aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrowanbeentje <rowan@beent.je>2010-11-15 01:25:38 +0000
committerrowanbeentje <rowan@beent.je>2010-11-15 01:25:38 +0000
commit9b9cb791f818faee0cd9af8e89ee4bd28a60ca24 (patch)
tree1828866c8463cef35b1601cb96e32b70cf30a92a
parenta3c99039fea0827520aa83e412ce98cf15e3e57d (diff)
downloadsequelpro-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
-rw-r--r--Resources/English.lproj/SPQLPluginConnectionBundleTemplate.html2
-rw-r--r--Resources/English.lproj/SPQLPluginSQLTemplate.html2
-rw-r--r--Source/GeneratePreviewForURL.m23
3 files changed, 17 insertions, 10 deletions
diff --git a/Resources/English.lproj/SPQLPluginConnectionBundleTemplate.html b/Resources/English.lproj/SPQLPluginConnectionBundleTemplate.html
index 02e5601d..c97fb4bc 100644
--- a/Resources/English.lproj/SPQLPluginConnectionBundleTemplate.html
+++ b/Resources/English.lproj/SPQLPluginConnectionBundleTemplate.html
@@ -14,7 +14,7 @@ body {
<table>
<tr>
<td valign="right">
-<img width="128" heigth="128" src="data:image/auto;base64,%@">
+<img width="128" height="128" src="data:image/auto;base64,%@">
</td>
<td>
<center>
diff --git a/Resources/English.lproj/SPQLPluginSQLTemplate.html b/Resources/English.lproj/SPQLPluginSQLTemplate.html
index d9f55c09..65ba2a3c 100644
--- a/Resources/English.lproj/SPQLPluginSQLTemplate.html
+++ b/Resources/English.lproj/SPQLPluginSQLTemplate.html
@@ -14,7 +14,7 @@ body {
<table>
<tr>
<td valign="right">
-<img width="128" heigth="128" src="data:image/auto;base64,%@">
+<img width="128" height="128" src="data:image/auto;base64,%@">
</td>
<td>
<center>
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 {