Skip to content

Commit ef21bc5

Browse files
committed
Remove another 2 cases of very strange object notification behavior (code style)
1 parent 74b18ee commit ef21bc5

File tree

8 files changed

+28
-20
lines changed

8 files changed

+28
-20
lines changed

Source/SPConstants.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -452,6 +452,8 @@ extern NSString *SPSSHEnableMuxingPreference;
452452
extern NSString *SPSSHClientPath;
453453
extern NSString *SPSSLCipherListKey;
454454
extern NSString *SPQueryFavoritesHaveBeenUpdatedNotification;
455+
extern NSString *SPHistoryItemsHaveBeenUpdatedNotification;
456+
extern NSString *SPContentFiltersHaveBeenUpdatedNotification;
455457

456458
// URLs
457459
extern NSString *SPDonationsURL;

Source/SPConstants.m

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,8 @@
249249
NSString *SPSSHClientPath = @"SSHClientPath";
250250
NSString *SPSSLCipherListKey = @"SSLCipherList";
251251
NSString *SPQueryFavoritesHaveBeenUpdatedNotification = @"QueryFavoritesHaveBeenUpdatedNotification";
252+
NSString *SPHistoryItemsHaveBeenUpdatedNotification = @"HistoryItemsHaveBeenUpdatedNotification";
253+
NSString *SPContentFiltersHaveBeenUpdatedNotification = @"ContentFiltersHaveBeenUpdatedNotification";
252254

253255
// URLs
254256
NSString *SPDonationsURL = @"http://www.sequelpro.com/donate/";

Source/SPContentFilterManager.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,6 @@
3131
@class SPDatabaseDocument;
3232
@class SPSplitView;
3333

34-
@interface NSObject (SPContentFilterManagerDelegate)
35-
36-
- (void)contentFiltersHaveBeenUpdated:(id)manager;
37-
38-
@end
39-
4034
@interface SPContentFilterManager : NSWindowController <NSOpenSavePanelDelegate>
4135
{
4236
#ifndef SP_CODA /* ivars */

Source/SPContentFilterManager.m

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -406,11 +406,8 @@ - (IBAction)closeContentFilterManagerSheet:(id)sender
406406
[cf release];
407407

408408
// Inform all opened documents to update the query favorites list
409-
for(id doc in [SPAppDelegate orderedDocuments])
410-
if([[doc valueForKeyPath:@"tableContentInstance"] respondsToSelector:@selector(setCompareTypes:)])
411-
[[doc valueForKeyPath:@"tableContentInstance"] setCompareTypes:nil];
409+
[[NSNotificationCenter defaultCenter] postNotificationName:SPContentFiltersHaveBeenUpdatedNotification object:self];
412410
#endif
413-
414411
}
415412
}
416413

Source/SPCustomQuery.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,6 @@
298298
- (NSRange)currentQueryRange;
299299
- (NSString *)buildHistoryString;
300300
- (void)addHistoryEntry:(NSString *)entryString;
301-
- (void)historyItemsHaveBeenUpdated:(id)manager;
302301
- (void)processFieldEditorResult:(id)data contextInfo:(NSDictionary*)contextInfo;
303302

304303
@end

Source/SPCustomQuery.m

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ - (id)_resultDataItemAtRow:(NSInteger)row columnIndex:(NSUInteger)column preserv
7272
+ (NSString *)linkToHelpTopic:(NSString *)aTopic;
7373
- (void)documentWillClose:(NSNotification *)notification;
7474
- (void)queryFavoritesHaveBeenUpdated:(NSNotification *)notification;
75+
- (void)historyItemsHaveBeenUpdated:(NSNotification *)notification;
7576

7677
@end
7778

@@ -1621,7 +1622,7 @@ - (void)setConnection:(SPMySQLConnection *)theConnection
16211622

16221623
#ifndef SP_CODA
16231624
if ( [[SPQueryController sharedQueryController] historyForFileURL:[tableDocumentInstance fileURL]] )
1624-
[self performSelectorOnMainThread:@selector(historyItemsHaveBeenUpdated:) withObject:self waitUntilDone:YES];
1625+
[self performSelectorOnMainThread:@selector(historyItemsHaveBeenUpdated:) withObject:nil waitUntilDone:YES];
16251626

16261627
// Populate query favorites
16271628
[self queryFavoritesHaveBeenUpdated:nil];
@@ -3369,8 +3370,12 @@ - (BOOL)windowShouldClose:(id)sender
33693370

33703371
/**
33713372
* Rebuild history popup menu.
3373+
*
3374+
* Warning: notification may be nil if invoked directly from within this class.
3375+
*
3376+
* MUST BE CALLED ON THE UI THREAD!
33723377
*/
3373-
- (void)historyItemsHaveBeenUpdated:(id)manager
3378+
- (void)historyItemsHaveBeenUpdated:(NSNotification *)notification
33743379
{
33753380
// Abort if the connection has been closed already - sign of a closed window
33763381
if (![mySQLConnection isConnected]) return;
@@ -3997,6 +4002,10 @@ - (void)awakeFromNib
39974002
selector:@selector(queryFavoritesHaveBeenUpdated:)
39984003
name:SPQueryFavoritesHaveBeenUpdatedNotification
39994004
object:nil];
4005+
[[NSNotificationCenter defaultCenter] addObserver:self
4006+
selector:@selector(historyItemsHaveBeenUpdated:)
4007+
name:SPHistoryItemsHaveBeenUpdatedNotification
4008+
object:nil];
40004009

40014010
#ifndef SP_CODA
40024011
[prefs addObserver:self forKeyPath:SPGlobalResultTableFont options:NSKeyValueObservingOptionNew context:NULL];

Source/SPQueryDocumentsController.m

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -204,13 +204,8 @@ - (void)replaceHistoryByArray:(NSArray *)historyArray forFileURL:(NSURL *)fileUR
204204
}
205205

206206
// Inform all opened documents to update the history list
207-
for (id doc in [SPAppDelegate orderedDocuments])
208-
{
209-
if([[doc valueForKeyPath:@"customQueryInstance"] respondsToSelector:@selector(historyItemsHaveBeenUpdated:)]) {
210-
[[doc valueForKeyPath:@"customQueryInstance"] performSelectorOnMainThread:@selector(historyItemsHaveBeenUpdated:) withObject:self waitUntilDone:NO];
211-
}
212-
}
213-
207+
[[NSNotificationCenter defaultCenter] postNotificationOnMainThreadWithName:SPHistoryItemsHaveBeenUpdatedNotification object:self];
208+
214209
// User did choose to clear the global history list
215210
if (![fileURL isFileURL] && ![historyArray count]) {
216211
[prefs setObject:historyArray forKey:SPQueryHistory];

Source/SPTableContent.m

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ @interface SPTableContent ()
8383

8484
- (BOOL)cancelRowEditing;
8585
- (void)documentWillClose:(NSNotification *)notification;
86+
- (void)contentFiltersHaveBeenUpdated:(NSNotification *)notification;
8687

8788
@end
8889

@@ -305,6 +306,10 @@ - (void)awakeFromNib
305306
selector:@selector(documentWillClose:)
306307
name:SPDocumentWillCloseNotification
307308
object:tableDocumentInstance];
309+
[[NSNotificationCenter defaultCenter] addObserver:self
310+
selector:@selector(contentFiltersHaveBeenUpdated:)
311+
name:SPContentFiltersHaveBeenUpdatedNotification
312+
object:nil];
308313
}
309314

310315
#pragma mark -
@@ -2595,6 +2600,11 @@ - (void)clickLinkArrowTask:(SPTextAndLinkCell *)theArrowCell
25952600
[linkPool drain];
25962601
}
25972602

2603+
- (void)contentFiltersHaveBeenUpdated:(NSNotification *)notification
2604+
{
2605+
[self setCompareTypes:nil];
2606+
}
2607+
25982608
/**
25992609
* Sets the compare types for the filter and the appropriate formatter for the textField
26002610
*/

0 commit comments

Comments
 (0)