[Top][All Lists]

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

Replacing views with setContentView

From: Andreas Höschler
Subject: Replacing views with setContentView
Date: Sat, 10 Jun 2006 10:31:11 +0200

Hello all,

in our apps we have to replace views with setContentView:, e.g. in the inspector depending on the context. Our code works perfectly on MacOSX but failed under GNUstep. I spent 2 days on debugging this in the GNUstep sources. I finally figured out that this has to do with resizeWithOldSuperviewSize: and probably a no longer valid reference size after the replacing the contentView. Finally the following modification fixed the problem (last three lines):


- (void) setFrame: (NSRect)frameRect
  NSSize oldSize = _frame.size;
  NSView *cv = [_window contentView];

  frameRect = [isa windowFrameRectForFrameRect: frameRect
                                     styleMask: [window styleMask]];

  _autoresizes_subviews = NO;
  [super setFrame: frameRect];

  contentRect = [isa contentRectForWindowFrameRect: frameRect
                                         styleMask: [window styleMask]];

  // Safety Check.
//  [cv setAutoresizingMask: NSViewWidthSizable | NSViewHeightSizable];
//  [cv resizeWithOldSuperviewSize: oldSize];
  [cv setFrame: contentRect];

I don't understand what the author intended to do with this safety check, but it definitely makes our code fai. I checked 8 applications after my modification and all behave well. I therefore recommend to apply this patch.



reply via email to

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