Document Unreleased Only When Quitting
Document Unreleased Only When Quitting
- Subject: Document Unreleased Only When Quitting
- From: Seth Willits <email@hidden>
- Date: Fri, 13 May 2005 03:23:13 -0700
I've been chasing down the source of this bug for two hours now, and
with some cleverness in overriding retain and release I've been able
to find that my document isn't being released when I'm quiting and
that this is causing a hang in the app.
If I have an unsaved document and tell the app to quit, the standard
sheet save changes appears. If I click "Don't Save" then the
document:shouldClose:contextInfo: method is called in which I do some
junk and then call [document close];. However after everything is
done, the retain count is still at 2, and the app hangs in a run
loop: <http://www.freaksw.com/Part3.png>
If instead of quitting the application with the unsaved document, I
simply close the document window, the same exact code runs on my end
(I verified this) but this time after clicking "Don't Save" the
document is additionally released by an autorelease pool and is
properly deallocated!
I have no idea what's causing this hang but here's what happen as far
as retain and releasing goes in these two cases:
+/- RC The Caller ** WHEN QUITTING **
---------------------------------------------------------------------
+1 1 (accounting for initial alloc)
+1 2 [NSDocumentController addDocument]
+1 3 [NSAlert sheetDidEnd...]
+1 4 [NSDocument close] // **
Remains unbalanced
+1 5 [NSMutableArray removeObject:range:identical:] // nsdocument
-1 4 CFArrayReleaseValues // removing
-1 3 [NSMutableArray removeObject] // document
-1 2 [NSAlert sheetDidEnd...]
+/- RC The Caller ** WHEN CLOSING **
---------------------------------------------------------------------
+1 1 (initial alloc)
+1 2 [NSDocumentController addDocument]
+1 3 [NSAlert sheetDidEnd...]
+1 4 [NSDocument close]
+1 5 [NSMutableArray removeObject:range:identical:] // nsdocument
-1 4 CFArrayReleaseValues // removing
-1 3 [NSMutableArray removeObject] // document
-1 2 [NSAlert sheetDidEnd...]
-1 1 autoRelease pool
-1 0 dealloc
So why is it that only when quitting the application with an unsaved
document that the document isn't actually released, and the
application hangs in this termination cycle?
Any ideas are appreciated,
--
Seth Willits
_______________________________________________
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