Multiple NSWindowController/document mystery
Multiple NSWindowController/document mystery
- Subject: Multiple NSWindowController/document mystery
- From: "Doug Knowles" <email@hidden>
- Date: Sun, 15 Jul 2007 11:12:52 -0400
I have an application that implements a few different NSWindowController
types for document windows, and can have one or more of these
windows/controllers open at a time. I've been tracking down a problem
wherein my document object (and at least one window controller) remain
instantiated after I close the document by closing the last window, which
only happens with one particular class of window controller.
I've set up two test cases with a single window of a different type is open,
and the document is "dirty". In both cases, I close the single open window,
and I am prompted to save the (changed) document before closing. What
happens after I choose "Don't Save" differs between window controller types,
as denoted by the stack traces at the end of this message.
In the first case (correct behavior, AFAIK), [NSWindow close] invokes my
document object's removeWindowController, then close, then the window
controller's windowWillClose delegate callback.
In the second case, there is never a call to the document's
removeWindowController or close methods; it goes straight to
windowWillClose, leaving the document object (and the window controller)
closed but still instantiated. A subsequent Quit crashes, apparently
because the application is trying to tear down the already closed document
and/or window.
Any ideas as to why I might be seeing this inconsistent behavior on closing
windows of different types? Both window controllers have
shouldCloseDocument set to NO, but I think that's moot because the
application is correctly trying to close the document (as proven by the save
warning) when the last open window is closed.
Any thoughts would be greatly appreciated.
Doug K
Case
1:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
Closing category view (1):
#0 0x00007a8e in -[SLNDocument removeWindowController:] at SLNDocument.m
:1064
#1 0x920ead2e in -[NSWindowController _windowWillClose:]
#2 0x90a6e17b in _nsnote_callback
#3 0x902cf3e6 in __CFXNotificationPost
#4 0x902c6bd1 in _CFXNotificationPostNotification
#5 0x90a66724 in -[NSNotificationCenter
postNotificationName:object:userInfo:]
#6 0x90a6d6c9 in -[NSNotificationCenter postNotificationName:object:]
#7 0x920eab32 in -[NSWindow _close]
#8 0x920eaaa4 in -[NSWindow close]
#9 0x92458e05 in -[NSDocument
_closeAlertSheet:wasPresentedWithResult:inContext:]
#10 0x9231ffea in -[NSAlert didEndSheet:returnCode:contextInfo:]
#11 0x922417ee in -[NSApplication endSheet:returnCode:]
#12 0x92241671 in -[NSAlert buttonPressed:]
#13 0x921b7d88 in -[NSApplication sendAction:to:from:]
#14 0x921b7ce1 in -[NSControl sendAction:to:]
#15 0x921b9e91 in -[NSCell _sendActionFrom:]
#16 0x921cc671 in -[NSCell trackMouse:inRect:ofView:untilMouseUp:]
#17 0x921ea25d in -[NSButtonCell trackMouse:inRect:ofView:untilMouseUp:]
#18 0x921e9b0d in -[NSControl mouseDown:]
#19 0x921a73af in -[NSWindow sendEvent:]
#20 0x92199350 in -[NSApplication sendEvent:]
#21 0x920c3dfe in -[NSApplication run]
#22 0x920b7d2f in NSApplicationMain
#23 0x0000b3a2 in main at main.m:13
(3)
#0 0x00007b93 in -[SLNDocument close] at SLNDocument.m:1076
#1 0x90a6e17b in _nsnote_callback
#2 0x902cf3e6 in __CFXNotificationPost
#3 0x902c6bd1 in _CFXNotificationPostNotification
#4 0x90a66724 in -[NSNotificationCenter
postNotificationName:object:userInfo:]
#5 0x90a6d6c9 in -[NSNotificationCenter postNotificationName:object:]
#6 0x920eab32 in -[NSWindow _close]
#7 0x920eaaa4 in -[NSWindow close]
#8 0x92458e05 in -[NSDocument
_closeAlertSheet:wasPresentedWithResult:inContext:]
#9 0x9231ffea in -[NSAlert didEndSheet:returnCode:contextInfo:]
#10 0x922417ee in -[NSApplication endSheet:returnCode:]
#11 0x92241671 in -[NSAlert buttonPressed:]
#12 0x921b7d88 in -[NSApplication sendAction:to:from:]
#13 0x921b7ce1 in -[NSControl sendAction:to:]
#14 0x921b9e91 in -[NSCell _sendActionFrom:]
#15 0x921cc671 in -[NSCell trackMouse:inRect:ofView:untilMouseUp:]
#16 0x921ea25d in -[NSButtonCell trackMouse:inRect:ofView:untilMouseUp:]
#17 0x921e9b0d in -[NSControl mouseDown:]
#18 0x921a73af in -[NSWindow sendEvent:]
#19 0x92199350 in -[NSApplication sendEvent:]
#20 0x920c3dfe in -[NSApplication run]
#21 0x920b7d2f in NSApplicationMain
#22 0x0000b3a2 in main at main.m:13
(4)
#0 0x0001d928 in -[SLNWindowController windowWillClose:] at
SLNWindowController.m:193
#1 0x90a6e17b in _nsnote_callback
#2 0x902cf3e6 in __CFXNotificationPost
#3 0x902c6bd1 in _CFXNotificationPostNotification
#4 0x90a66724 in -[NSNotificationCenter
postNotificationName:object:userInfo:]
#5 0x90a6d6c9 in -[NSNotificationCenter postNotificationName:object:]
#6 0x920eab32 in -[NSWindow _close]
#7 0x920eaaa4 in -[NSWindow close]
#8 0x92458e05 in -[NSDocument
_closeAlertSheet:wasPresentedWithResult:inContext:]
#9 0x9231ffea in -[NSAlert didEndSheet:returnCode:contextInfo:]
#10 0x922417ee in -[NSApplication endSheet:returnCode:]
#11 0x92241671 in -[NSAlert buttonPressed:]
#12 0x921b7d88 in -[NSApplication sendAction:to:from:]
#13 0x921b7ce1 in -[NSControl sendAction:to:]
#14 0x921b9e91 in -[NSCell _sendActionFrom:]
#15 0x921cc671 in -[NSCell trackMouse:inRect:ofView:untilMouseUp:]
#16 0x921ea25d in -[NSButtonCell trackMouse:inRect:ofView:untilMouseUp:]
#17 0x921e9b0d in -[NSControl mouseDown:]
#18 0x921a73af in -[NSWindow sendEvent:]
#19 0x92199350 in -[NSApplication sendEvent:]
#20 0x920c3dfe in -[NSApplication run]
#21 0x920b7d2f in NSApplicationMain
#22 0x0000b3a2 in main at main.m:13
Case
2:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
Closing list view (1):
#0 0x0001d928 in -[SLNWindowController windowWillClose:] at
SLNWindowController.m:193
#1 0x90a6e17b in _nsnote_callback
#2 0x902cf3e6 in __CFXNotificationPost
#3 0x902c6bd1 in _CFXNotificationPostNotification
#4 0x90a66724 in -[NSNotificationCenter
postNotificationName:object:userInfo:]
#5 0x90a6d6c9 in -[NSNotificationCenter postNotificationName:object:]
#6 0x920eab32 in -[NSWindow _close]
#7 0x920eaaa4 in -[NSWindow close]
#8 0x92458e05 in -[NSDocument
_closeAlertSheet:wasPresentedWithResult:inContext:]
#9 0x9231ffea in -[NSAlert didEndSheet:returnCode:contextInfo:]
#10 0x922417ee in -[NSApplication endSheet:returnCode:]
#11 0x92241671 in -[NSAlert buttonPressed:]
#12 0x921b7d88 in -[NSApplication sendAction:to:from:]
#13 0x921b7ce1 in -[NSControl sendAction:to:]
#14 0x921b9e91 in -[NSCell _sendActionFrom:]
#15 0x921b994c in -[NSButtonCell performClick:]
#16 0x921b9690 in -[NSButton performKeyEquivalent:]
#17 0x921b8717 in -[NSView performKeyEquivalent:]
#18 0x92264fde in -[NSApplication _handleKeyEquivalent:]
#19 0x92198d87 in -[NSApplication sendEvent:]
#20 0x920c3dfe in -[NSApplication run]
#21 0x920b7d2f in NSApplicationMain
#22 0x0000b3a2 in main at main.m:13
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden