Revision: 14663
          http://sourceforge.net/p/skim-app/code/14663
Author:   hofman
Date:     2024-11-10 09:31:23 +0000 (Sun, 10 Nov 2024)
Log Message:
-----------
Arguments to method to save recent document info to force it. Alwqys make sure 
recent document info is saved when terminating the app or closing a document.

Modified Paths:
--------------
    trunk/NSDocument_SKExtensions.h
    trunk/NSDocument_SKExtensions.m
    trunk/SKApplicationController.m
    trunk/SKMainDocument.m
    trunk/SKMainWindowController_UI.m

Modified: trunk/NSDocument_SKExtensions.h
===================================================================
--- trunk/NSDocument_SKExtensions.h     2024-11-09 15:26:02 UTC (rev 14662)
+++ trunk/NSDocument_SKExtensions.h     2024-11-10 09:31:23 UTC (rev 14663)
@@ -64,7 +64,7 @@
 
 #pragma mark Document Setup
 
-- (void)saveRecentDocumentInfo;
+- (void)saveRecentDocumentInfo:(BOOL)forced;
 - (void)applySetup:(NSDictionary<NSString *, id> *)setup;
 - (void)applyOptions:(NSDictionary<NSString *, id> *)options;
 @property (nonatomic, nullable, readonly) NSDictionary<NSString *, id> 
*currentDocumentSetup;

Modified: trunk/NSDocument_SKExtensions.m
===================================================================
--- trunk/NSDocument_SKExtensions.m     2024-11-09 15:26:02 UTC (rev 14662)
+++ trunk/NSDocument_SKExtensions.m     2024-11-10 09:31:23 UTC (rev 14663)
@@ -95,7 +95,7 @@
 
 #pragma mark Document Setup
 
-- (void)saveRecentDocumentInfo {}
+- (void)saveRecentDocumentInfo:(BOOL)forced {}
 
 - (void)applySetup:(NSDictionary *)setup {}
 

Modified: trunk/SKApplicationController.m
===================================================================
--- trunk/SKApplicationController.m     2024-11-09 15:26:02 UTC (rev 14662)
+++ trunk/SKApplicationController.m     2024-11-10 09:31:23 UTC (rev 14663)
@@ -161,7 +161,9 @@
 
 - (void)registerCurrentDocuments:(id)timerOrNotification {
     [[NSUserDefaults standardUserDefaults] setObject:[[NSApp orderedDocuments] 
valueForKey:CURRENTDOCUMENTSETUP_KEY] forKey:SKLastOpenFileNamesKey];
-    [[[NSDocumentController sharedDocumentController] documents] 
makeObjectsPerformSelector:@selector(saveRecentDocumentInfo)];
+    BOOL forced = [timerOrNotification 
isEqual:SKApplicationStartsTerminatingNotification];
+    for (NSDocument *doc in [[NSDocumentController sharedDocumentController] 
documents])
+        [doc saveRecentDocumentInfo:forced];
 }
 
 #pragma mark NSApplication delegate

Modified: trunk/SKMainDocument.m
===================================================================
--- trunk/SKMainDocument.m      2024-11-09 15:26:02 UTC (rev 14662)
+++ trunk/SKMainDocument.m      2024-11-10 09:31:23 UTC (rev 14663)
@@ -233,8 +233,8 @@
     [super removeWindowController:windowController];
 }
 
-- (void)saveRecentDocumentInfo {
-    if ([[self mainWindowController] recentInfoNeedsUpdate]) {
+- (void)saveRecentDocumentInfo:(BOOL)forced {
+    if (forced || [[self mainWindowController] recentInfoNeedsUpdate]) {
         NSURL *fileURL = [self fileURL];
         NSUInteger pageIndex = [[[self pdfView] currentPage] pageIndex];
         if (fileURL && pageIndex != NSNotFound) {

Modified: trunk/SKMainWindowController_UI.m
===================================================================
--- trunk/SKMainWindowController_UI.m   2024-11-09 15:26:02 UTC (rev 14662)
+++ trunk/SKMainWindowController_UI.m   2024-11-10 09:31:23 UTC (rev 14663)
@@ -250,8 +250,7 @@
 
 - (void)windowWillClose:(NSNotification *)notification {
     if ([[notification object] isEqual:[self window]]) {
-        [self setRecentInfoNeedsUpdate:YES];
-        [[self document] saveRecentDocumentInfo];
+        [[self document] saveRecentDocumentInfo:YES];
         if ([[self document] fileURL])
             [[SKBookmarkController sharedBookmarkController] 
addClosedDocumentWithSetup:[[self document] currentDocumentSetup]];
         if ([[pdfView document] isFinding])

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



_______________________________________________
Skim-app-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/skim-app-commit

Reply via email to