discuss-gnustep
[Top][All Lists]
Advanced

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

Problems with GNUMail or GSDecorationView?


From: Tim Kack
Subject: Problems with GNUMail or GSDecorationView?
Date: Wed, 19 Aug 2009 10:38:19 +0200

Hi all,

I am quite amateur when it comes to development, but I really want to keep GNUMail alive as my primary email client.
So bear with me if this analysis is a bit thin.

While debugging why the closing the Compose window (by hitting X or clicking 'Send') generates a SIGSEGV, I found the following and I would like to know your opinions whether this is a bug in GNUstep gui classes or in GNUMail.

First some structures:
EditWindow is a subclass of NSWindow
EditWindowController is a subclass of NSWindowController.

The controller is has the following initializer, and it is not using NIBs on Linux so the method argument is not important right now:

- (id) initWithWindowNibName: (NSString *) windowNibName

It creates a window with:

theEditWindow = [[EditWindow alloc] initWithContentRect: NSMakeRect(50,75,750,520)
                      styleMask: (NSClosableWindowMask|NSTitledWindowMask|
                          NSMiniaturizableWindowMask|NSResizableWindowMask)
                      backing: NSBackingStoreRetained
                      defer: NO];
 
  self = [super initWithWindow: theEditWindow];

It then sets itself to be the delegate:

  [theEditWindow setDelegate: self];

the controller is adding a Toolbar with the following setup and attaches it to the window

 // We initialize our toolbar
  aToolbar = [[NSToolbar alloc] initWithIdentifier: @"EditWindowToolbar"];
  [aToolbar setDelegate: self];
..
  [[self window] setToolbar: aToolbar];
  RELEASE(aToolbar);

With this known we know that:
* the EditWindow's delegate is the EditWindowController
* the toolbar in the EditWindow has the EditWindowController as delegate.

Now the problem:

When you hit 'Send' or close the window the following deallocation sequence is happening (ordered):
-dealloc in EditWindowController is called. (This goes fine)
-dealloc in EditWindow is called and crashes.

The crash is happening when  [super dealloc] is called and the following deallocation sequence is happening:
In NSWindow.m:734 -dealloc first thing that is called is [self setToolbar: nil];
It will try to remove the last toolbar view with (a  GSWindowDecorationView *_wv;) with removeToolbarView: [_toolbar _toolbarView].
The last method call in removeToolbarView is this:

[self changeWindowHeight: -toolbarViewHeight];

This is calling the follwing to adjust the frame in the NSWindow:

[window setFrame: windowFrame display: YES];

Here is the problem in the setFrame:display method that causes the sigsegv:

2067  if (NSEqualSizes(frameRect.size, _frame.size) == NO)
2068     {
2069       if ([_delegate respondsToSelector: @selector(windowWillResize:toSize:)])
2070         {
2071           frameRect.size = [_delegate windowWillResize: self
2072                                                 toSize: frameRect.size];
2073         }
2074     }


Note, at this point _delegate will be 0xdeadface because the EditWindowController has been deallocated and therefore respondsToSelector will crash.

Now, my question is - is this a GNUMail bug (i.e. the NSToolbar should have been deallocated earlier) or is it a problem with the GSWindowDecorationView removeToolbarView? Perhaps there should be a check if the delegate still is valid before calling setFrame?

The workaround is to set NSZombieEnabled to YES, but that will just hide the problem.

Any ideas?

Best regards,
Tim


reply via email to

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