diff options
author | Max <post@wickenrode.com> | 2015-11-20 04:48:50 +0100 |
---|---|---|
committer | Max <post@wickenrode.com> | 2015-11-20 04:48:50 +0100 |
commit | 8b2376dc47110530eeab8f61334ff46e28256045 (patch) | |
tree | 83170e070debcff4731af78a6120df2a5dad4f39 /Source/SPExporter.m | |
parent | 5568af642c2fc738f175e0be4729fd3e1fe2263a (diff) | |
download | sequelpro-8b2376dc47110530eeab8f61334ff46e28256045.tar.gz sequelpro-8b2376dc47110530eeab8f61334ff46e28256045.tar.bz2 sequelpro-8b2376dc47110530eeab8f61334ff46e28256045.zip |
Reorder some code to remove duplicate code and make leaking a NSAutoreleasePool more difficult
Diffstat (limited to 'Source/SPExporter.m')
-rw-r--r-- | Source/SPExporter.m | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/Source/SPExporter.m b/Source/SPExporter.m index dfd5b4fa..adfe0545 100644 --- a/Source/SPExporter.m +++ b/Source/SPExporter.m @@ -67,11 +67,31 @@ } /** - * Override NSOperation's main() method. This method should never be called as all subclasses should override it. + * Override NSOperation's main() method. + * This method only creates an autoreleasepool and calls exportOperation */ - (void)main { - [NSException raise:NSInternalInconsistencyException format:@"Cannot call NSOperation's main() method in SPExpoter, must be overriden in a subclass. See SPExporter.h"]; + NSAutoreleasePool *pool = nil; + @try { + pool = [[NSAutoreleasePool alloc] init]; + + [self exportOperation]; + } + @catch(NSException *e) { + [[NSApp onMainThread] reportException:e]; // will be caught by FeedbackReporter + } + @finally { + [pool release]; + } +} + +/** + * This method should never be called as all subclasses should override it. + */ +- (void)exportOperation +{ + [NSException raise:NSInternalInconsistencyException format:@"Cannot call %s, must be overriden in a subclass. See SPExporter.h",__PRETTY_FUNCTION__]; } /** |