Permalink
Browse files

Change some method calls so the custom query view controller gets not…

…ified when the window is about to be closed and can stop a pending UI timer (#2775)
  • Loading branch information...
dmoagx committed May 10, 2017
1 parent 9d8926a commit 23c4d04e433f9eb21872edacc41173e34ec45ac2
Showing with 18 additions and 8 deletions.
  1. +3 −5 Source/SPCustomQuery.h
  2. +12 −0 Source/SPCustomQuery.m
  3. +3 −3 Source/SPDatabaseDocument.m
View
@@ -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;
View
@@ -70,6 +70,7 @@ @interface SPCustomQuery (PrivateAPI)
- (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 @@ - (void)awakeFromNib
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 @@ - (id)_resultDataItemAtRow:(NSInteger)row columnIndex:(NSUInteger)column preserv
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
@@ -6503,6 +6503,9 @@ - (void)_removePreferenceObservers
- (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 @@ - (void)dealloc
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);

0 comments on commit 23c4d04

Please sign in to comment.