Fix bugs in closing gds render windows

This commit is contained in:
Mario Hüttel 2019-03-15 20:36:23 +01:00
parent 28734a797a
commit 19b26a3c26
2 changed files with 17 additions and 13 deletions

View File

@ -74,15 +74,10 @@ static gboolean on_window_close(gpointer window, GdkEvent *event, gpointer user)
if (!self) if (!self)
return TRUE; 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 */ /* Close Window. Leads to termination of the program/the current instance */
g_clear_object(&self->main_window);
gtk_widget_destroy(GTK_WIDGET(window)); gtk_widget_destroy(GTK_WIDGET(window));
return TRUE; return TRUE;
} }
@ -429,17 +424,19 @@ static void gds_render_gui_dispose(GObject *gobject)
self = RENDERER_GUI(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->cell_tree_view);
g_clear_object(&self->convert_button); g_clear_object(&self->convert_button);
g_clear_object(&self->layer_selector); g_clear_object(&self->layer_selector);
g_clear_object(&self->cell_tree_store); g_clear_object(&self->cell_tree_store);
g_clear_object(&self->cell_search_entry); 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 */ /* Chain up */
G_OBJECT_CLASS(gds_render_gui_parent_class)->dispose(gobject); G_OBJECT_CLASS(gds_render_gui_parent_class)->dispose(gobject);
} }

9
main.c
View File

@ -32,7 +32,7 @@ struct application_data {
static void app_quit(GSimpleAction *action, GVariant *parameter, gpointer user_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)action;
(void)parameter; (void)parameter;
GList *list_iter; GList *list_iter;
@ -45,6 +45,7 @@ static void app_quit(GSimpleAction *action, GVariant *parameter, gpointer user_d
} }
g_list_free(appdata->gui_list); g_list_free(appdata->gui_list);
appdata->gui_list = NULL;
} }
static void app_about(GSimpleAction *action, GVariant *parameter, gpointer user_data) 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_application_register(G_APPLICATION(gapp), NULL, NULL);
g_signal_connect(gapp, "activate", G_CALLBACK(gapp_activate), &appdata); 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(); menu = g_menu_new();
m_quit = g_menu_new(); m_quit = g_menu_new();
m_about = g_menu_new(); m_about = g_menu_new();