Crash when MyDocument becomes the delegate of NSApplication
Crash when MyDocument becomes the delegate of NSApplication
- Subject: Crash when MyDocument becomes the delegate of NSApplication
- From: Jochen Moeller <email@hidden>
- Date: Sat, 25 Jul 2009 03:01:53 +0200
Hello List,
Suddenly my Doc-based Cocoa App began to crash always when I closed a
window.
In a long run I tracked it down when myDocument is made the delegate
of NSApplication.
I did the following few steps to reproduce the crash with an empty
App. in Xcode 3.1.3:
New Document-based Cocoa Application without GC.
Doubleclick MyDocument.xib, select the Application-Icon and make the
File's Owner the delegate of it.
Back in Xcode I wrote two NSLogs in -init:
- (id)init {
NSLog(@"%@ - %@", [self className], NSStringFromSelector(_cmd));
self = [super init];
if (self) {
NSLog(@" self: %p", self);
}
return self;
}
Then I enabled Zombies:
ExecutableApp / Info / Arguments / Vars for environment /
NSZombieEnabled YES.
When running the App and closing the window, or repeated New and
Closing again,
the App crashes reproducible with the following output:
[Session started at 2009-07-25 01:52:21 +0200.]
2009-07-25 01:52:21.278 NewDocApp[49373:10b] MyDocument - init
2009-07-25 01:52:21.280 NewDocApp[49373:10b] self: 0x175d70
[Session started at 2009-07-25 01:52:25 +0200.]
2009-07-25 01:52:25.724 NewDocApp[49373:10b] *** -[MyDocument
respondsToSelector:]:
message sent to deallocated instance 0x175d70
GNU gdb 6.3.50-20050815 (Apple version gdb-966) (Tue Mar 10 02:43:13
UTC 2009)
...snip...
This GDB was configured as "i386-apple-darwin".sharedlibrary apply-
load-rules all
Attaching to process 49373.
kill
The Debugger Debugger is attaching to process(gdb)
So the MyDocument class seems to be overreleased by NSApplication.
Is that a known issue?
Never use an NSDocument subclass for delegates?
Thanks for comments,
Jochen Moeller
_______________________________________________
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