diff options
author | Max <post@wickenrode.com> | 2018-01-17 20:21:07 +0100 |
---|---|---|
committer | Max <post@wickenrode.com> | 2018-01-17 20:21:07 +0100 |
commit | ef21bc5c3749756c21804d1592f3a3fe2faf7cab (patch) | |
tree | c52405f115536abcbd9861c40f740521d40bf6d8 /Source | |
parent | 74b18eee1821ec8ec5bd472cd5ddb80eb865c1ed (diff) | |
download | sequelpro-ef21bc5c3749756c21804d1592f3a3fe2faf7cab.tar.gz sequelpro-ef21bc5c3749756c21804d1592f3a3fe2faf7cab.tar.bz2 sequelpro-ef21bc5c3749756c21804d1592f3a3fe2faf7cab.zip |
Remove another 2 cases of very strange object notification behavior (code style)
Diffstat (limited to 'Source')
-rw-r--r-- | Source/SPConstants.h | 2 | ||||
-rw-r--r-- | Source/SPConstants.m | 2 | ||||
-rw-r--r-- | Source/SPContentFilterManager.h | 6 | ||||
-rw-r--r-- | Source/SPContentFilterManager.m | 5 | ||||
-rw-r--r-- | Source/SPCustomQuery.h | 1 | ||||
-rw-r--r-- | Source/SPCustomQuery.m | 13 | ||||
-rw-r--r-- | Source/SPQueryDocumentsController.m | 9 | ||||
-rw-r--r-- | Source/SPTableContent.m | 10 |
8 files changed, 28 insertions, 20 deletions
diff --git a/Source/SPConstants.h b/Source/SPConstants.h index 9316413d..13ec5933 100644 --- a/Source/SPConstants.h +++ b/Source/SPConstants.h @@ -452,6 +452,8 @@ extern NSString *SPSSHEnableMuxingPreference; extern NSString *SPSSHClientPath; extern NSString *SPSSLCipherListKey; extern NSString *SPQueryFavoritesHaveBeenUpdatedNotification; +extern NSString *SPHistoryItemsHaveBeenUpdatedNotification; +extern NSString *SPContentFiltersHaveBeenUpdatedNotification; // URLs extern NSString *SPDonationsURL; diff --git a/Source/SPConstants.m b/Source/SPConstants.m index 5e0cdd2e..60674007 100644 --- a/Source/SPConstants.m +++ b/Source/SPConstants.m @@ -249,6 +249,8 @@ NSString *SPSSHEnableMuxingPreference = @"SSHMultiplexingEnabled"; NSString *SPSSHClientPath = @"SSHClientPath"; NSString *SPSSLCipherListKey = @"SSLCipherList"; NSString *SPQueryFavoritesHaveBeenUpdatedNotification = @"QueryFavoritesHaveBeenUpdatedNotification"; +NSString *SPHistoryItemsHaveBeenUpdatedNotification = @"HistoryItemsHaveBeenUpdatedNotification"; +NSString *SPContentFiltersHaveBeenUpdatedNotification = @"ContentFiltersHaveBeenUpdatedNotification"; // URLs NSString *SPDonationsURL = @"http://www.sequelpro.com/donate/"; diff --git a/Source/SPContentFilterManager.h b/Source/SPContentFilterManager.h index 96e864ed..3c170bfc 100644 --- a/Source/SPContentFilterManager.h +++ b/Source/SPContentFilterManager.h @@ -31,12 +31,6 @@ @class SPDatabaseDocument; @class SPSplitView; -@interface NSObject (SPContentFilterManagerDelegate) - -- (void)contentFiltersHaveBeenUpdated:(id)manager; - -@end - @interface SPContentFilterManager : NSWindowController <NSOpenSavePanelDelegate> { #ifndef SP_CODA /* ivars */ diff --git a/Source/SPContentFilterManager.m b/Source/SPContentFilterManager.m index c8991943..9c340745 100644 --- a/Source/SPContentFilterManager.m +++ b/Source/SPContentFilterManager.m @@ -406,11 +406,8 @@ static NSString *SPExportFilterAction = @"SPExportFilter"; [cf release]; // Inform all opened documents to update the query favorites list - for(id doc in [SPAppDelegate orderedDocuments]) - if([[doc valueForKeyPath:@"tableContentInstance"] respondsToSelector:@selector(setCompareTypes:)]) - [[doc valueForKeyPath:@"tableContentInstance"] setCompareTypes:nil]; + [[NSNotificationCenter defaultCenter] postNotificationName:SPContentFiltersHaveBeenUpdatedNotification object:self]; #endif - } } diff --git a/Source/SPCustomQuery.h b/Source/SPCustomQuery.h index 7491b304..24695ba2 100644 --- a/Source/SPCustomQuery.h +++ b/Source/SPCustomQuery.h @@ -298,7 +298,6 @@ - (NSRange)currentQueryRange; - (NSString *)buildHistoryString; - (void)addHistoryEntry:(NSString *)entryString; -- (void)historyItemsHaveBeenUpdated:(id)manager; - (void)processFieldEditorResult:(id)data contextInfo:(NSDictionary*)contextInfo; @end diff --git a/Source/SPCustomQuery.m b/Source/SPCustomQuery.m index abd4c2a8..374f31db 100644 --- a/Source/SPCustomQuery.m +++ b/Source/SPCustomQuery.m @@ -72,6 +72,7 @@ + (NSString *)linkToHelpTopic:(NSString *)aTopic; - (void)documentWillClose:(NSNotification *)notification; - (void)queryFavoritesHaveBeenUpdated:(NSNotification *)notification; +- (void)historyItemsHaveBeenUpdated:(NSNotification *)notification; @end @@ -1621,7 +1622,7 @@ #ifndef SP_CODA if ( [[SPQueryController sharedQueryController] historyForFileURL:[tableDocumentInstance fileURL]] ) - [self performSelectorOnMainThread:@selector(historyItemsHaveBeenUpdated:) withObject:self waitUntilDone:YES]; + [self performSelectorOnMainThread:@selector(historyItemsHaveBeenUpdated:) withObject:nil waitUntilDone:YES]; // Populate query favorites [self queryFavoritesHaveBeenUpdated:nil]; @@ -3369,8 +3370,12 @@ /** * Rebuild history popup menu. + * + * Warning: notification may be nil if invoked directly from within this class. + * + * MUST BE CALLED ON THE UI THREAD! */ -- (void)historyItemsHaveBeenUpdated:(id)manager +- (void)historyItemsHaveBeenUpdated:(NSNotification *)notification { // Abort if the connection has been closed already - sign of a closed window if (![mySQLConnection isConnected]) return; @@ -3997,6 +4002,10 @@ selector:@selector(queryFavoritesHaveBeenUpdated:) name:SPQueryFavoritesHaveBeenUpdatedNotification object:nil]; + [[NSNotificationCenter defaultCenter] addObserver:self + selector:@selector(historyItemsHaveBeenUpdated:) + name:SPHistoryItemsHaveBeenUpdatedNotification + object:nil]; #ifndef SP_CODA [prefs addObserver:self forKeyPath:SPGlobalResultTableFont options:NSKeyValueObservingOptionNew context:NULL]; diff --git a/Source/SPQueryDocumentsController.m b/Source/SPQueryDocumentsController.m index a9602b61..d3081338 100644 --- a/Source/SPQueryDocumentsController.m +++ b/Source/SPQueryDocumentsController.m @@ -204,13 +204,8 @@ } // Inform all opened documents to update the history list - for (id doc in [SPAppDelegate orderedDocuments]) - { - if([[doc valueForKeyPath:@"customQueryInstance"] respondsToSelector:@selector(historyItemsHaveBeenUpdated:)]) { - [[doc valueForKeyPath:@"customQueryInstance"] performSelectorOnMainThread:@selector(historyItemsHaveBeenUpdated:) withObject:self waitUntilDone:NO]; - } - } - + [[NSNotificationCenter defaultCenter] postNotificationOnMainThreadWithName:SPHistoryItemsHaveBeenUpdatedNotification object:self]; + // User did choose to clear the global history list if (![fileURL isFileURL] && ![historyArray count]) { [prefs setObject:historyArray forKey:SPQueryHistory]; diff --git a/Source/SPTableContent.m b/Source/SPTableContent.m index fda32232..27207fca 100644 --- a/Source/SPTableContent.m +++ b/Source/SPTableContent.m @@ -83,6 +83,7 @@ static NSString *SPTableFilterSetDefaultOperator = @"SPTableFilterSetDefaultOper - (BOOL)cancelRowEditing; - (void)documentWillClose:(NSNotification *)notification; +- (void)contentFiltersHaveBeenUpdated:(NSNotification *)notification; @end @@ -305,6 +306,10 @@ static NSString *SPTableFilterSetDefaultOperator = @"SPTableFilterSetDefaultOper selector:@selector(documentWillClose:) name:SPDocumentWillCloseNotification object:tableDocumentInstance]; + [[NSNotificationCenter defaultCenter] addObserver:self + selector:@selector(contentFiltersHaveBeenUpdated:) + name:SPContentFiltersHaveBeenUpdatedNotification + object:nil]; } #pragma mark - @@ -2595,6 +2600,11 @@ static NSString *SPTableFilterSetDefaultOperator = @"SPTableFilterSetDefaultOper [linkPool drain]; } +- (void)contentFiltersHaveBeenUpdated:(NSNotification *)notification +{ + [self setCompareTypes:nil]; +} + /** * Sets the compare types for the filter and the appropriate formatter for the textField */ |