Re: App Crashing in ARC !!
Re: App Crashing in ARC !!
- Subject: Re: App Crashing in ARC !!
- From: KappA <email@hidden>
- Date: Thu, 23 Feb 2012 22:40:35 -0500
Based on this line:
**** -[NSPanel release]: message sent to deallocated instance 0x111c74a60*
And this from the stack trace:
*#2 0x00007fff8ff49ca0 in CFRelease ()*
Looks like you're over releasing. Perhaps ensure that the object is
declared as "strong" so that you keep a reference of it around?
This is just my guess based on the above. You should enable NSZombie and
malloc stack and see if you get any more info. If not, at least you have an
idea that it's the NSPanel, and you can take a closer look at that in your
code.
I happened to see this on the documentation for NSAlert which looks
interesting...
*<begin quote>*
Link<https://developer.apple.com/library/mac/#documentation/Cocoa/Reference/ApplicationKit/Classes/NSAlert_Class/Reference/Reference.html>Special
Considerations
This is a compatibility method. It is designed for easy adoption by
applications migrating from the corresponding function-based API. This
method uses earlier return
values—NSAlertDefaultReturn<https://developer.apple.com/library/mac/documentation/Cocoa/Reference/ApplicationKit/Classes/NSPanel_Class/Reference/Reference.html#//apple_ref/doc/c_ref/NSAlertDefaultReturn>
,NSAlertAlternateReturn<https://developer.apple.com/library/mac/documentation/Cocoa/Reference/ApplicationKit/Classes/NSPanel_Class/Reference/Reference.html#//apple_ref/doc/c_ref/NSAlertAlternateReturn>,
and NSAlertOtherReturn<https://developer.apple.com/library/mac/documentation/Cocoa/Reference/ApplicationKit/Classes/NSPanel_Class/Reference/Reference.html#//apple_ref/doc/c_ref/NSAlertOtherReturn>—compatible
with the earlier API, rather than the return values defined by the
NSAlert class,
described in “Button Return
Values.”<https://developer.apple.com/library/mac/documentation/Cocoa/Reference/ApplicationKit/Classes/NSAlert_Class/Reference/Reference.html#//apple_ref/doc/constant_group/Button_Return_Values>
Unless you must maintain compatibility with existing alert-processing code
that uses the function-based API, you should allocate (alloc) and
initialize (init) the object, and then set its attributes using the
appropriate methods of the NSAlert class.
*<end quote>*
Anyways, good luck and maybe someone else might chime in with a more
conclusive answer.
Thanks,
Kappa
On Thu, Feb 23, 2012 at 3:01 PM, Fritz Anderson <email@hidden>wrote:
> On 22 Feb 2012, at 9:31 PM, Naresh Kongara wrote:
>
> > I'm creating the alert with class method in NSAlert and running it with
> runModal.
> >
> > NSAlert *alert =[NSAlert
> alertWithMessageText:defaultButton:alternateButton:otherButton:informativeTextWithFormat:];
> > if ([alert runModal] == NSAlertDefaultReturn) {
> > //Code
> > }
> > This crash is happening only after we migrated to ARC. I tried with
> analyzer and Zombies, but no success in finding the cause for the crash.
>
> You've provided a skeleton of how you intend to do something, but nothing
> that shows what you are actually doing. You've provided nothing more than
> "make an alert and run it." If there is a bug in this section of your code,
> it's probably in the construction of the parameters to alertWith…, or in
> "Code."
>
> If your actual code is terribly complex, or proprietary, reduce it to a
> minimal case that reproduces it, and post it. Creating a minimal case will
> often show you your problem with no need to consult anyone else.
>
> Also: By any chance, are you running this alert on any thread other than
> the main one? You can't do that. You'll crash.
>
> — F
>
>
> _______________________________________________
>
> 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
>
_______________________________________________
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