Skip to content

Commit

Permalink
Remove another 2 cases of very strange object notification behavior (…
Browse files Browse the repository at this point in the history
…code style)
  • Loading branch information
dmoagx committed Jan 17, 2018
1 parent 74b18ee commit ef21bc5
Show file tree
Hide file tree
Showing 8 changed files with 28 additions and 20 deletions.
2 changes: 2 additions & 0 deletions Source/SPConstants.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 2 additions & 0 deletions Source/SPConstants.m
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,8 @@
NSString *SPSSHClientPath = @"SSHClientPath";
NSString *SPSSLCipherListKey = @"SSLCipherList";
NSString *SPQueryFavoritesHaveBeenUpdatedNotification = @"QueryFavoritesHaveBeenUpdatedNotification";
NSString *SPHistoryItemsHaveBeenUpdatedNotification = @"HistoryItemsHaveBeenUpdatedNotification";
NSString *SPContentFiltersHaveBeenUpdatedNotification = @"ContentFiltersHaveBeenUpdatedNotification";

// URLs
NSString *SPDonationsURL = @"http://www.sequelpro.com/donate/";
Expand Down
6 changes: 0 additions & 6 deletions Source/SPContentFilterManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,6 @@
@class SPDatabaseDocument;
@class SPSplitView;

@interface NSObject (SPContentFilterManagerDelegate)

- (void)contentFiltersHaveBeenUpdated:(id)manager;

@end

@interface SPContentFilterManager : NSWindowController <NSOpenSavePanelDelegate>
{
#ifndef SP_CODA /* ivars */
Expand Down
5 changes: 1 addition & 4 deletions Source/SPContentFilterManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -406,11 +406,8 @@ - (IBAction)closeContentFilterManagerSheet:(id)sender
[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

}
}

Expand Down
1 change: 0 additions & 1 deletion Source/SPCustomQuery.h
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,6 @@
- (NSRange)currentQueryRange;
- (NSString *)buildHistoryString;
- (void)addHistoryEntry:(NSString *)entryString;
- (void)historyItemsHaveBeenUpdated:(id)manager;
- (void)processFieldEditorResult:(id)data contextInfo:(NSDictionary*)contextInfo;

@end
13 changes: 11 additions & 2 deletions Source/SPCustomQuery.m
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ - (id)_resultDataItemAtRow:(NSInteger)row columnIndex:(NSUInteger)column preserv
+ (NSString *)linkToHelpTopic:(NSString *)aTopic;
- (void)documentWillClose:(NSNotification *)notification;
- (void)queryFavoritesHaveBeenUpdated:(NSNotification *)notification;
- (void)historyItemsHaveBeenUpdated:(NSNotification *)notification;

@end

Expand Down Expand Up @@ -1621,7 +1622,7 @@ - (void)setConnection:(SPMySQLConnection *)theConnection

#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];
Expand Down Expand Up @@ -3369,8 +3370,12 @@ - (BOOL)windowShouldClose:(id)sender

/**
* 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;
Expand Down Expand Up @@ -3997,6 +4002,10 @@ - (void)awakeFromNib
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];
Expand Down
9 changes: 2 additions & 7 deletions Source/SPQueryDocumentsController.m
Original file line number Diff line number Diff line change
Expand Up @@ -204,13 +204,8 @@ - (void)replaceHistoryByArray:(NSArray *)historyArray forFileURL:(NSURL *)fileUR
}

// 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];
Expand Down
10 changes: 10 additions & 0 deletions Source/SPTableContent.m
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ @interface SPTableContent ()

- (BOOL)cancelRowEditing;
- (void)documentWillClose:(NSNotification *)notification;
- (void)contentFiltersHaveBeenUpdated:(NSNotification *)notification;

@end

Expand Down Expand Up @@ -305,6 +306,10 @@ - (void)awakeFromNib
selector:@selector(documentWillClose:)
name:SPDocumentWillCloseNotification
object:tableDocumentInstance];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(contentFiltersHaveBeenUpdated:)
name:SPContentFiltersHaveBeenUpdatedNotification
object:nil];
}

#pragma mark -
Expand Down Expand Up @@ -2595,6 +2600,11 @@ - (void)clickLinkArrowTask:(SPTextAndLinkCell *)theArrowCell
[linkPool drain];
}

- (void)contentFiltersHaveBeenUpdated:(NSNotification *)notification
{
[self setCompareTypes:nil];
}

/**
* Sets the compare types for the filter and the appropriate formatter for the textField
*/
Expand Down

0 comments on commit ef21bc5

Please sign in to comment.