Hi all,

A warning to NSPersistentDocument users....

Let's say you have an NSPersistentDocument-based app-- you do some work
and you save successfully.  Now let's say the app has a bug where its UI
allows the user to set a value outside the allowable range of one of
your NSManagedObjects.  When you try to save, the OS will give a message like:

"The document "Untitled" could not be saved as "Untitled". attribute is
too large."

The user is confused and panics.  He tries to "Save As" under a
different name instead.  Similar error message.  He messes around in the
UI but cannot make the document 'conform'.  He then tries "Save" again.
Poof, it crashes!

Exception Type:  EXC_BAD_ACCESS (SIGSEGV)
Exception Codes: KERN_INVALID_ADDRESS at 0x000000005b14c4a3
Crashed Thread:  0

Thread 0 Crashed:
0   libobjc.A.dylib                     0x9240e688 objc_msgSend + 24
1   com.apple.AppKit                    0x96ba8070 -[NSDocument
_willPresentSavingError:forOperation:url:] + 88
2   com.apple.AppKit                    0x96a759f2 -[NSDocument
_saveToURL:ofType:forSaveOperation:de
legate:didSaveSelector:contextInfo:] + 611
3   com.apple.AppKit                    0x96a75787 -[NSDocument
saveToURL:ofType:forSaveOperation:delegate:didSaveSelector:contextInfo:] + 860
4   com.apple.AppKit                    0x96aab8a1 -[NSDocument
_saveDocumentWithDelegate:didSaveSelector:contextInfo:] + 810
5   com.apple.AppKit                    0x96aab56f -[NSDocument
saveDocumentWithDelegate:didSaveSelector:contextInfo:] + 366
6   com.apple.AppKit                    0x96aab3f8 -[NSDocument saveDocument:] 
+ 58

This repros with a trivial test app in both 10.5.8 and, um, newer.

<http://www.rogue-research.com/EpicSaveFail7169032.zip>
<rdar://problem/7169032>

So be sure to fix all your validation errors, because the frameworks are
not forgiving! :(

--
____________________________________________________________
Sean McBride, B. Eng                 s...@rogue-research.com
Rogue Research                        www.rogue-research.com
Mac Software Developer              Montréal, Québec, Canada


_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to