Revision: 27371
http://sourceforge.net/p/bibdesk/svn/27371
Author: hofman
Date: 2022-04-15 14:04:23 +0000 (Fri, 15 Apr 2022)
Log Message:
-----------
Remove temp directory for preview after loading the attributed string in the
text view
Modified Paths:
--------------
trunk/bibdesk/BibDocument_UI.m
Modified: trunk/bibdesk/BibDocument_UI.m
===================================================================
--- trunk/bibdesk/BibDocument_UI.m 2022-04-15 06:30:20 UTC (rev 27370)
+++ trunk/bibdesk/BibDocument_UI.m 2022-04-15 14:04:23 UTC (rev 27371)
@@ -164,6 +164,7 @@
BDSKTemplate *template = [BDSKTemplate templateForStyle:templateStyle] ?:
[BDSKTemplate templateForStyle:[BDSKTemplate
defaultStyleNameForFileType:@"rtf"]];
NSAttributedString *templateString = nil;
NSColor *backgroundColor = nil;
+ NSURL *tmpDirURL = nil;
// make sure this is really one of the attributed string types...
if([template templateFormat] & BDSKTemplateFormatRichText){
@@ -177,13 +178,12 @@
// we generally assume UTF-8 encoding for all template-related files
if ([accessoryURLs count] > 0) {
NSFileManager *fm = [NSFileManager defaultManager];
- NSURL *tmpDirURL = [fm
uniqueTemporaryDirectoryURLWithBasename:@""];
+ tmpDirURL = [fm uniqueTemporaryDirectoryURLWithBasename:@""];
for (NSURL *accessoryURL in accessoryURLs)
[fm copyItemAtURL:accessoryURL toURL:[tmpDirURL
URLByAppendingPathComponent:[accessoryURL lastPathComponent] isDirectory:NO]
error:NULL];
NSURL *tmpFileURL = [fm uniqueFileURLWithName:[@"templatepreview"
stringByAppendingPathExtension:[template fileExtension]] atURL:tmpDirURL
isDirectory:NO];
[str writeToURL:tmpFileURL atomically:NO
encoding:NSUTF8StringEncoding error:NULL];
templateString = [[[NSAttributedString alloc]
initWithURL:tmpFileURL options:[NSDictionary dictionary] documentAttributes:nil
error:NULL] autorelease];
- dispatch_async(dispatch_get_main_queue(), ^{ [fm
cleanupTemporaryDirectoryAtURL:tmpDirURL]; });
} else if ([template templateFormat] == BDSKTemplateFormatPlainHTML)
templateString = [[[NSAttributedString alloc] initWithHTML:[str
dataUsingEncoding:NSUTF8StringEncoding] documentAttributes:NULL] autorelease];
else
@@ -204,7 +204,11 @@
if (RUNNING_AFTER(10_13) && backgroundColor == nil)
[textStorage addTextColorAttribute];
[textStorage endEditing];
+ [textView didChangeText];
+ if (tmpDirURL)
+ [[NSFileManager defaultManager]
cleanupTemporaryDirectoryAtURL:tmpDirURL];
+
// @@ Dark mode
[textView setBackgroundColor:backgroundColor ?: [NSColor
controlBackgroundColor]];
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