Modal Window Failure on 10.10.2
Modal Window Failure on 10.10.2
- Subject: Modal Window Failure on 10.10.2
- From: Charles Jenkins <email@hidden>
- Date: Sun, 08 Feb 2015 18:44:10 -0500
I updated my OS yesterday, and now my modal window doesn’t work (which probably means I’m doing it wrong and just got lucky before).
I created the window by asking XCode to create a subclass of NSWindowController and making sure the “also create xib” checkbox was checked. Then I designed the UI, outlets and actions, and wrote the short bit of code that’s supposed to call up the window in my document controller.
The window’s name is OpenXmlExportSettings, and the code that displays it looks like this:
if ( self.openXmlExportSettings == nil ) {
self.openXmlExportSettings = [[OpenXmlExportSettings alloc] init];
}
OpenXmlExportSettings* settings = self.openXmlExportSettings;
NSInteger result = [NSApp runModalForWindow:settings.window];
if ( result == NSModalResponseAbort ) {
return;
}
// After this we do useful things with the selected settings...
I haven’t made any changes to this since last week when it worked, but like I said, that doesn’t mean I’m sure this was good code to begin with.
Now when runModalForWindow: is called, I get this crash before the window ever appears:
2015-02-08 16:24:04.155 MyApp[2989:720882] *** Assertion failure in -[NSApplication _commonBeginModalSessionForWindow:relativeToWindow:modalDelegate:didEndSelector:contextInfo:], /SourceCache/AppKit/AppKit-1344.72/AppKit.subproj/NSApplication.m:4048
2015-02-08 16:24:04.159 MyApp[2989:720882] An uncaught exception was raised
2015-02-08 16:24:04.159 MyApp[2989:720882] Modal session requires modal window
2015-02-08 16:24:04.165 MyApp[2989:720882] (
0 CoreFoundation 0x00007fff8679a66c __exceptionPreprocess + 172
1 libobjc.A.dylib 0x00007fff874a276e objc_exception_throw + 43
2 CoreFoundation 0x00007fff8679a44a +[NSException raise:format:arguments:] + 106
3 Foundation 0x00007fff93e083a9 -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 195
4 AppKit 0x00007fff8a278d27 -[NSApplication _commonBeginModalSessionForWindow:relativeToWindow:modalDelegate:didEndSelector:contextInfo:] + 637
5 AppKit 0x00007fff8a2825e7 -[NSApplication beginModalSessionForWindow:] + 37
6 AppKit 0x00007fff8a282501 -[NSApplication runModalForWindow:] + 98
7 MyApp 0x0000000100004050 -[Document exportToOpenXml:] + 320
8 libsystem_trace.dylib 0x00007fff935e6cd7 _os_activity_initiate + 75
9 AppKit 0x00007fff8a14db71 -[NSApplication sendAction:to:from:] + 452
10 AppKit 0x00007fff8a167cbe -[NSMenuItem _corePerformAction] + 382
11 AppKit 0x00007fff8a1679dc -[NSCarbonMenuImpl performActionWithHighlightingForItemAtIndex:] + 114
12 libsystem_trace.dylib 0x00007fff935e6cd7 _os_activity_initiate + 75
13 AppKit 0x00007fff8a1b54e0 -[NSMenu performActionForItemAtIndex:] + 131
14 AppKit 0x00007fff8a1b5446 -[NSMenu _internalPerformActionForItemAtIndex:] + 35
15 AppKit 0x00007fff8a1b5292 -[NSCarbonMenuImpl _carbonCommandProcessEvent:handlerCallRef:] + 107
16 AppKit 0x00007fff8a15d5db NSSLMMenuEventHandler + 724
17 HIToolbox 0x00007fff8b34b98c _ZL23DispatchEventToHandlersP14EventTargetRecP14OpaqueEventRefP14HandlerCallRec + 1260
18 HIToolbox 0x00007fff8b34adce _ZL30SendEventToEventTargetInternalP14OpaqueEventRefP20OpaqueEventTargetRefP14HandlerCallRec + 386
19 HIToolbox 0x00007fff8b35f8f6 SendEventToEventTarget + 40
20 HIToolbox 0x00007fff8b394f25 _ZL18SendHICommandEventjPK9HICommandjjhPKvP20OpaqueEventTargetRefS5_PP14OpaqueEventRef + 428
21 HIToolbox 0x00007fff8b3c864d SendMenuCommandWithContextAndModifiers + 59
22 HIToolbox 0x00007fff8b3c85f4 SendMenuItemSelectedEvent + 188
23 HIToolbox 0x00007fff8b3c84c6 _ZL19FinishMenuSelectionP13SelectionDataP10MenuResultS2_ + 96
24 HIToolbox 0x00007fff8b3d0071 _ZL14MenuSelectCoreP8MenuData5PointdjPP13OpaqueMenuRefPt + 702
25 HIToolbox 0x00007fff8b3cfc5e _HandleMenuSelection2 + 446
26 AppKit 0x00007fff8a0e38be _NSHandleCarbonMenuEvent + 277
27 AppKit 0x00007fff89f7f2f0 _DPSNextEvent + 1843
28 AppKit 0x00007fff89f7e730 -[NSApplication nextEventMatchingMask:untilDate:inMode:dequeue:] + 194
29 AppKit 0x00007fff89f72593 -[NSApplication run] + 594
30 AppKit 0x00007fff89f5da14 NSApplicationMain + 1832
31 MyApp 0x0000000100016b32 main + 34
32 libdyld.dylib 0x00007fff866175c9 start + 1
)
I’m focusing on that line which says “Modal session requires modal window.” Could that mean there’s an incorect setting I don’t know about in the NIB file? Or do I have to do something to tell the window controller to wake up the window before using it?
—
Charles
_______________________________________________
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