NSDocument with NSMatrix crasher (10.4)
NSDocument with NSMatrix crasher (10.4)
- Subject: NSDocument with NSMatrix crasher (10.4)
- From: Shehryar Khan <email@hidden>
- Date: Sat, 8 Jul 2006 22:30:04 -0700
I'm working on a document based cocoa time tracking application. It
differs from a traditional document based application in that rather
than saving data to a file on the filesystem it invokes remote web
services to fetch and persist data.
Getting the document subsystem to behave slightly differently from
the norm is tricky. However, it lends itself perfectly to this type
of implementation and it's been going pretty well. That's until I
ran into the following problem:
If someone opens a document window, modifies it's contents (causes
the document window to get dirty), and then opts to close the window
choosing "Don't Save" in the unsaved Changes Sheet, the app crashes
with a EXC_BAD_ACCESS error.
I thought for sure that this was a problem specific to the way I'm
using the document subsystem, perhaps my subclass of
NSDocumentController isn't retaining the document properly, perhaps
the order of operations is off.
Well it turns out that the crash isn't related to my usage of the
document subsystem after all. I was able to reproduce the problem
with a totally vanilla cocoa document based application. Here's what
I did:
- create a new document based application
launch xcode
File -> New Project...
choose Cocoa Document-based Application
specify a name (anything will do) and a location (any will do)
click on Finish
- edit the nib
open up MyDocument.nib (should live under Resources)
delete the "Your document contents here"
grab a text field to your document window
reduce it's size and then select it
alt-drag first horizontally, then vertically to create a matrix of
text fields
save the nib
- modify -[MyDocument windowControllerDidLoadNib:]
add the following piece of code
[self updateChangeCount:NSChangeDone];
(note: adding this because we want to mark the window dirty to spawn
the
unsaved changes sheet which will trip the bug)
- set an extension that this app will open - anything will do here (I
chose .txt)
edit Info.plist and add "txt" to the CFBundleTypeExtensions array
- build and run the application
choose File -> Open...
in the Open Panel select a .txt file
choose a cell in the matrix and type in something
click on the close button
in the result Unsaved changes sheet choose "Don't Save"
watch the app crash
Here's a backtrace:
Program received signal: "EXC_BAD_ACCESS".
#0 0x93418dd4 in -[NSMatrix setNeedsDisplayInRect:]
#1 0x933eda29 in -[NSView setKeyboardFocusRingNeedsDisplayInRect:]
#2 0x93479838 in -[_NSKeyboardFocusClipView
_setKeyboardFocusRingNeedsDisplay]
#3 0x9348fddc in -[_NSKeyboardFocusClipView _clearFocusForView]
#4 0x9348fe4a in -[_NSKeyboardFocusClipView removeFromSuperview]
#5 0x93444fb5 in -[NSView removeFromSuperviewWithoutNeedingDisplay]
#6 0x90834f26 in CFArrayApplyFunction
#7 0x933c2333 in -[NSView _finalize]
#8 0x933c2188 in -[NSView dealloc]
#9 0x9347a011 in -[NSControl dealloc]
#10 0x9353ef06 in -[NSMatrix dealloc]
#11 0x933afd43 in -[NSView release]
#12 0x9270d873 in NSPopAutoreleasePool
#13 0x9339d130 in -[NSApplication run]
#14 0x93391037 in NSApplicationMain
#15 0x0000dffc in main at main.m:13
Please tell me I'm missing something really basic here. I find it
hard to believe that something as simple / straightforward as this
would result in an application crash.
thanks!
-shehryar
Attachment:
smime.p7s
Description: S/MIME cryptographic signature
_______________________________________________
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