bug-gnustep
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Some small issues..


From: Ludovic Marcotte
Subject: Re: Some small issues..
Date: Thu, 18 Oct 2001 11:19:06 -0400 (EDT)

> Thanks - 'd like to have the time to track this down myself ... please let
> me know if you find something more about it

ok! I've found it.

In my previous message, the retainCount >= 1 was due to the fact that in
NSView: -setFrameSize we had:

if (_post_frame_changes)
  {
     [nc postNotificationName: NSViewFrameDidChangeNotification
          object: self];
  }

so our object (self) was in the contained in a NSNotification that was
itself, in the autorelease pool.

So, the retainCount of a NSTextView is alright but calling -dealloc on it
will cause a crash.

In NSTextContainer: - (void) setTextView:

we add an observer on our textView but we never remove it! So, our object
*will* receive notifications even after beeing deallocated.

We should, in NSTextContainer: modify -dealloc so it looks like:

- (void) dealloc
{
  NSNotificationCenter *nc;
  
  nc = [NSNotificationCenter defaultCenter];
  [nc removeObserver: self
      name: NSViewFrameDidChangeNotification
      object: _textView];

  RELEASE (_textView);
  [super dealloc];
}

Same thing for NSClipView. In - (void) setDocumentView: (NSView*)aView, we
add two observers and we never remove them.

I think we should remove them in NSClipView: -dealloc like:

- (void) dealloc
{
  NSNotificationCenter *nc;

  nc = [NSNotificationCenter defaultCenter];

  [nc removeObserver: self
      name: NSViewFrameDidChangeNotification
      object: _documentView];

  [nc removeObserver: self
      name: NSViewBoundsDidChangeNotification
      object: _documentView];

  RELEASE(_documentView);
  RELEASE(_cursor);
  RELEASE(_backgroundColor);

  [super dealloc];
}

I've tested the code with GNUMail.app and *everything* gets dealloced
properly and nothing crash (iif we remove the observers in -dealloc!).

Ludo

-- 
Live as if you were to die tomorrow.
Learn as if you were to live forever.
 - Gandhi




reply via email to

[Prev in Thread] Current Thread [Next in Thread]