Bug 5848 - standardWindowButton:forStyleMask: is an instance method rather than class method
Summary: standardWindowButton:forStyleMask: is an instance method rather than class me...
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-06-25 14:55 UTC by steven.orth
Modified: 2012-08-14 12:24 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-06-25 14:55:44 UTC
When attempting to call the class method standardWindowButton:forStyleMask: [		public virtual NSButton StandardWindowButton(NSWindowButton b, NSWindowStyle styleMask)
], there is a crash in native code:

	0   CoreFoundation                      0x99333a67 __raiseError + 231
	1   libobjc.A.dylib                     0x93410149 objc_exception_throw + 155
	2   CoreFoundation                      0x99337070 -[NSObject doesNotRecognizeSelector:] + 256
	3   CoreFoundation                      0x99285cd9 ___forwarding___ + 457
	4   CoreFoundation                      0x99285aa2 _CF_forwarding_prep_0 + 50
	5   ???                                 0x0bad7282 0x0 + 195916418
	6   ???                                 0x0bad718c 0x0 + 195916172
	7   ???                                 0x0bad64f0 0x0 + 195912944
	8   ???                                 0x0bad63dc 0x0 + 195912668
	9   ???                                 0x0bad62b8 0x0 + 195912376
	10  ???                                 0x07edde08 0x0 + 133029384
	11  ???                                 0x07ede5b0 0x0 + 133031344
	12  ???                                 0x000b9467 0x0 + 758887
	13  ???                                 0x000b826a 0x0 + 754282
	14  ???                                 0x000b814a 0x0 + 753994
	15  ???                                 0x07ef5d04 0x0 + 133127428
	16  ???                                 0x07ef5714 0x0 + 133125908
	17  ???                                 0x07ef5538 0x0 + 133125432
	18  ???                                 0x07ef51d6 0x0 + 133124566
	19  ???                                 0x03ce3f4c 0x0 + 63848268
	20  ???                                 0x04419f44 0x0 + 71409476
	21  Foundation                          0x972ec792 __NSFireDelayedPerform + 615
	22  CoreFoundation                      0x9924b2a6 __CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__ + 22
	23  CoreFoundation                      0x9924ac37 __CFRunLoopDoTimer + 743
	24  CoreFoundation                      0x99229cd0 __CFRunLoopRun + 1888
	25  CoreFoundation                      0x992291dc CFRunLoopRunSpecific + 332
	26  CoreFoundation                      0x99229088 CFRunLoopRunInMode + 120
	27  HIToolbox                           0x93088723 RunCurrentEventLoopInMode + 318
	28  HIToolbox                           0x9308f9b6 ReceiveNextEventCommon + 168
	29  HIToolbox                           0x9308f8fa BlockUntilNextEventMatchingListInMode + 88
	30  AppKit                              0x9bb300d8 _DPSNextEvent + 678
	31  AppKit                              0x9bb2f942 -[NSApplication nextEventMatchingMask:untilDate:inMode:dequeue:] + 113
	32  AppKit                              0x9bb2bcb1 -[NSApplication run] + 911
	33  ???                                 0x048d058c 0x0 + 76350860
	34  ???                                 0x07ef20d8 0x0 + 133112024
	35  ???                                 0x048d0df4 0x0 + 76353012
	36  ???                                 0x03cead35 0x0 + 63876405
	37  ???                                 0x044fb0a4 0x0 + 72331428
	38  AppKit                              0x9bdbcbd9 NSApplicationMain + 1054
	39  ???                                 0x048ce88e 0x0 + 76343438
	40  ???                                 0x048ce68c 0x0 + 76342924
	41  ???                                 0x000b3e70 0x0 + 736880
	42  ???                                 0x000ad974 0x0 + 711028
	43  ???                                 0x000acfe0 0x0 + 708576
	44  ???                                 0x000ad12e 0x0 + 708910
	45  libmono-2.0.dylib                   0x0020dca4 mono_jit_runtime_invoke + 164
	46  libmono-2.0.dylib                   0x003832e4 mono_runtime_invoke + 68
	47  libmono-2.0.dylib                   0x003893ae mono_runtime_exec_main + 238
	48  libmono-2.0.dylib                   0x002735fd mono_main + 6797
Comment 1 steven.orth 2012-06-25 15:49:28 UTC
Here is a functioning implementation I'm using on one of my classes:

        private static IntPtr selStandardWindowButtonForStyleMask_ = MonoMac.ObjCRuntime.Selector.GetHandle ("standardWindowButton:forStyleMask:");
        private static IntPtr class_ptr = MonoMac.ObjCRuntime.Class.GetHandle ("NSWindow");

        [Export("standardWindowButton:forStyleMask:")]
        public static NSButton CreateStandardWindowButton(NSWindowButton b, NSWindowStyle styleMask)
        {
            return (NSButton)MonoMac.ObjCRuntime.Runtime.GetNSObject(MonoMac.ObjCRuntime.Messaging.IntPtr_objc_msgSend_int_int(NSWindowBase.class_ptr, NSWindowBase.selStandardWindowButtonForStyleMask_, (int)b, (int)styleMask));
        }
Comment 2 Miguel de Icaza [MSFT] 2012-08-14 12:24:56 UTC
Fixed in Github