diff options
author | Lluis Sanchez <lluis@xamarin.com> | 2019-07-05 20:34:50 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-07-05 20:34:50 +0300 |
commit | 3849e9c4a4b28b32696cb9f4a7ead0bc43da06d1 (patch) | |
tree | 766e23a28f682ddfd925b58d18f9bf3d5b0c645e | |
parent | 84e14e50f483484eec97c5ade7ea07dac3a9f797 (diff) | |
parent | d32c3cfaee201f4582760361ceb0f51115fe2c05 (diff) |
Merge pull request #8144 from mono/backport-pr-8143-to-release-8.2
[release-8.2] [Mac] Don't hang when terminating through the dock icon
-rw-r--r-- | main/src/addins/MacPlatform/MacPlatform.cs | 30 |
1 files changed, 4 insertions, 26 deletions
diff --git a/main/src/addins/MacPlatform/MacPlatform.cs b/main/src/addins/MacPlatform/MacPlatform.cs index 569ccbe782..34a34620e9 100644 --- a/main/src/addins/MacPlatform/MacPlatform.cs +++ b/main/src/addins/MacPlatform/MacPlatform.cs @@ -58,6 +58,7 @@ using MonoDevelop.Components.Mac; using System.Reflection; using MacPlatform; using MonoDevelop.Projects; +using System.Threading.Tasks; namespace MonoDevelop.MacIntegration { @@ -301,12 +302,13 @@ namespace MonoDevelop.MacIntegration var appDelegate = NSApplication.SharedApplication.Delegate as Xwt.Mac.AppDelegate; if (appDelegate != null) { - appDelegate.Terminating += (object o, TerminationEventArgs e) => { + appDelegate.Terminating += async (object o, TerminationEventArgs e) => { if (MonoDevelop.Ide.IdeApp.IsRunning) { // If GLib the mainloop is still running that means NSApplication.Terminate() was called // before Gtk.Application.Quit(). Cancel Cocoa termination and exit the mainloop. e.Reply = NSApplicationTerminateReply.Cancel; - Gtk.Main.Quit (); + + await IdeApp.Exit(); } else { // The mainloop has already exited and we've already cleaned up our application state // so it's now safe to terminate Cocoa. @@ -681,30 +683,6 @@ namespace MonoDevelop.MacIntegration { //FIXME: should we remove these when finalizing? try { - ApplicationEvents.Quit += delegate (object sender, ApplicationQuitEventArgs e) - { - // We can only attempt to quit safely if all windows are GTK windows and not modal - if (!IsModalDialogRunning ()) { - e.UserCancelled = !IdeApp.Exit ().Result; // FIXME: could this block in rare cases? - e.Handled = true; - return; - } - - // When a modal dialog is running, things are much harder. We can't just shut down MD behind the - // dialog, and aborting the dialog may not be appropriate. - // - // There's NSTerminateLater but I'm not sure how to access it from carbon, maybe - // we need to swizzle methods into the app's NSApplicationDelegate. - // Also, it stops the main CFRunLoop and enters a special runloop mode, not sure how that would - // interact with GTK+. - - // For now, just bounce - NSApplication.SharedApplication.RequestUserAttention (NSRequestUserAttentionType.CriticalRequest); - // and abort the quit. - e.UserCancelled = true; - e.Handled = true; - }; - ApplicationEvents.Reopen += delegate (object sender, ApplicationEventArgs e) { e.Handled = true; IdeApp.BringToFront (); |