From 19b26a3c26ffe503bfb7c772888abd43719dbcfa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mario=20H=C3=BCttel?= Date: Fri, 15 Mar 2019 20:36:23 +0100 Subject: [PATCH] Fix bugs in closing gds render windows --- gds-render-gui.c | 21 +++++++++------------ main.c | 9 ++++++++- 2 files changed, 17 insertions(+), 13 deletions(-) diff --git a/gds-render-gui.c b/gds-render-gui.c index 366efc5..a251487 100644 --- a/gds-render-gui.c +++ b/gds-render-gui.c @@ -74,15 +74,10 @@ static gboolean on_window_close(gpointer window, GdkEvent *event, gpointer user) if (!self) return TRUE; - g_clear_object(&self->main_window); - g_clear_object(&self->cell_tree_view); - g_clear_object(&self->convert_button); - g_clear_object(&self->layer_selector); - g_clear_object(&self->cell_tree_store); - g_clear_object(&self->cell_search_entry); - /* Close Window. Leads to termination of the program/the current instance */ + g_clear_object(&self->main_window); gtk_widget_destroy(GTK_WIDGET(window)); + return TRUE; } @@ -429,17 +424,19 @@ static void gds_render_gui_dispose(GObject *gobject) self = RENDERER_GUI(gobject); - if (self->main_window) { - gtk_window_close(self->main_window); - } - - g_clear_object(&self->main_window); g_clear_object(&self->cell_tree_view); g_clear_object(&self->convert_button); g_clear_object(&self->layer_selector); g_clear_object(&self->cell_tree_store); g_clear_object(&self->cell_search_entry); + + if (self->main_window) { + g_signal_handlers_destroy(self->main_window); + gtk_widget_destroy(GTK_WIDGET(self->main_window)); + self->main_window = NULL; + } + /* Chain up */ G_OBJECT_CLASS(gds_render_gui_parent_class)->dispose(gobject); } diff --git a/main.c b/main.c index 39b2720..f921e16 100644 --- a/main.c +++ b/main.c @@ -32,7 +32,7 @@ struct application_data { static void app_quit(GSimpleAction *action, GVariant *parameter, gpointer user_data) { - const struct application_data * const appdata = (const struct application_data *)user_data; + struct application_data * const appdata = (struct application_data *)user_data; (void)action; (void)parameter; GList *list_iter; @@ -45,6 +45,7 @@ static void app_quit(GSimpleAction *action, GVariant *parameter, gpointer user_d } g_list_free(appdata->gui_list); + appdata->gui_list = NULL; } static void app_about(GSimpleAction *action, GVariant *parameter, gpointer user_data) @@ -102,6 +103,12 @@ static int start_gui(int argc, char **argv) g_application_register(G_APPLICATION(gapp), NULL, NULL); g_signal_connect(gapp, "activate", G_CALLBACK(gapp_activate), &appdata); + if (g_application_get_is_remote(G_APPLICATION(gapp)) == TRUE) { + g_application_activate(G_APPLICATION(gapp)); + printf("There is already an open instance. Will open second window in said instance.\n"); + return 0; + } + menu = g_menu_new(); m_quit = g_menu_new(); m_about = g_menu_new();