adium 4339:ac27d9e327ac: Clean up some shared references in the ...
commits at adium.im
commits at adium.im
Fri Dec 2 00:17:35 UTC 2011
details: http://hg.adium.im/adium/rev/ac27d9e327ac
revision: 4339:ac27d9e327ac
branch: (none)
author: Stephen Holt <sholt at adium.im>
date: Thu Dec 01 16:15:32 2011 -0800
Clean up some shared references in the log viewer plugin. Donno if this was causing the chat name color problems, but I haven't seen it since. Refs #15574.
diffs (112 lines):
diff -r 8777972e1760 -r ac27d9e327ac Source/AILogViewerWindowController.m
--- a/Source/AILogViewerWindowController.m Thu Dec 01 15:31:20 2011 -0800
+++ b/Source/AILogViewerWindowController.m Thu Dec 01 16:15:32 2011 -0800
@@ -88,6 +88,7 @@
@interface AILogViewerWindowController ()
+ (NSOperationQueue *)sharedLogViewerQueue;
++ (AILogViewerWindowController *)sharedLogViewerForPlugin:(id)inPlugin;
- (id)initWithWindowNibName:(NSString *)windowNibName plugin:(id)inPlugin;
- (void)initLogFiltering;
@@ -128,7 +129,6 @@
@implementation AILogViewerWindowController
-static AILogViewerWindowController *sharedLogViewerInstance = nil;
static NSInteger toArraySort(id itemA, id itemB, void *context);
+ (NSOperationQueue *)sharedLogViewerQueue
@@ -149,11 +149,23 @@
return @"LogViewer";
}
+static AILogViewerWindowController *__sharedLogViewer = nil;
++ (AILogViewerWindowController *)sharedLogViewerForPlugin:(id)inPlugin
+{
+ if (inPlugin && !__sharedLogViewer) {
+ __sharedLogViewer = [[self alloc] initWithWindowNibName:[self nibName] plugin:inPlugin];
+ }
+ return __sharedLogViewer;
+}
+
++ (void)destroySharedLogViewer
+{
+ [__sharedLogViewer autorelease]; __sharedLogViewer = nil;
+}
+
+ (id)openForPlugin:(id)inPlugin
{
- if (!sharedLogViewerInstance) {
- sharedLogViewerInstance = [[self alloc] initWithWindowNibName:[self nibName] plugin:inPlugin];
- }
+ AILogViewerWindowController *sharedLogViewerInstance = [self sharedLogViewerForPlugin:inPlugin];
[sharedLogViewerInstance showWindow:nil];
@@ -161,9 +173,10 @@
}
+ (id)openLogAtPath:(NSString *)inPath plugin:(id)inPlugin
-{
+{
[self openForPlugin:inPlugin];
+ AILogViewerWindowController *sharedLogViewerInstance = [self sharedLogViewerForPlugin:inPlugin];
[sharedLogViewerInstance openLogAtPath:inPath];
return sharedLogViewerInstance;
@@ -172,9 +185,7 @@
//Open the log viewer window to a specific contact's logs
+ (id)openForContact:(AIListContact *)inContact plugin:(id)inPlugin
{
- if (!sharedLogViewerInstance) {
- sharedLogViewerInstance = [[self alloc] initWithWindowNibName:[self nibName] plugin:inPlugin];
- }
+ AILogViewerWindowController *sharedLogViewerInstance = [self sharedLogViewerForPlugin:inPlugin];
[sharedLogViewerInstance _willOpenForContact];
[sharedLogViewerInstance showWindow:nil];
@@ -186,9 +197,7 @@
+ (id)openForChatName:(NSString *)inChatName withAccount:(AIAccount *)inAccount plugin:(id)inPlugin
{
- if (!sharedLogViewerInstance) {
- sharedLogViewerInstance = [[self alloc] initWithWindowNibName:[self nibName] plugin:inPlugin];
- }
+ AILogViewerWindowController *sharedLogViewerInstance = [self sharedLogViewerForPlugin:inPlugin];
[sharedLogViewerInstance _willOpenForContact];
[sharedLogViewerInstance showWindow:nil];
@@ -201,12 +210,13 @@
//Returns the window controller if one exists
+ (id)existingWindowController
{
- return sharedLogViewerInstance;
+ return [self sharedLogViewerForPlugin:nil];
}
//Close the log viewer window
+ (void)closeSharedInstance
{
+ AILogViewerWindowController *sharedLogViewerInstance = [self existingWindowController];
if (sharedLogViewerInstance) {
[sharedLogViewerInstance closeWindow:nil];
}
@@ -537,7 +547,7 @@
[activeSearchString release]; activeSearchString = nil;
[self updateRankColumnVisibility];
- [sharedLogViewerInstance autorelease]; sharedLogViewerInstance = nil;
+ [[self class] destroySharedLogViewer];
[toolbarItems autorelease]; toolbarItems = nil;
}
@@ -2234,6 +2244,7 @@
static NSInteger toArraySort(id itemA, id itemB, void *context)
{
+ AILogViewerWindowController *sharedLogViewerInstance = [AILogViewerWindowController existingWindowController];
NSString *nameA = [sharedLogViewerInstance outlineView:nil objectValueForTableColumn:nil byItem:itemA];
NSString *nameB = [sharedLogViewerInstance outlineView:nil objectValueForTableColumn:nil byItem:itemB];
NSComparisonResult result = [nameA caseInsensitiveCompare:nameB];
More information about the commits
mailing list