Revision: 7141
          http://skim-app.svn.sourceforge.net/skim-app/?rev=7141&view=rev
Author:   hofman
Date:     2011-03-09 12:07:04 +0000 (Wed, 09 Mar 2011)

Log Message:
-----------
Notify just before removing a document, so it's safer to use the document. 
Don't notify after adding a document as we don't observe that.

Modified Paths:
--------------
    trunk/SKDocumentController.h
    trunk/SKDocumentController.m
    trunk/SKMainWindowController_UI.m

Modified: trunk/SKDocumentController.h
===================================================================
--- trunk/SKDocumentController.h        2011-03-07 17:53:39 UTC (rev 7140)
+++ trunk/SKDocumentController.h        2011-03-09 12:07:04 UTC (rev 7141)
@@ -58,7 +58,7 @@
 extern NSString *SKDocumentSetupAliasKey;
 extern NSString *SKDocumentSetupFileNameKey;
 
-extern NSString *SKDocumentControllerDidAddDocumentNotification;
+extern NSString *SKDocumentControllerWillRemoveDocumentNotification;
 extern NSString *SKDocumentControllerDidRemoveDocumentNotification;
 extern NSString *SKDocumentDidShowNotification;
 

Modified: trunk/SKDocumentController.m
===================================================================
--- trunk/SKDocumentController.m        2011-03-07 17:53:39 UTC (rev 7140)
+++ trunk/SKDocumentController.m        2011-03-09 12:07:04 UTC (rev 7141)
@@ -75,7 +75,7 @@
 NSString *SKDocumentSetupAliasKey = @"_BDAlias";
 NSString *SKDocumentSetupFileNameKey = @"fileName";
 
-NSString *SKDocumentControllerDidAddDocumentNotification = 
@"SKDocumentControllerDidAddDocumentNotification";
+NSString *SKDocumentControllerWillRemoveDocumentNotification = 
@"SKDocumentControllerWillRemoveDocumentNotification";
 NSString *SKDocumentControllerDidRemoveDocumentNotification = 
@"SKDocumentControllerDidRemoveDocumentNotification";
 NSString *SKDocumentDidShowNotification = @"SKDocumentDidShowNotification";
 
@@ -102,16 +102,12 @@
     [super dealloc];
 }
 
-- (void)addDocument:(NSDocument *)document {
-    [super addDocument:document];
-    [[NSNotificationCenter defaultCenter] 
postNotificationName:SKDocumentControllerDidAddDocumentNotification 
-            object:self userInfo:[NSDictionary 
dictionaryWithObjectsAndKeys:document, SKDocumentControllerDocumentKey, nil]];
-}
-
 - (void)removeDocument:(NSDocument *)document {
-    [super removeDocument:[[document retain] autorelease]];
-    [[NSNotificationCenter defaultCenter] 
postNotificationName:SKDocumentControllerDidRemoveDocumentNotification 
+    [[NSNotificationCenter defaultCenter] 
postNotificationName:SKDocumentControllerWillRemoveDocumentNotification 
             object:self userInfo:[NSDictionary 
dictionaryWithObjectsAndKeys:document, SKDocumentControllerDocumentKey, nil]];
+    [super removeDocument:document];
+    [[NSNotificationCenter defaultCenter] 
postNotificationName:SKDocumentControllerDidRemoveDocumentNotification 
+            object:self userInfo:nil];
 }
 
 

Modified: trunk/SKMainWindowController_UI.m
===================================================================
--- trunk/SKMainWindowController_UI.m   2011-03-07 17:53:39 UTC (rev 7140)
+++ trunk/SKMainWindowController_UI.m   2011-03-09 12:07:04 UTC (rev 7141)
@@ -1708,7 +1708,7 @@
         [self updateThumbnailAtPageIndex:[newPage pageIndex]];
 }
 
-- (void)handleDidRemoveDocumentNotification:(NSNotification *)notification {
+- (void)handleWillRemoveDocumentNotification:(NSNotification *)notification {
     if ([[notification userInfo] objectForKey:SKDocumentControllerDocumentKey] 
== presentationNotesDocument)
         [self setPresentationNotesDocument:nil];
 }
@@ -1747,8 +1747,8 @@
     [nc addObserver:self selector:@selector(observeUndoManagerCheckpoint:) 
                              name:NSUndoManagerCheckpointNotification 
object:[[self document] undoManager]];
     //  SKDocumentController
-    [nc addObserver:self 
selector:@selector(handleDidRemoveDocumentNotification:) 
-                             
name:SKDocumentControllerDidRemoveDocumentNotification object:nil];
+    [nc addObserver:self 
selector:@selector(handleWillRemoveDocumentNotification:) 
+                             
name:SKDocumentControllerWillRemoveDocumentNotification object:nil];
 }
 
 @end


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

------------------------------------------------------------------------------
Colocation vs. Managed Hosting
A question and answer guide to determining the best fit
for your organization - today and in the future.
http://p.sf.net/sfu/internap-sfd2d
_______________________________________________
Skim-app-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/skim-app-commit

Reply via email to