Revision: 26169
          http://sourceforge.net/p/bibdesk/svn/26169
Author:   hofman
Date:     2021-06-08 09:50:31 +0000 (Tue, 08 Jun 2021)
Log Message:
-----------
Let complex string editor observe sheet closing on parent when in a sheet, so 
the sheet controllers don't need to explicitly remove it

Modified Paths:
--------------
    trunk/bibdesk/BDSKComplexStringEditor.m
    trunk/bibdesk/BDSKComplexStringFormatter.h
    trunk/bibdesk/BDSKComplexStringFormatter.m
    trunk/bibdesk/BDSKMacroWindowController.m
    trunk/bibdesk/BDSKTextImportController.m

Modified: trunk/bibdesk/BDSKComplexStringEditor.m
===================================================================
--- trunk/bibdesk/BDSKComplexStringEditor.m     2021-06-08 06:30:35 UTC (rev 
26168)
+++ trunk/bibdesk/BDSKComplexStringEditor.m     2021-06-08 09:50:31 UTC (rev 
26169)
@@ -181,10 +181,16 @@
                    name:NSWindowDidResignKeyNotification
                  object:controlWindow];
     }
-    [nc addObserver:self
-           selector:@selector(controlWindowWillClose:)
-               name:NSWindowWillCloseNotification
-             object:controlWindow];
+    if ([controlWindow sheetParent])
+        [nc addObserver:self
+               selector:@selector(controlWindowWillClose:)
+                   name:NSWindowDidEndSheetNotification
+                 object:[controlWindow sheetParent]];
+    else
+        [nc addObserver:self
+               selector:@selector(controlWindowWillClose:)
+                   name:NSWindowWillCloseNotification
+                 object:controlWindow];
 }
 
 - (void)unregisterForNotifications {
@@ -204,7 +210,11 @@
         [nc removeObserver:self name:NSWindowDidBecomeKeyNotification 
object:controlWindow];
         [nc removeObserver:self name:NSWindowDidResignKeyNotification 
object:controlWindow];
     }
-    [nc removeObserver:self name:NSWindowWillCloseNotification 
object:controlWindow];
+    if ([controlWindow sheetParent])
+        [nc removeObserver:self name:NSWindowDidEndSheetNotification 
object:[controlWindow sheetParent]];
+    else
+        [nc removeObserver:self name:NSWindowWillCloseNotification 
object:controlWindow];
+
 }
 
 // @@ Dark mode
@@ -268,7 +278,7 @@
 #pragma mark Window close delegate method
 
 - (void)windowWillClose:(NSNotification *)notification {
-    // this gets called whenever an editor window closes
+    // this should never happen, we should only close when removed
     if ([self isAttached]){
         //BDSKASSERT_NOT_REACHED("macro textfield window closed while 
editing");
         [self remove];

Modified: trunk/bibdesk/BDSKComplexStringFormatter.h
===================================================================
--- trunk/bibdesk/BDSKComplexStringFormatter.h  2021-06-08 06:30:35 UTC (rev 
26168)
+++ trunk/bibdesk/BDSKComplexStringFormatter.h  2021-06-08 09:50:31 UTC (rev 
26169)
@@ -50,6 +50,5 @@
 @property (nonatomic) BOOL editAsComplexString;
 
 - (void)attachComplexStringEditorForCell:(NSTextFieldCell *)cell;
-- (void)removeComplexStringEditor;
 
 @end

Modified: trunk/bibdesk/BDSKComplexStringFormatter.m
===================================================================
--- trunk/bibdesk/BDSKComplexStringFormatter.m  2021-06-08 06:30:35 UTC (rev 
26168)
+++ trunk/bibdesk/BDSKComplexStringFormatter.m  2021-06-08 09:50:31 UTC (rev 
26169)
@@ -60,7 +60,9 @@
 }
 
 - (void)dealloc {
-    [self removeComplexStringEditor];
+    // should never happen
+    if ([complexStringEditor isAttached])
+        [complexStringEditor remove];
     BDSKDESTROY(macroResolver);
     BDSKDESTROY(complexStringEditor);
     [super dealloc];
@@ -140,9 +142,4 @@
     }
 }
 
-- (void)removeComplexStringEditor {
-    if ([complexStringEditor isAttached])
-        [complexStringEditor remove];
-}
-
 @end

Modified: trunk/bibdesk/BDSKMacroWindowController.m
===================================================================
--- trunk/bibdesk/BDSKMacroWindowController.m   2021-06-08 06:30:35 UTC (rev 
26168)
+++ trunk/bibdesk/BDSKMacroWindowController.m   2021-06-08 09:50:31 UTC (rev 
26169)
@@ -179,7 +179,6 @@
         [[self window] endEditingFor:nil];
     if (macroResolver != [BDSKMacroResolver defaultMacroResolver])
         [tableView setTypeSelectHelper:nil];
-    [tableCellFormatter removeComplexStringEditor];
 }
 
 // we want to have the same undoManager as our document, so we use this 

Modified: trunk/bibdesk/BDSKTextImportController.m
===================================================================
--- trunk/bibdesk/BDSKTextImportController.m    2021-06-08 06:30:35 UTC (rev 
26168)
+++ trunk/bibdesk/BDSKTextImportController.m    2021-06-08 09:50:31 UTC (rev 
26169)
@@ -262,8 +262,6 @@
     
     [itemTableView setTypeSelectHelper:nil];
     
-    [tableCellFormatter removeComplexStringEditor];
-    
     [super dismiss:sender];
 }
 

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



_______________________________________________
Bibdesk-commit mailing list
Bibdesk-commit@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bibdesk-commit

Reply via email to