aboutsummaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorMax <post@wickenrode.com>2017-05-10 23:59:27 +0200
committerMax <post@wickenrode.com>2017-05-10 23:59:27 +0200
commit23c4d04e433f9eb21872edacc41173e34ec45ac2 (patch)
treeba98c45b98451bb768652683a5aa1dcaa6aa72b9 /Source
parent9d8926a9da1b2325a2139c5e23146f03ccc17003 (diff)
downloadsequelpro-23c4d04e433f9eb21872edacc41173e34ec45ac2.tar.gz
sequelpro-23c4d04e433f9eb21872edacc41173e34ec45ac2.tar.bz2
sequelpro-23c4d04e433f9eb21872edacc41173e34ec45ac2.zip
Change some method calls so the custom query view controller gets notified when the window is about to be closed and can stop a pending UI timer (#2775)
Diffstat (limited to 'Source')
-rw-r--r--Source/SPCustomQuery.h8
-rw-r--r--Source/SPCustomQuery.m12
-rw-r--r--Source/SPDatabaseDocument.m6
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);