Revision: 18446
          http://bibdesk.svn.sourceforge.net/bibdesk/?rev=18446&view=rev
Author:   hofman
Date:     2012-01-28 12:06:37 +0000 (Sat, 28 Jan 2012)
Log Message:
-----------
Filer maintains all open filer error controllers, so they do not need to retain 
themselves. Close all filer error controllers for document when the document 
closes.

Modified Paths:
--------------
    trunk/bibdesk/BDSKFiler.h
    trunk/bibdesk/BDSKFiler.m
    trunk/bibdesk/BDSKFilerErrorController.h
    trunk/bibdesk/BDSKFilerErrorController.m
    trunk/bibdesk/BibDocument.m

Modified: trunk/bibdesk/BDSKFiler.h
===================================================================
--- trunk/bibdesk/BDSKFiler.h   2012-01-28 11:24:19 UTC (rev 18445)
+++ trunk/bibdesk/BDSKFiler.h   2012-01-28 12:06:37 UTC (rev 18446)
@@ -68,6 +68,7 @@
 
 @interface BDSKFiler : NSWindowController {
        IBOutlet NSProgressIndicator *progressIndicator;
+    NSMutableArray *errorControllers;
 }
 
 + (BDSKFiler *)sharedFiler;
@@ -100,6 +101,8 @@
 */
 - (BOOL)movePapers:(NSArray *)paperInfos forField:(NSString *)field 
fromDocument:(BibDocument *)doc options:(BDSKFilerOptions)masks;
 
+- (void)closeErrorControllersForDocument:(BibDocument *)document;
+
 @end
 
 

Modified: trunk/bibdesk/BDSKFiler.m
===================================================================
--- trunk/bibdesk/BDSKFiler.m   2012-01-28 11:24:19 UTC (rev 18445)
+++ trunk/bibdesk/BDSKFiler.m   2012-01-28 12:06:37 UTC (rev 18446)
@@ -69,9 +69,34 @@
 
 - (id)init{
     BDSKPRECONDITION(sharedFiler == nil);
-       return [super initWithWindowNibName:@"AutoFileProgress"];
+       self = [super initWithWindowNibName:@"AutoFileProgress"];
+    if (self) {
+        errorControllers = [[NSMutableArray alloc] init];
+    }
+    return self;
 }
 
+- (void)dealloc {
+    BDSKDESTROY(errorControllers);
+    [super dealloc];
+}
+
+- (void)handleErrorWindowWillCloseNotification:(NSNotification *)notification {
+    NSWindow *window = [notification object];
+    BDSKFilerErrorController *errorController = [[[window windowController] 
retain] autorelease];
+    [errorControllers removeObject:errorController];
+    [[NSNotificationCenter defaultCenter] removeObserver:self 
name:NSWindowWillCloseNotification object:window];
+}
+
+- (void)closeErrorControllersForDocument:(BibDocument *)document {
+    NSUInteger i = [errorControllers count];
+    while (i-- > 0) {
+        BDSKFilerErrorController *errorController = [errorControllers 
objectAtIndex:i];
+        if ([errorController document] == document)
+            [errorController close];
+    }
+}
+
 #pragma mark Auto file methods
 
 - (BOOL)checkPapersFolder {
@@ -229,7 +254,9 @@
        
        if ([errorInfoDicts count] > 0) {
                BDSKFilerErrorController *errorController = 
[[[BDSKFilerErrorController alloc] initWithErrors:errorInfoDicts forField:field 
fromDocument:doc options:mask] autorelease];
+        [errorControllers addObject:errorController];
         [errorController showWindow:nil];
+        [[NSNotificationCenter defaultCenter] addObserver:self 
selector:@selector(handleErrorWindowWillCloseNotification:) 
name:NSWindowWillCloseNotification object:[errorController window]];
     }
     
     return [fileInfoDicts count] > 0;

Modified: trunk/bibdesk/BDSKFilerErrorController.h
===================================================================
--- trunk/bibdesk/BDSKFilerErrorController.h    2012-01-28 11:24:19 UTC (rev 
18445)
+++ trunk/bibdesk/BDSKFilerErrorController.h    2012-01-28 12:06:37 UTC (rev 
18446)
@@ -62,6 +62,8 @@
 - (IBAction)selectAll:(id)sender;
 - (IBAction)showFile:(id)sender;
 
+- (BibDocument *)sourceDocument;
+
 - (NSArray *)errorInfoDicts;
 - (NSUInteger)countOfErrorInfoDicts;
 - (id)objectInErrorInfoDictsAtIndex:(NSUInteger)index;

Modified: trunk/bibdesk/BDSKFilerErrorController.m
===================================================================
--- trunk/bibdesk/BDSKFilerErrorController.m    2012-01-28 11:24:19 UTC (rev 
18445)
+++ trunk/bibdesk/BDSKFilerErrorController.m    2012-01-28 12:06:37 UTC (rev 
18446)
@@ -98,18 +98,8 @@
        [tv setTarget:self];
 }
 
-- (void)windowWillClose:(NSNotification *)notification {
-    [self autorelease];
-}
-
 #pragma mark Actions
 
-- (IBAction)showWindow:(id)sender {
-    // we have to stay around until the window closes, this is balanced in 
windowWillClose:
-    [self retain];
-    [super showWindow:sender];
-}
-
 - (IBAction)done:(id)sender{
     [self close];
 }
@@ -218,6 +208,10 @@
 
 #pragma mark Accessors
 
+- (BibDocument *)sourceDocument {
+    return document;
+}
+
 - (NSArray *)errorInfoDicts {
     return errorInfoDicts;
 }

Modified: trunk/bibdesk/BibDocument.m
===================================================================
--- trunk/bibdesk/BibDocument.m 2012-01-28 11:24:19 UTC (rev 18445)
+++ trunk/bibdesk/BibDocument.m 2012-01-28 12:06:37 UTC (rev 18446)
@@ -658,6 +658,8 @@
        [self numberOfSelectedPubs] != 0)
         [[BDSKPreviewer sharedPreviewer] updateWithBibTeXString:nil];    
        
+    [[BDSKFiler sharedFiler] closeErrorControllersForDocument:self];
+    
        [pboardHelper setDelegate:nil];
     [pboardHelper release];
     pboardHelper = nil;

This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.


------------------------------------------------------------------------------
Try before you buy = See our experts in action!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-dev2
_______________________________________________
Bibdesk-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bibdesk-commit

Reply via email to