diff options
author | rowanbeentje <rowan@beent.je> | 2010-11-15 01:25:38 +0000 |
---|---|---|
committer | rowanbeentje <rowan@beent.je> | 2010-11-15 01:25:38 +0000 |
commit | 9b9cb791f818faee0cd9af8e89ee4bd28a60ca24 (patch) | |
tree | 1828866c8463cef35b1601cb96e32b70cf30a92a /Source | |
parent | a3c99039fea0827520aa83e412ce98cf15e3e57d (diff) | |
download | sequelpro-9b9cb791f818faee0cd9af8e89ee4bd28a60ca24.tar.gz sequelpro-9b9cb791f818faee0cd9af8e89ee4bd28a60ca24.tar.bz2 sequelpro-9b9cb791f818faee0cd9af8e89ee4bd28a60ca24.zip |
- Switch to explicit memory management of strings in the QuickLook plugin when viewing SQL files - this fixes certain crashers, addressing Issue 896.
- Tweak a misspelling in the templates
Diffstat (limited to 'Source')
-rw-r--r-- | Source/GeneratePreviewForURL.m | 23 |
1 files changed, 15 insertions, 8 deletions
diff --git a/Source/GeneratePreviewForURL.m b/Source/GeneratePreviewForURL.m index 841fca8d..0fd6514d 100644 --- a/Source/GeneratePreviewForURL.m +++ b/Source/GeneratePreviewForURL.m @@ -394,17 +394,17 @@ OSStatus GeneratePreviewForURL(void *thisInterface, QLPreviewRequestRef preview, // compose the html and perform syntax highlighting // read the file and try to get a proper encoding - NSString *sqlText = [NSString stringWithContentsOfFile:[myURL path] encoding:sqlEncoding error:&readError]; - NSMutableString *sqlHTML = [NSMutableString string]; - NSString *truncatedString = @""; + NSString *sqlText = [[NSString alloc] initWithContentsOfFile:[myURL path] encoding:sqlEncoding error:&readError]; + NSMutableString *sqlHTML = [[NSMutableString alloc] init]; + NSString *truncatedString = [[NSString alloc] init]; if(readError != nil) { // cocoa tries to detect the encoding - sqlText = [NSString stringWithContentsOfFile:[myURL path] usedEncoding:&sqlEncoding error:&readError]; + sqlText = [[NSString alloc] initWithContentsOfFile:[myURL path] usedEncoding:&sqlEncoding error:&readError]; // fall back to latin1 if no sqlText couldn't read if(sqlText == nil) { sqlEncoding = NSISOLatin1StringEncoding; - sqlText = [NSString stringWithContentsOfFile:[myURL path] encoding:sqlEncoding error:&readError]; + sqlText = [[NSString alloc] initWithContentsOfFile:[myURL path] encoding:sqlEncoding error:&readError]; } } @@ -415,8 +415,12 @@ OSStatus GeneratePreviewForURL(void *thisInterface, QLPreviewRequestRef preview, // truncate large files since Finder blocks if([filesize unsignedLongValue] > kMaxSQLFileSize) { - sqlText = [sqlText substringToIndex:kMaxSQLFileSize-1]; - truncatedString = @"\n ✂ ..."; + NSString *truncatedSqlText = [[NSString alloc] initWithString:[sqlText substringToIndex:kMaxSQLFileSize-1]]; + [sqlText release]; + sqlText = [[NSString alloc] initWithString:truncatedSqlText]; + [truncatedSqlText release]; + [truncatedString release]; + truncatedString = [[NSString alloc] initWithString:@"\n ✂ ..."]; } NSRange textRange = NSMakeRange(0, [sqlText length]); @@ -467,6 +471,8 @@ OSStatus GeneratePreviewForURL(void *thisInterface, QLPreviewRequestRef preview, } [sqlHTML appendString:truncatedString]; + [sqlText release]; + [truncatedString release]; } html = [[NSMutableString alloc] initWithString:[NSString stringWithFormat:template, @@ -475,7 +481,8 @@ OSStatus GeneratePreviewForURL(void *thisInterface, QLPreviewRequestRef preview, sqlHTML ]]; - previewHeight = 495; + previewHeight = 495; + [sqlHTML release]; } else { |