Re: Removing subview crashes host application
Re: Removing subview crashes host application
- Subject: Re: Removing subview crashes host application
- From: Kevin <email@hidden>
- Date: Sat, 21 Apr 2007 14:46:48 -0500
Ken,
I do something similar to remove all subviews of a custom view, but I
use the objectEnumerator method. You don't need to autorelease each
subview unless you're retaining them yourself. They will be released
automatically when removeFromSuperview is called. See code below.
Kevin
xhead software
NSView *view;
NSEnumerator *viewEnumerator = [[contextView subviews]
objectEnumerator];
while ( view = [viewEnumerator nextObject] )
[view removeFromSuperview];
On Apr 21, 2007, at 2:16 PM, Ken Tozier wrote:
Hi
I have a multipurpose custom view class inside a plugin palette
that changes it's entire contents in response to various runtime
contextual information. What I'm trying to do is delete everything
inside the custom view when major context changes occur but am
finding that when I do the following, the host app crashes
id sub = [[contextView subviews] objectAtIndex: 0];
[sub removeFromSuperview];
[sub autorelease]; // <- commenting this out has no effect on the
crashes
Here's the crash log
Thread 0 Crashed:
0 libobjc.A.dylib 0x90a53387 objc_msgSend + 23
1 com.apple.AppKit 0x93567bf6
carbonAppEventLoopObserverHandler + 529
2 com.apple.HIToolbox 0x92dcc17e
_NotifyEventLoopObservers + 162
3 com.apple.HIToolbox 0x92dce6a0
PostEventToQueueInternal + 861
4 com.apple.HIToolbox 0x92dd22a7
ConvertPlatformEventRecordAndPostWithOptions + 7056
5 com.apple.HIToolbox 0x92dd06ea
PullEventsFromWindowServerOnConnection + 844
6 com.apple.HIToolbox 0x92dd0371 MessageHandler + 44
7 com.apple.CoreFoundation 0x90838773 __CFMachPortPerform
+ 136
8 com.apple.CoreFoundation 0x90828a14 CFRunLoopRunSpecific
+ 2904
9 com.apple.CoreFoundation 0x90827eb5 CFRunLoopRunInMode + 61
10 com.apple.HIToolbox 0x92dcdb90
RunCurrentEventLoopInMode + 285
11 com.apple.HIToolbox 0x92dcd297
ReceiveNextEventCommon + 385
12 com.apple.HIToolbox 0x92e15929 _AcquireNextEvent + 58
13 com.apple.HIToolbox 0x92e15774
RunApplicationEventLoop + 150
14 com.quark.QuarkXPress 0x00189da4 main + 208
15 com.quark.QuarkXPress 0x00002e7a _start + 216
16 com.quark.QuarkXPress 0x00002da1 start + 41
Am I deleting the subview incorrectly?
Any help appreciated.
Ken
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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:
40xheadsoftware.com
This email sent to email@hidden
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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