> On 3 Mar 2015, at 11:42 am, Uli Kusterer <[email protected]> wrote: > > Sounds like an actual bug, at least I don’t get this behaviour in my popvers. > Are you sure your NSPopover is still valid at the point? What does calling > malloc_size() on the pointer return? If it’s 0, it’s already been disposed.
I'm not able to obtain the NSPopover pointer at the time of the exception - the block is invoked automatically, not by my code. > > Are you using the same view controller for several popover pop-up events? I > usually create a new one and let the NSPopover release it. I also usually > release the NSPopover when I get an NSPopoverDidCloseNotification (or > whatever it is, going from memory here). Any of these different from what > you’re doing? It seems like you’re re-using both the popover and its view > controller for different occasions. That sounds like it should be fine, but > as I’m not doing it, it may be worth trying if somehow Apple isn’t expecting > that. > This got me thinking. I'm sharing the NSPopover instance, though I am creating a new view controller each time (that isn't obvious from my code due to the way its factored, but it's true). So what I did was assign this new controller to the popover and ask it to display. If the old popover (which is the same instance) is still visible, it will be closed, but I've swapped out its -viewController property. That's bad, apparently. So I changed the code to create a new NSPopover instance each time, and all is well. I can release it straight away, because it seems to retain itself as long as it's visible, and on close cleans up after itself. I think I was thinking that this wasn't the case, and so I had to keep a reference to it to clean it up on receiving a close notification, but it's a bit smarter in this respect than I assumed. The NSPopover class deals with closing transient popovers when a new one is told to display - again, smarter than I'd assumed. So my code is now simpler, I don't need the popover property in order to reuse the popover, and it all works better. --Graham _______________________________________________ Cocoa-dev mailing list ([email protected]) 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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [email protected]
