diff options
Diffstat (limited to 'Source')
-rw-r--r-- | Source/SPCustomQuery.h | 8 | ||||
-rw-r--r-- | Source/SPCustomQuery.m | 12 | ||||
-rw-r--r-- | Source/SPDatabaseDocument.m | 6 |
3 files changed, 18 insertions, 8 deletions
diff --git a/Source/SPCustomQuery.h b/Source/SPCustomQuery.h index fe31be6d..7491b304 100644 --- a/Source/SPCustomQuery.h +++ b/Source/SPCustomQuery.h @@ -57,16 +57,14 @@ @class SPMySQLConnection; @class SPMySQLStreamingResultStore; @class SPTextView; - -#ifdef SP_CODA @class SPDatabaseDocument; @class SPTablesList; -#endif + @interface SPCustomQuery : NSObject <NSTableViewDataSource, NSWindowDelegate, NSTableViewDelegate, SPDatabaseContentViewDelegate> { - IBOutlet id tableDocumentInstance; - IBOutlet id tablesListInstance; + IBOutlet SPDatabaseDocument *tableDocumentInstance; + IBOutlet SPTablesList *tablesListInstance; #ifndef SP_CODA IBOutlet id queryFavoritesButton; diff --git a/Source/SPCustomQuery.m b/Source/SPCustomQuery.m index 3cbd6a4d..c14c275d 100644 --- a/Source/SPCustomQuery.m +++ b/Source/SPCustomQuery.m @@ -70,6 +70,7 @@ - (id)_resultDataItemAtRow:(NSInteger)row columnIndex:(NSUInteger)column preserveNULLs:(BOOL)preserveNULLs asPreview:(BOOL)asPreview; + (NSString *)linkToHelpTopic:(NSString *)aTopic; +- (void)documentWillClose:(NSNotification *)notification; @end @@ -3986,6 +3987,10 @@ selector:@selector(endDocumentTaskForTab:) name:SPDocumentTaskEndNotification object:tableDocumentInstance]; + [[NSNotificationCenter defaultCenter] addObserver:self + selector:@selector(documentWillClose:) + name:SPDocumentWillCloseNotification + object:tableDocumentInstance]; #ifndef SP_CODA [prefs addObserver:self forKeyPath:SPGlobalResultTableFont options:NSKeyValueObservingOptionNew context:NULL]; @@ -4046,6 +4051,13 @@ return value; } +//this method is called right before the UI objects are deallocated +- (void)documentWillClose:(NSNotification *)notification +{ + // if a result load is in progress we must stop the timer or it may try to call invalid IBOutlets + [self clearQueryLoadTimer]; +} + #pragma mark - - (void)dealloc diff --git a/Source/SPDatabaseDocument.m b/Source/SPDatabaseDocument.m index d19b3f4c..2581967c 100644 --- a/Source/SPDatabaseDocument.m +++ b/Source/SPDatabaseDocument.m @@ -6503,6 +6503,9 @@ static int64_t SPDatabaseDocumentInstanceCounter = 0; - (void)dealloc { NSAssert([NSThread isMainThread], @"Calling %s from a background thread is not supported!", __func__); + + // Tell listeners that this database document is being closed - fixes retain cycles and allows cleanup + [[NSNotificationCenter defaultCenter] postNotificationName:SPDocumentWillCloseNotification object:self]; // Unregister observers [self _removePreferenceObservers]; @@ -6517,9 +6520,6 @@ static int64_t SPDatabaseDocumentInstanceCounter = 0; for (id retainedObject in nibObjectsToRelease) [retainedObject release]; SPClear(nibObjectsToRelease); - - // Tell listeners that this database document is being closed - fixes retain cycles and allows cleanup - [[NSNotificationCenter defaultCenter] postNotificationName:SPDocumentWillCloseNotification object:self]; SPClear(databaseStructureRetrieval); |