Bug 3940 - NSView.AddSubview(NSView, NSWindowOrderingMode, NSView) crashes with null otherView argument
Summary: NSView.AddSubview(NSView, NSWindowOrderingMode, NSView) crashes with null oth...
Status: RESOLVED FIXED
Alias: None
Product: MonoMac
Classification: Desktop
Component: Bindings ()
Version: unspecified
Hardware: Macintosh Mac OS
: --- normal
Target Milestone: ---
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2012-03-16 14:53 UTC by steven.orth
Modified: 2012-03-22 13:29 UTC (History)
2 users (show)

Tags:
Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED FIXED

Description steven.orth 2012-03-16 14:53:31 UTC
According to the documentation here:

http://developer.apple.com/library/mac/#documentation/Cocoa/Reference/ApplicationKit/Classes/NSView_Class/Reference/NSView.html

---
addSubview:positioned:relativeTo:
Inserts a view among the receiver’s subviews so it’s displayed immediately above or below another view.

- (void)addSubview:(NSView *)aView positioned:(NSWindowOrderingMode)place relativeTo:(NSView *)otherView
Parameters
aView
The view object to add to the receiver as a subview.

place
An enum constant specifying the position of the aView relative to otherView. Valid values are NSWindowAbove or NSWindowBelow. 

otherView
The other view aView is to be positioned relative to. If otherView is nil (or isn’t a subview of the receiver), aView is added above or below all of its new siblings. 

Discussion
This method also sets the receiver as the next responder of aView.

The receiver retains aView. If you use removeFromSuperview to remove aView from the view hierarchy, aView is released. If you want to keep using aView after removing it from the view hierarchy (if, for example, you are swapping through a number of views), you must retain it before invoking removeFromSuperview.

----

Passing NULL for the 'otherView' argument crashes the appplication.
Comment 1 Duncan Mak 2012-03-22 13:27:42 UTC
Thanks for the hint - this is fixed in 8d44a7e8.
Comment 2 Duncan Mak 2012-03-22 13:29:58 UTC
I mean, 1701acb2.