diff --git a/ChangeLog b/ChangeLog index 6bcd3e295..9c6731470 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +2013-09-11 Frank Le Grand + + * Source\NSToolbar.m, + * Source\NSToolbarFrameworkPrivate.h, + * Source\NSWindow.h: Applied a fix/workaround to an issue where + a toolbar would cease from validating itself after its window + was closed and re-opened. The culprit is the logic in + GSValidationCenter which seems to assume that when a window has + closed it will be dealloc'd soon after, and does not consider + the possibility of the window getting brought back up. + 2013-09-04 Frank Le Grand * Source\NSBrowser.m: Fixed a bug where setting the path to "/" would diff --git a/Source/NSToolbar.m b/Source/NSToolbar.m index eda4f98ea..bce325f1e 100644 --- a/Source/NSToolbar.m +++ b/Source/NSToolbar.m @@ -1556,6 +1556,15 @@ static GSValidationCenter *vc = nil; [self validateVisibleItems]; } +- (void) _resetToolbarUpdates: (NSWindow *)window +{ + GSValidationCenter *validationCenter = [GSValidationCenter sharedValidationCenter]; + [validationCenter removeObserver: self window: nil]; + if (window != nil) + { + [validationCenter addObserver: self window: window]; + } +} @end diff --git a/Source/NSToolbarFrameworkPrivate.h b/Source/NSToolbarFrameworkPrivate.h index d19db026d..0bb887d71 100644 --- a/Source/NSToolbarFrameworkPrivate.h +++ b/Source/NSToolbarFrameworkPrivate.h @@ -35,6 +35,7 @@ #import "AppKit/NSToolbarItem.h" #import "GNUstepGUI/GSToolbarView.h" #import "GNUstepGUI/GSWindowDecorationView.h" +#import "AppKit/NSWindow.h" @interface GSToolbarView (GNUstepPrivate) - (void) _reload; @@ -114,6 +115,9 @@ - (NSArray *) _selectableItemIdentifiers; - (NSToolbarItem *) _toolbarItemForIdentifier: (NSString *)itemIdent willBeInsertedIntoToolbar: (BOOL)insert; +// Validation management +- (void) _resetToolbarUpdates: (NSWindow *)window; + @end @interface GSWindowDecorationView (ToolbarPrivate) @@ -126,4 +130,8 @@ - (NSMenuView*) removeMenuView; @end +@interface NSWindow (ToolbarPrivate) +- (void) _resetToolbarUpdates; +@end + #endif // _NSToolbarFrameworkPrivate_h_INCLUDE diff --git a/Source/NSWindow.m b/Source/NSWindow.m index 68052986a..7ebf066dc 100644 --- a/Source/NSWindow.m +++ b/Source/NSWindow.m @@ -1571,6 +1571,7 @@ titleWithRepresentedFilename(NSString *representedFilename) [_wv setInputState: GSTitleBarKey]; [GSServerForWindow(self) setinputfocus: _windowNum]; + [self _resetToolbarUpdates]; [self resetCursorRects]; [nc postNotificationName: NSWindowDidBecomeKeyNotification object: self]; NSDebugLLog(@"NSWindow", @"%@ is now key window", [self title]); @@ -5780,6 +5781,28 @@ current key view.
} @end +@implementation NSWindow (ToolbarPrivate) + +- (void) _resetToolbarUpdates +{ + /* 2013-09-11 Frank LeGrand: The toolbar validation process is + * architectured around the GSValidationCenter and its validation + * objects, which remove notification observers when the window + * closes (see NSToolbar.m). This architecture seems to assume + * that when a window closes it will be dealloc'd soon after, this + * is incorrect as someone else maybe retaining the window and later + * show it again. The purpose of this patch is to "turn on" again + * the validation process of the toolbar. + */ + if ([self toolbar]) + { + [[self toolbar] _resetToolbarUpdates:self]; + [nc postNotificationName: NSWindowDidUpdateNotification object: self]; + } +} + +@end + BOOL GSViewAcceptsDrag(NSView *v, id dragInfo) { NSPasteboard *pb = [dragInfo draggingPasteboard];