• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag
 

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Trying to understand/prevent crash using restorableStateKeyPaths in NSPersistentUI Work
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Trying to understand/prevent crash using restorableStateKeyPaths in NSPersistentUI Work


  • Subject: Trying to understand/prevent crash using restorableStateKeyPaths in NSPersistentUI Work
  • From: Eric Wing <email@hidden>
  • Date: Fri, 24 Aug 2012 18:17:33 -0700

I am struggling with a crash when implementing restorableStateKeyPaths
in my NSWindowController for my main window in my app.

I discovered that I needed to save out the window frame before I
entered fullscreen so when the user exits fullscreen,  I can go back
to the original value. For this, I added an ivar to my
NSWindowController class. I also discovered that when the app is quit
in fullscreen, Lion likes to relaunch the app in fullscreen, but I
lose that variable I set. So I discovered I should use
restorableStateKeyPaths to save that value between app relaunches. My
method is simply this:

+ (NSArray *)restorableStateKeyPaths
{
    return [[super restorableStateKeyPaths]
arrayByAddingObject:@"frameForNonFullScreenMode"];
}


But my app also allows the main window (and controller) to be
destroyed while running and I create a new instance of the two.
Sometimes my app crashes several seconds after this happens. The crash
always happens in background thread like so:

Crashed Thread:  8  Dispatch queue: NSPersistentUI Work

Thread 8 Crashed:: Dispatch queue: NSPersistentUI Work
0   libobjc.A.dylib               	0x00007fff906c02d0 objc_msgSend + 16
1   com.apple.Foundation          	0x00007fff8d4f3386 probeGC + 80
2   com.apple.Foundation          	0x00007fff8d50a110
-[NSConcreteMapTable grow] + 628
3   com.apple.Foundation          	0x00007fff8d4f3324
-[NSConcreteMapTable setObject:forKey:] + 170
4   com.apple.AppKit              	0x00007fff91d0201b
-[NSPersistentUIManager addPendingKeyPath:forObject:] + 216
5   com.apple.AppKit              	0x00007fff91d02197
__72-[NSPersistentUIManager
observeValueForKeyPath:ofObject:change:context:]_block_invoke_0 + 59
6   libdispatch.dylib             	0x00007fff8c715f3d
_dispatch_call_block_and_release + 15
7   libdispatch.dylib             	0x00007fff8c7120fa
_dispatch_client_callout + 8
8   libdispatch.dylib             	0x00007fff8c7134c3
_dispatch_queue_drain + 235
9   libdispatch.dylib             	0x00007fff8c713335
_dispatch_queue_invoke + 52
10  libdispatch.dylib             	0x00007fff8c713207
_dispatch_worker_thread2 + 249
11  libsystem_c.dylib             	0x00007fff97a05ceb _pthread_wqthread + 404
12  libsystem_c.dylib             	0x00007fff979f01b1 start_wqthread + 13


I turned on Zombies and it appears something is trying to call the
hash method of my WindowController which is now deallocated. (I can
always reproduce this by just repeating this process a lot.)

When I remove the restorableStateKeyPaths, my crashes go away.


Is there something I need to do to break this connection so the system
doesn't try to access my WindowController after I close and destroy
it?

Thanks,
Eric
--
Beginning iPhone Games Development
http://playcontrol.net/iphonegamebook/
_______________________________________________

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

  • Prev by Date: Re: Have to specify (id)sender to action methods in OS X but not in iOS?
  • Next by Date: NSView -backingAlignedRect:
  • Previous by thread: Re: Have to specify (id)sender to action methods in OS X but not in iOS?
  • Next by thread: NSView -backingAlignedRect:
  • Index(es):
    • Date
    • Thread