Fully implement --quit

Ensure that -q also shuts down non-local instances.
This commit is contained in:
Michael Gratton 2019-04-10 18:26:22 +10:00 committed by Michael James Gratton
parent d8e4c31256
commit 6f2187f5e2
2 changed files with 17 additions and 7 deletions

View file

@ -426,8 +426,9 @@ public class GearyApplication : Gtk.Application {
// see create_async() for reasoning hold/release is used
hold();
if (this.controller != null) // If we didn't get activated, controller might be null
if (this.controller != null && this.controller.is_open) {
yield this.controller.close_async();
}
release();
this.is_destroyed = true;
@ -598,8 +599,10 @@ public class GearyApplication : Gtk.Application {
public int handle_general_options(Configuration config,
GLib.VariantDict options) {
if (options.contains(OPTION_QUIT))
if (options.contains(OPTION_QUIT)) {
exit();
return 0;
}
bool enable_debug = options.contains(OPTION_LOG_DEBUG);
// Will be logging to stderr until this point

View file

@ -109,6 +109,13 @@ public class GearyController : Geary.BaseObject {
}
/** Determines if the controller is opening or is open. */
public bool is_open {
get {
return (this.open_cancellable != null);
}
}
public weak GearyApplication application { get; private set; } // circular ref
public Accounts.Manager? account_manager { get; private set; default = null; }
@ -413,13 +420,13 @@ public class GearyController : Geary.BaseObject {
this.open_cancellable.cancel();
this.open_cancellable = null;
Geary.Engine.instance.account_available.disconnect(on_account_available);
// Release folder and conversations in the main window
on_conversations_selected(new Gee.HashSet<Geary.App.Conversation>());
on_folder_selected(null);
this.application.engine.account_available.disconnect(on_account_available);
if (this.main_window != null) {
// Release folder and conversations in the main window
on_conversations_selected(new Gee.HashSet<Geary.App.Conversation>());
on_folder_selected(null);
// Disconnect from various UI signals.
this.main_window.conversation_list_view.conversations_selected.disconnect(on_conversations_selected);
this.main_window.conversation_list_view.conversation_activated.disconnect(on_conversation_activated);