From ceaae3cf35172d773f6621f44b3c08e812a2167f Mon Sep 17 00:00:00 2001 From: John Darrington Date: Sun, 3 Mar 2013 11:15:59 +0100 Subject: [PATCH] Use our own explicit loop instead of main_loop_run --- src/ui/gui/page-assistant.c | 6 ++++-- src/ui/gui/text-data-import-dialog.c | 15 ++++++++++++++- src/ui/gui/text-data-import-dialog.h | 1 + 3 files changed, 19 insertions(+), 3 deletions(-) diff --git a/src/ui/gui/page-assistant.c b/src/ui/gui/page-assistant.c index f1c95f71fd..e10d83d0c6 100644 --- a/src/ui/gui/page-assistant.c +++ b/src/ui/gui/page-assistant.c @@ -65,7 +65,6 @@ static void on_cancel (GtkAssistant *assistant, struct import_assistant *); static void on_close (GtkAssistant *assistant, struct import_assistant *); static void on_paste (GtkButton *button, struct import_assistant *); static void on_reset (GtkButton *button, struct import_assistant *); -static void close_assistant (struct import_assistant *, int response); /* Initializes IA's asst substructure. PARENT_WINDOW must be the window to use as the assistant window's parent. */ @@ -239,7 +238,10 @@ static void close_assistant (struct import_assistant *ia, int response) { ia->asst.response = response; - g_main_loop_quit (ia->asst.main_loop); + /* Use our loop_done variable until we find out + why g_main_loop_quit (ia->asst.main_loop); doesn't work. + */ + ia->asst.loop_done = true; gtk_widget_hide (GTK_WIDGET (ia->asst.assistant)); } diff --git a/src/ui/gui/text-data-import-dialog.c b/src/ui/gui/text-data-import-dialog.c index fe08caa9b1..a9cf86054e 100644 --- a/src/ui/gui/text-data-import-dialog.c +++ b/src/ui/gui/text-data-import-dialog.c @@ -105,7 +105,20 @@ text_data_import_assistant (PsppireDataWindow *dw) gtk_widget_show_all (GTK_WIDGET (ia->asst.assistant)); ia->asst.main_loop = g_main_loop_new (NULL, false); - g_main_loop_run (ia->asst.main_loop); + + { + /* + Instead of this block, + A simple g_main_loop_run (ia->asst.main_loop); should work here. But it seems to crash. + I have no idea why. + */ + GMainContext *ctx = g_main_loop_get_context (ia->asst.main_loop); + ia->asst.loop_done = false; + while (! ia->asst.loop_done) + { + g_main_context_iteration (ctx, TRUE); + } + } g_main_loop_unref (ia->asst.main_loop); switch (ia->asst.response) diff --git a/src/ui/gui/text-data-import-dialog.h b/src/ui/gui/text-data-import-dialog.h index 847a1af6c6..dc8bef03c7 100644 --- a/src/ui/gui/text-data-import-dialog.h +++ b/src/ui/gui/text-data-import-dialog.h @@ -47,6 +47,7 @@ struct assistant GtkBuilder *builder; GtkAssistant *assistant; GMainLoop *main_loop; + bool loop_done; GtkWidget *paste_button; GtkWidget *reset_button; int response; -- 2.30.2