diff options
author | iain holmes <iain@xamarin.com> | 2020-01-24 19:06:29 +0300 |
---|---|---|
committer | iain holmes <iain@xamarin.com> | 2020-01-27 14:47:43 +0300 |
commit | 6c6a281b1508927f46c92d1e5d6d84d1c0e1c856 (patch) | |
tree | fae77ac3253fffa9b94826d6dc561fae189c0209 | |
parent | 96b42aa0741af179a8e501f426b6ff5451c27264 (diff) |
Allow the startup to complete without taking control of the runloop.optional-mainloop
Separate the initialization/shutdown sequence into separate methods just on the
offchance that a separate runloop might be used.
-rw-r--r-- | main/src/core/MonoDevelop.Ide/MonoDevelop.Ide/IdeStartup.cs | 72 |
1 files changed, 49 insertions, 23 deletions
diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide/IdeStartup.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide/IdeStartup.cs index 389cdd31e8..0f282eb77c 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide/IdeStartup.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide/IdeStartup.cs @@ -242,27 +242,6 @@ namespace MonoDevelop.Ide var desktopService = Runtime.GetService<DesktopService> ().Result; desktopService.SetGlobalMenu (commandService, DefaultWorkbench.MainMenuPath, DefaultWorkbench.AppMenuPath); - // Run the main loop - Gtk.Application.Invoke ((s, e) => { - MainLoop (options, startupInfo).Ignore (); - }); - Gtk.Application.Run (); - - IdeApp.IsRunning = false; - - IdeApp.Customizer.OnIdeShutdown (); - - instanceConnection.Dispose (); - - lockupCheckRunning = false; - Runtime.Shutdown (); - - IdeApp.Customizer.OnCoreShutdown (); - - InstrumentationService.Stop (); - - MonoDevelop.Components.GtkWorkarounds.Terminate (); - return 0; } @@ -403,6 +382,46 @@ namespace MonoDevelop.Ide return 0; } + int Run (MonoDevelopOptions options, bool controlMainLoop) + { + var ret = Run (options); + if (ret != 0) { + return ret; + } + + if (controlMainLoop) { + // Run the main loop + Gtk.Application.Invoke ((s, e) => { + MainLoop (options, startupInfo).Ignore (); + }); + Gtk.Application.Run (); + + Shutdown (); + return 0; + } else { + MainLoop (options, startupInfo).Ignore (); + return 0; + } + } + + internal void Shutdown () + { + IdeApp.IsRunning = false; + + IdeApp.Customizer.OnIdeShutdown (); + + instanceConnection.Dispose (); + + lockupCheckRunning = false; + Runtime.Shutdown (); + + IdeApp.Customizer.OnCoreShutdown (); + + InstrumentationService.Stop (); + + GtkWorkarounds.Terminate (); + } + void RegisterServices () { Runtime.RegisterServiceType<ProgressMonitorManager, IdeProgressMonitorManager> (); @@ -723,6 +742,11 @@ namespace MonoDevelop.Ide public static int Main (string[] args, IdeCustomizer customizer = null) { + return Main (args, true, customizer); + } + + public static int Main (string[] args, bool controlMainLoop, IdeCustomizer customizer) + { IdeStartupTracker.StartupTracker.Start (); @@ -752,7 +776,7 @@ namespace MonoDevelop.Ide IdeStartupTracker.StartupTracker.MarkSection ("mainInitialization"); var app = new IdeStartup (); - ret = app.Run (options); + ret = app.Run (options, controlMainLoop); } catch (Exception ex) { LoggingService.LogFatalError ( string.Format ( @@ -761,7 +785,9 @@ namespace MonoDevelop.Ide BrandingService.ApplicationName ), ex); } finally { - Runtime.Shutdown (); + if (controlMainLoop) { + Runtime.Shutdown (); + } } LoggingService.Shutdown (); |