Bug 12641 - NSApplication.BeginSheet bug
Summary: NSApplication.BeginSheet bug
Status: RESOLVED FIXED
Alias: None
Product: Xamarin.Mac
Classification: Desktop
Component: Library (Xamarin.Mac.dll) ()
Version: 1.4.x
Hardware: PC Mac OS
: --- normal
Target Milestone: ---
Assignee: Aaron Bockover [MSFT]
URL:
Depends on:
Blocks:
 
Reported: 2013-06-11 17:38 UTC by Jon Lipsky
Modified: 2015-01-16 17:12 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 Jon Lipsky 2013-06-11 17:38:24 UTC
I just upgraded to Xamarin.Mac 1.4 today and immediately ran into what looks like a bug to me.

I have a several places in my code where I display sheet, using the following method:
NSApplication.SharedApplication.BeginSheet(this, window, delegate { HandleDismissed(); });

This has always worked in previous versions; however after upgrading to Xamarin.Mac 1.4, I get the following error when I try to dismiss the Sheet:

2013-06-11 16:28:57.981 TouchDraw[967:2007] -[__MonoMac_OnEndTrackerDispatch xamarinApplySelector]: unrecognized selector sent to instance 0x10f3ffa0
2013-06-11 16:28:57.981 TouchDraw[967:2007] An uncaught exception was raised
2013-06-11 16:28:57.981 TouchDraw[967:2007] -[__MonoMac_OnEndTrackerDispatch xamarinApplySelector]: unrecognized selector sent to instance 0x10f3ffa0
2013-06-11 16:28:57.984 TouchDraw[967:2007] (
	0   CoreFoundation                      0x91c70e9b __raiseError + 219
	1   libobjc.A.dylib                     0x9794b52e objc_exception_throw + 230
	2   CoreFoundation                      0x91c74b0d -[NSObject(NSObject) doesNotRecognizeSelector:] + 253
	3   CoreFoundation                      0x91bbce97 ___forwarding___ + 487
	4   CoreFoundation                      0x91bbcc42 _CF_forwarding_prep_0 + 50
	5   AppKit                              0x92200f56 -[NSApplication endSheet:returnCode:] + 314
	6   ???                                 0x0c467e43 0x0 + 205946435
	7   ???                                 0x15673dd4 0x0 + 359087572
	8   ???                                 0x15673a88 0x0 + 359086728
	9   ???                                 0x156739b0 0x0 + 359086512
	10  ???                                 0x1567394b 0x0 + 359086411
	11  ???                                 0x06fe91dc 0x0 + 117346780
	12  ???                                 0x084efc50 0x0 + 139394128
	13  libobjc.A.dylib                     0x979585d3 -[NSObject performSelector:withObject:] + 70
	14  AppKit                              0x923fbb42 -[NSApplication sendAction:to:from:] + 436
	15  AppKit                              0x923fb950 -[NSControl sendAction:to:] + 102
	16  AppKit                              0x923fb85f -[NSCell _sendActionFrom:] + 159
	17  AppKit                              0x923f9dd0 -[NSCell trackMouse:inRect:ofView:untilMouseUp:] + 1895
	18  AppKit                              0x923f960f -[NSButtonCell trackMouse:inRect:ofView:untilMouseUp:] + 511
	19  AppKit                              0x923f8d29 -[NSControl mouseDown:] + 867

It looks to me like there is a problem with the Xamarin generated delegate that listens for callbacks and then forwards them to my C# method.  If I change the code to the following (where I have it send a message to my object), everything works:

NSApplication.SharedApplication.BeginSheet(this, window, this, SheetDidEndSelector, IntPtr.Zero);
Comment 1 Aaron Bockover [MSFT] 2013-09-26 10:36:16 UTC
I do believe we fixed this. Jon, can you confirm with a 1.6 build?
Comment 2 Timothy Risi 2015-01-16 17:12:36 UTC
Tested and working correctly now