Doc App - Errors closing an document.
Doc App - Errors closing an document.
- Subject: Doc App - Errors closing an document.
- From: Fredrik Olsson <email@hidden>
- Date: Wed, 14 Jun 2006 09:49:20 +0200
Repost but with more information.
I have an document based application. This application have a bundled
framework that defines a skeleton for a plug-in API. This skeleton is a
subclass of NSDocument defining a common
-initWithDatapacketRow:dataPath: (Stripped down to using only NSStrings
in an attempt to eliminate code when searching for the bug), and not
much more.
Also one plug-in is bundled with the application, the plug-in is a
bundle with a subclass of the skeleton provided in the framework, a nib
with a single window and nothing else.
When the app starts it scans it's PlugIns folder and stores the plug-in
bundles in a NSArray (Just one for now), using NSFileManager to
enumerate the folder content, and NSBundle's bundleWithPath:, nothing
complex I think.
When selecting a new document I fetch the NSBundle instance from my
array, get the principal class, alloc and init with
-initWithDatapacketRow:dataPath:, add to NSDocumentController,
createWindowControllers and showWindows. Also very basic I think. Sure I
do not use the open panel, but I can not do that as the data for the
documents can be fetched over network or whatever.
This works for opening new document, they display great, and in numbers
if I like. The trouble comes when closing a document. If I close one
document and try to open a new I will get this stack trace (Added a
breakpoint for -[NSException raise] or else I just get a notice of
attempting to insert nil into array):
#0 0x9294d008 in -[NSException raise]
#1 0x9294ce5c in +[NSException raise:format:]
#2 0x9290fd4c in -[NSCFArray addObject:]
#3 0x936f4bb8 in -[NSIBObjectData
nibInstantiateWithOwner:topLevelObjects:]
#4 0x936e103c in loadNib
#5 0x936e0a94 in +[NSBundle(NSNibLoading)
_loadNibFile:nameTable:withZone:ownerBundle:]
#6 0x93737f64 in +[NSBundle(NSNibLoading)
loadNibFile:externalNameTable:withZone:]
#7 0x937cb930 in -[NSWindowController loadWindow]
#8 0x937cb654 in -[NSWindowController window]
#9 0x937cb564 in -[NSWindowController showWindow:]
#10 0x937d8ac8 in -[NSDocument showWindows]
#11 0x00002884 in -[MTMainController newMessage:] <- THIS IS MINE!
#12 0x9377bff0 in -[NSApplication sendAction:to:from:]
#13 0x937d6838 in -[NSMenu performActionForItemAtIndex:]
#14 0x937d65bc in -[NSCarbonMenuImpl
performActionWithHighlightingForItemAtIndex:]
#15 0x936dd8a0 in _NSHandleCarbonMenuEvent
#16 0x936db204 in _DPSNextEvent
#17 0x936dab48 in -[NSApplication
nextEventMatchingMask:untilDate:inMode:dequeue:]
#18 0x936d708c in -[NSApplication run]
#19 0x937c7bfc in NSApplicationMain
#20 0x00002264 in _start at crt.c:272
I can also open two documents in succession and then close the first
one, no problem, when I close the second one I get this stack trace:
#0 0xfffeff20 in objc_msgSend_rtp
#1 0x907fd458 in CFRunLoopObserverInvalidate
#2 0x907db75c in __CFRunLoopDoObservers
#3 0x907db9dc in __CFRunLoopRun
#4 0x907db47c in CFRunLoopRunSpecific
#5 0x931d8980 in RunCurrentEventLoopInMode
#6 0x931d7f8c in ReceiveNextEventCommon
#7 0x931d7e80 in BlockUntilNextEventMatchingListInMode
#8 0x936dae84 in _DPSNextEvent
#9 0x936dab48 in -[NSApplication
nextEventMatchingMask:untilDate:inMode:dequeue:]
#10 0x936d708c in -[NSApplication run]
#11 0x937c7bfc in NSApplicationMain
#12 0x00002264 in _start at crt.c:272
Now here is not a single line of code I have written :/, that bothers
me. Escpecially since this stack trace is not the only one, I also on
occasion get:
#0 0xfffeff20 in objc_msgSend_rtp
#1 0x907bf08c in __CFArrayReleaseValues
#2 0x907bedf8 in __CFArrayDeallocate
#3 0x907bbf34 in _CFRelease
#4 0x9290e968 in NSPopAutoreleasePool
#5 0x936d70d4 in -[NSApplication run]
#6 0x937c7bfc in NSApplicationMain
#7 0x00002264 in _start at crt.c:272
Or just:
#0 0xfffeff20 in objc_msgSend_rtp
#1 0x9290e968 in NSPopAutoreleasePool
#2 0x936d70d4 in -[NSApplication run]
#3 0x937c7bfc in NSApplicationMain
#4 0x00002264 in _start at crt.c:272
Failing on the auto release pool, (and having a nil when creating
something new) gives me the idea that it should be something I release
one time too many, or perhaps do not retain when I should. And it is
probably located in the nib in he plug-in bundle. But should not the nib
be loaded again fresh and complete for each new document?
But after stripping the projects to just the bare basics needed to find
the plug-ins and open documents, the problem is still identical. And I
can still not find what might be wrong.
As kind of a last plead for help I have also uploaded a stripped down
project to:
http://peylow.no-ip.org/~peylow/StrippedDocApp.zip
Perhaps a pair of fresh eyes can locate the problem in no time
at all?
// Fredrik Olsson
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden