Revision: 28935
          http://sourceforge.net/p/bibdesk/svn/28935
Author:   hofman
Date:     2024-08-18 16:25:19 +0000 (Sun, 18 Aug 2024)
Log Message:
-----------
Don't check sharedPreviewer directly to see whether its window is visible, use 
class method that first checks whether the sharedPreviewer exists. So we don't 
need to create it early for safety.

Modified Paths:
--------------
    trunk/bibdesk/BDSKAppController.m
    trunk/bibdesk/BDSKPreviewer.h
    trunk/bibdesk/BDSKPreviewer.m
    trunk/bibdesk/BibDocument.m
    trunk/bibdesk/BibDocument_UI.m
    trunk/bibdesk/BibPref_TeX.m

Modified: trunk/bibdesk/BDSKAppController.m
===================================================================
--- trunk/bibdesk/BDSKAppController.m   2024-08-18 16:03:54 UTC (rev 28934)
+++ trunk/bibdesk/BDSKAppController.m   2024-08-18 16:25:19 UTC (rev 28935)
@@ -344,10 +344,6 @@
         [self showReadMeFile:nil];
     [[NSUserDefaults standardUserDefaults] setObject:versionString 
forKey:BDSKLastVersionLaunchedKey];
     
-    // Ensure the previewer and TeX task get created now in order to avoid a 
spurious "unable to copy helper file" warning when quit->document window 
closes->first call to [BDSKPreviewer sharedPreviewer]
-    if([[NSUserDefaults standardUserDefaults] boolForKey:BDSKUsesTeXKey])
-        [BDSKPreviewer sharedPreviewer];
-       
        if([[NSUserDefaults standardUserDefaults] 
boolForKey:BDSKShowingPreviewKey])
                [[BDSKPreviewer sharedPreviewer] showWindow:self];
     
@@ -464,7 +460,7 @@
        if (act == @selector(toggleShowingPreviewPanel:)){ 
                // menu item for toggling the preview panel
                // set the on/off state according to the panel's visibility
-               if ([[BDSKPreviewer sharedPreviewer] isWindowVisible]) {
+               if ([BDSKPreviewer isSharedPreviewerVisible]) {
                        [menuItem setState:NSOnState];
                }else {
                        [menuItem setState:NSOffState];

Modified: trunk/bibdesk/BDSKPreviewer.h
===================================================================
--- trunk/bibdesk/BDSKPreviewer.h       2024-08-18 16:03:54 UTC (rev 28934)
+++ trunk/bibdesk/BDSKPreviewer.h       2024-08-18 16:25:19 UTC (rev 28935)
@@ -75,6 +75,7 @@
        @result Pointer to the single BDSKPreviewer instance.
 */
 @property (class, nonatomic, readonly) BDSKPreviewer *sharedPreviewer;
+@property (class, nonatomic, readonly, getter=isSharedPreviewerVisible) BOOL 
sharedPreviewerVisible;
 
 @property (nonatomic, retain) IBOutlet BDSKZoomablePDFView *pdfView;
 @property (nonatomic, strong) IBOutlet NSTextView *logView;

Modified: trunk/bibdesk/BDSKPreviewer.m
===================================================================
--- trunk/bibdesk/BDSKPreviewer.m       2024-08-18 16:03:54 UTC (rev 28934)
+++ trunk/bibdesk/BDSKPreviewer.m       2024-08-18 16:25:19 UTC (rev 28935)
@@ -104,6 +104,10 @@
 // Using isEqual:[BDSKSharedPreviewer sharedPreviewer] will lead to a leak if 
awakeFromNib is called while +sharedPreviewer is on the stack for the first 
time, since it calls isSharedPreviewer.  This is readily seen from the 
backtrace in 
http://sourceforge.net/tracker/index.php?func=detail&aid=1936951&group_id=61487&atid=497423
 although it doesn't fix that problem.
 - (BOOL)isSharedPreviewer { return [self isEqual:sharedPreviewer]; }
 
++ (BOOL)isSharedPreviewerVisible {
+    return sharedPreviewer != nil && [sharedPreviewer isWindowVisible];
+}
+
 #pragma mark UI setup and display
 
 - (void)windowDidLoad{

Modified: trunk/bibdesk/BibDocument.m
===================================================================
--- trunk/bibdesk/BibDocument.m 2024-08-18 16:03:54 UTC (rev 28934)
+++ trunk/bibdesk/BibDocument.m 2024-08-18 16:25:19 UTC (rev 28935)
@@ -672,7 +672,7 @@
     
     // reset the previewer; don't send [self updatePreviews:] here, as the 
tableview will be gone by the time the queue posts the notification
     if ([[NSUserDefaults standardUserDefaults] boolForKey:BDSKUsesTeXKey]) {
-        if ([[BDSKPreviewer sharedPreviewer] isWindowVisible] &&
+        if ([BDSKPreviewer isSharedPreviewerVisible] &&
             [self isMainDocument] &&
             [self numberOfSelectedPubs] != 0)
             [[BDSKPreviewer sharedPreviewer] updateWithoutBibTeXString];

Modified: trunk/bibdesk/BibDocument_UI.m
===================================================================
--- trunk/bibdesk/BibDocument_UI.m      2024-08-18 16:03:54 UTC (rev 28934)
+++ trunk/bibdesk/BibDocument_UI.m      2024-08-18 16:25:19 UTC (rev 28935)
@@ -131,7 +131,7 @@
     [self updateSidePreviewPane];
     
     if([[NSUserDefaults standardUserDefaults] boolForKey:BDSKUsesTeXKey] &&
-          [[BDSKPreviewer sharedPreviewer] isWindowVisible] &&
+          [BDSKPreviewer isSharedPreviewerVisible] &&
        [self isMainDocument])
         [self updatePreviewer:[BDSKPreviewer sharedPreviewer]];
 }
@@ -1827,7 +1827,7 @@
             if ([previewer isVisible])
                 [self updatePreviews];
             else if ([[NSUserDefaults standardUserDefaults] 
boolForKey:BDSKUsesTeXKey] &&
-                    [[BDSKPreviewer sharedPreviewer] isWindowVisible] &&
+                    [BDSKPreviewer isSharedPreviewerVisible] &&
                     [self isMainDocument])
                 [self updatePreviewer:[BDSKPreviewer sharedPreviewer]];
         } else if ([key isEqualToString:BDSKUsesTeXKey]) {

Modified: trunk/bibdesk/BibPref_TeX.m
===================================================================
--- trunk/bibdesk/BibPref_TeX.m 2024-08-18 16:03:54 UTC (rev 28934)
+++ trunk/bibdesk/BibPref_TeX.m 2024-08-18 16:25:19 UTC (rev 28935)
@@ -192,7 +192,7 @@
             [alert setInformativeText:error];
             [alert beginSheetModalForWindow:[[self view] window] 
completionHandler:NULL];
         }
-    } else if ([key isEqualToString:BDSKUsesTeXKey] && [sud 
boolForKey:BDSKUsesTeXKey] == NO) {
+    } else if ([key isEqualToString:BDSKUsesTeXKey] && [sud 
boolForKey:BDSKUsesTeXKey] == NO && [BDSKPreviewer isSharedPreviewerVisible]) {
         // hide preview panel if necessary
         [[BDSKPreviewer sharedPreviewer] hideWindow:self];
     }

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