• 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
Re: Since when does caling [NSTimer invalidate] release the object that spawned it?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Since when does caling [NSTimer invalidate] release the object that spawned it?


  • Subject: Re: Since when does caling [NSTimer invalidate] release the object that spawned it?
  • From: "Timothy J. Wood" <email@hidden>
  • Date: Tue, 16 Aug 2005 19:31:01 -0700


On Aug 16, 2005, at 6:59 PM, Walt Horat wrote:

Subject says all. Code is:

- (IBAction) someMethod
{
    m_closeAlpha = 1.0;
    m_closeTimer = [NSTimer scheduledTimerWithTimeInterval:0.1
        target:self
        selector:@selector(windowCloseFade:)
        userInfo:self
        repeats:TRUE];

Zombie here...

}

- (IBAction) windowCloseFade: (id) sender
{
if (m_closeAlpha <= 0.0)
{
if (nil != m_closeTimer)
{
[m_closeTimer invalidate]; // invalidate our current timer
m_closeTimer = nil;
}
}
else
{
m_closeAlpha -= 0.0125; //(8 second fade)
[[self window] setAlphaValue: m_closeAlpha];
}
}




... probably causes crash here.

We crash on the call to invalidate. Looking up the stack, I can see it trying to deallocate the object that instantiated it (i.e. "self" in the call to create the timer). NOTE: frame #4 is the [m_closeTimer invalidate] statement. Why would invalidating my timer invalidate me?

#0 0x00023230 in -[UCSessionWindowController dealloc] at UCSessionWindowController.m:177
#1 0x93a7cccc in -[NSWindowController release]
#2 0x9288b0d0 in _timerRelease
#3 0x90772370 in CFRunLoopTimerInvalidate
#4 0x00025640 in -[UCSessionWindowController windowCloseFade:] at UCSessionWindowController.m:749
#5 0x9287fcfc in __NSFireTimer
#6 0x9075edb0 in __CFRunLoopDoTimer
#7 0x9074b728 in __CFRunLoopRun


Why, oh why... Why would it do that?


  The NSTimer method returns an autoreleased instance  :)

-tim

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: Since when does caling [NSTimer invalidate] release the object that spawned it?
      • From: Fritz Anderson <email@hidden>
References: 
 >[NEWBIE] windowDidBecomeKey ? (From: Stephane Pinel <email@hidden>)
 >Since when does caling [NSTimer invalidate] release the object that spawned it? (From: Walt Horat <email@hidden>)

  • Prev by Date: ZeroLink making progress bar animation smoother?
  • Next by Date: Re: AppleScript escape special characters
  • Previous by thread: Since when does caling [NSTimer invalidate] release the object that spawned it?
  • Next by thread: Re: Since when does caling [NSTimer invalidate] release the object that spawned it?
  • Index(es):
    • Date
    • Thread