Revision: 28330
          http://sourceforge.net/p/bibdesk/svn/28330
Author:   hofman
Date:     2023-07-19 17:08:36 +0000 (Wed, 19 Jul 2023)
Log Message:
-----------
mark items as imported in initializer override

Modified Paths:
--------------
    trunk/bibdesk/BDSKDocumentController.m
    trunk/bibdesk/BibDocument.h
    trunk/bibdesk/BibDocument.m

Modified: trunk/bibdesk/BDSKDocumentController.m
===================================================================
--- trunk/bibdesk/BDSKDocumentController.m      2023-07-19 16:52:52 UTC (rev 
28329)
+++ trunk/bibdesk/BDSKDocumentController.m      2023-07-19 17:08:36 UTC (rev 
28330)
@@ -350,10 +350,8 @@
             NSURL *tmpFileURL = [[NSFileManager defaultManager] 
temporaryFileURLWithBasename:tmpFileName];
             
             if ([filteredString writeToURL:tmpFileURL atomically:YES 
encoding:encoding error:outError]) {
-                if ((doc = [super makeDocumentForURL:nil 
withContentsOfURL:tmpFileURL ofType:BDSKBibTeXDocumentType error:outError])) {
-                    [doc setDisplayName:[[absoluteURL lastPathComponent] 
stringByDeletingPathExtension]];
-                    [(BibDocument *)doc markAsImported];
-                }
+                if ((doc = [self makeDocumentForURL:nil 
withContentsOfURL:tmpFileURL ofType:BDSKBibTeXDocumentType error:outError]))
+                    [doc setDisplayName:[tmpFileName 
stringByDeletingPathExtension]];
                 [[NSFileManager defaultManager] removeItemAtPath:[tmpFileURL 
path] error:NULL];
             }
         }

Modified: trunk/bibdesk/BibDocument.h
===================================================================
--- trunk/bibdesk/BibDocument.h 2023-07-19 16:52:52 UTC (rev 28329)
+++ trunk/bibdesk/BibDocument.h 2023-07-19 17:08:36 UTC (rev 28330)
@@ -347,7 +347,6 @@
 - (BOOL)readFromBibTeXData:(NSData *)data string:(NSString *)string 
fromURL:(NSURL *)absoluteURL encoding:(NSStringEncoding)encoding error:(NSError 
**)outError;
 
 - (void)reportTemporaryCiteKeysForNewDocument:(BOOL)isNewFile;
-- (void)markAsImported;
 
 - (NSString *)bibTeXStringDroppingInternal:(BOOL)drop forPublications:(NSArray 
*)items;
 - (NSString *)previewBibTeXStringForPublications:(NSArray *)items;

Modified: trunk/bibdesk/BibDocument.m
===================================================================
--- trunk/bibdesk/BibDocument.m 2023-07-19 16:52:52 UTC (rev 28329)
+++ trunk/bibdesk/BibDocument.m 2023-07-19 17:08:36 UTC (rev 28330)
@@ -267,6 +267,18 @@
 
 - (void)encodeWithCoder:(NSCoder *)encoder {}
 
+- (id)initForURL:(NSURL *)urlOrNil withContentsOfURL:(NSURL *)contentsURL 
ofType:(NSString *)typeName error:(NSError * _Nullable *)outError {
+    self = [super initForURL:urlOrNil withContentsOfURL:contentsURL 
ofType:typeName error:outError];
+    if (self) {
+        // set date-added for imports
+        NSDate *importDate = [NSDate date];
+        NSString *importDateDescription = [importDate standardDescription];
+        for (BibItem *pub in publications)
+            [pub markNeWithDate:importDate description:importDateDescription];
+    }
+    return self;
+}
+
 - (void)invalidateSearchFieldCellTimer{
     // AppKit bug workarounds:  NSSearchFieldCell's timer creates a retain 
cycle after typing in it, so we manually invalidate it when the document is 
deallocated to avoid leaking the cell and timer.  Further, if the insertion 
point is in the searchfield cell when the window closes, the field editor (and 
associated text system) and undo manager also leak, so we send -[documentWindow 
endEditingFor:nil] in windowWillClose:.
     id timer = [[searchField cell] valueForKey:@"_partialStringTimer"];
@@ -1974,14 +1986,6 @@
 
 #pragma mark -
 
-- (void)markAsImported {
-    // set date-added for imports
-    NSDate *importDate = [NSDate date];
-    NSString *importDateDescription = [importDate standardDescription];
-    for (BibItem *pub in publications)
-        [pub markNeWithDate:importDate description:importDateDescription];
-}
-
 - (void)generateForTemporaryCiteKey:(NSString *)tmpKey {
     NSArray *selItems = [self selectedPublications];
     [self selectPublications:[[self publications] allItemsForCiteKey:tmpKey]];

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



_______________________________________________
Bibdesk-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bibdesk-commit

Reply via email to