aboutsummaryrefslogtreecommitdiff
path: root/AppKit/GTMWindowSheetController.m
diff options
context:
space:
mode:
authorGravatar gtm.daemon <gtm.daemon@7dc7ac4e-7543-0410-b95c-c1676fc8e2a3>2010-11-08 21:39:10 +0000
committerGravatar gtm.daemon <gtm.daemon@7dc7ac4e-7543-0410-b95c-c1676fc8e2a3>2010-11-08 21:39:10 +0000
commit144526b58bb1d6866f8c427a63036c31f8e1d8a9 (patch)
treeb98665ac3f36bd957783bb36741905ea3aaab0cf /AppKit/GTMWindowSheetController.m
parent2e0d716e8fe85d33f1b68e2830d2f33c79dd8289 (diff)
[Author: avi]
Allow adding a new sheet in a sheet's closing callback in GTMWindowSheetController. GTMWindowSheetController does not completely remove a sheet until after the callback has been invoked. This causes an assert to trigger if another sheet is launched in the callback, which is inconsistent with normal Cocoa sheets. Switch the order of the two operations and add a unit test. This affects http://crbug.com/56948 . Patch by davidben@chromium.org . R=dmaclach DELTA=112 (106 added, 5 deleted, 1 changed)
Diffstat (limited to 'AppKit/GTMWindowSheetController.m')
-rw-r--r--AppKit/GTMWindowSheetController.m16
1 files changed, 10 insertions, 6 deletions
diff --git a/AppKit/GTMWindowSheetController.m b/AppKit/GTMWindowSheetController.m
index f7c87a3..60cd611 100644
--- a/AppKit/GTMWindowSheetController.m
+++ b/AppKit/GTMWindowSheetController.m
@@ -523,7 +523,10 @@ willPositionSheet:(NSWindow*)sheet
contextInfo:(void*)contextInfo
arg1Size:(int)size {
NSValue* viewKey = [NSValue valueWithNonretainedObject:(NSView*)contextInfo];
- GTMWSCSheetInfo* sheetInfo = [sheets_ objectForKey:viewKey];
+ // Retain a reference to sheetInfo so we can use it after it is
+ // removed from sheets_.
+ GTMWSCSheetInfo* sheetInfo =
+ [[[sheets_ objectForKey:viewKey] retain] autorelease];
_GTMDevAssert(sheetInfo, @"Could not find information about the sheet that "
@"just ended");
_GTMDevAssert(size == 8 || size == 32 || size == 64,
@@ -537,6 +540,12 @@ willPositionSheet:(NSWindow*)sheet
name:NSViewFrameDidChangeNotification
object:contextInfo];
+ // We clean up the sheet before calling the callback so that the
+ // callback is free to fire another sheet if it so desires.
+ [window_ removeChildWindow:sheetInfo->overlayWindow_];
+ [sheetInfo->overlayWindow_ release];
+ [sheets_ removeObjectForKey:viewKey];
+
NSInvocation* invocation =
[NSInvocation invocationWithMethodSignature:
[sheetInfo->modalDelegate_
@@ -555,11 +564,6 @@ willPositionSheet:(NSWindow*)sheet
}
[invocation setArgument:&sheetInfo->contextInfo_ atIndex:4];
[invocation invokeWithTarget:sheetInfo->modalDelegate_];
-
- [window_ removeChildWindow:sheetInfo->overlayWindow_];
- [sheetInfo->overlayWindow_ release];
-
- [sheets_ removeObjectForKey:viewKey];
}
- (void)systemRequestsVisibilityForWindow:(NSWindow*)window {