aboutsummaryrefslogtreecommitdiffstats
path: root/Source/GeneratePreviewForURL.m
diff options
context:
space:
mode:
authorrowanbeentje <rowan@beent.je>2010-11-16 01:29:48 +0000
committerrowanbeentje <rowan@beent.je>2010-11-16 01:29:48 +0000
commitb9c7ce03b7c2c121c599e36000b68996dd762f1c (patch)
treeb8a2c22a9cc918ab84ee623d109cc57d743184ae /Source/GeneratePreviewForURL.m
parent280f8dcc22b5556a4ed56ae77116c5177cbbfa2c (diff)
downloadsequelpro-b9c7ce03b7c2c121c599e36000b68996dd762f1c.tar.gz
sequelpro-b9c7ce03b7c2c121c599e36000b68996dd762f1c.tar.bz2
sequelpro-b9c7ce03b7c2c121c599e36000b68996dd762f1c.zip
- Attempt to improve QuickLook crashes by using a pool around the area causing crashes on certain files (lines 420,422)
- Improve SQL wrapping
Diffstat (limited to 'Source/GeneratePreviewForURL.m')
-rw-r--r--Source/GeneratePreviewForURL.m22
1 files changed, 20 insertions, 2 deletions
diff --git a/Source/GeneratePreviewForURL.m b/Source/GeneratePreviewForURL.m
index cef1e4ad..ba123c89 100644
--- a/Source/GeneratePreviewForURL.m
+++ b/Source/GeneratePreviewForURL.m
@@ -383,6 +383,8 @@ OSStatus GeneratePreviewForURL(void *thisInterface, QLPreviewRequestRef preview,
BOOL skipFontTag;
// now loop through all the tokens
+ NSUInteger poolCount = 0;
+ NSAutoreleasePool *loopPool = [[NSAutoreleasePool alloc] init];
while (token=yylex()){
skipFontTag = NO;
switch (token) {
@@ -424,20 +426,36 @@ OSStatus GeneratePreviewForURL(void *thisInterface, QLPreviewRequestRef preview,
if(truncatedString) [truncatedString release], sqlHTML = nil;
if(sqlText) [sqlText release], sqlHTML = nil;
if(pool) [pool release], pool = nil;
+ [loopPool release];
return noErr;
}
-
+ poolCount++;
+ if (poolCount > 1000) {
+ poolCount = 0;
+ [loopPool release];
+ loopPool = [[NSAutoreleasePool alloc] init];
+ }
}
+ [loopPool release];
+ [sqlHTML appendString:sqlText];
[sqlHTML appendString:truncatedString];
[sqlText release];
[truncatedString release];
}
+ // Wrap lines, and replace tabs with spaces
+ [sqlHTML replaceOccurrencesOfString:@"\n" withString:@"<br>" options:NSLiteralSearch range:NSMakeRange(0, [sqlHTML length])];
+ [sqlHTML replaceOccurrencesOfString:@"\t" withString:@"&nbsp;&nbsp;&nbsp;&nbsp;" options:NSLiteralSearch range:NSMakeRange(0, [sqlHTML length])];
+
+ // Improve soft wrapping my making more characters wrap points
+ [sqlHTML replaceOccurrencesOfString:@"," withString:@",&#8203;" options:NSLiteralSearch range:NSMakeRange(0, [sqlHTML length])];
+ [sqlHTML replaceOccurrencesOfString:@"/" withString:@"/&#8203;" options:NSLiteralSearch range:NSMakeRange(0, [sqlHTML length])];
+
html = [NSString stringWithFormat:template,
[NSString stringForByteSize:[[fileAttributes objectForKey:NSFileSize] longLongValue]],
- [[sqlHTML stringByReplacingOccurrencesOfString:@"\t" withString:@"&nbsp;&nbsp;&nbsp;&nbsp;"] stringByReplacingOccurrencesOfString:@"\n" withString:@"<br>"]
+ sqlHTML
];
previewHeight = 495;
[sqlHTML release];