[libgda/LIBGDA_5.0] GdaSql: really exit on ".q" command, removed warning



commit 97a5bde6e97e3fb5bc220fbe0674634ce56c4fe2
Author: Vivien Malerba <malerba gnome-db org>
Date:   Sun Jan 8 20:54:11 2012 +0100

    GdaSql: really exit on ".q" command, removed warning

 tools/gda-sql.c |    8 +++++++-
 1 files changed, 7 insertions(+), 1 deletions(-)
---
diff --git a/tools/gda-sql.c b/tools/gda-sql.c
index d0e590b..35b3c50 100644
--- a/tools/gda-sql.c
+++ b/tools/gda-sql.c
@@ -133,6 +133,7 @@ typedef struct {
 	MainData *main_data;
 GString *prompt = NULL;
 GMainLoop *main_loop = NULL;
+gboolean exit_requested = FALSE;
 
 static ConnectionSetting *get_current_connection_settings (SqlConsole *console);
 static char   **completion_func (const char *text, int start, int end);
@@ -414,6 +415,9 @@ main (int argc, char *argv[])
 		}
 	}
 
+	if (exit_requested)
+		goto cleanup;
+
 	/* set up interactive commands */
 	setup_sigint_handler ();
 	init_input ((TreatLineFunc) treat_line_func, prompt_func, NULL);
@@ -515,6 +519,7 @@ treat_line_func (const gchar *cmde, gboolean *out_cmde_exec_ok)
 				display_result (res);
 				if (res->type == GDA_INTERNAL_COMMAND_RESULT_EXIT) {
 					gda_internal_command_exec_result_free (res);
+					exit_requested = TRUE;
 					goto exit;
 				}
 				gda_internal_command_exec_result_free (res);
@@ -531,7 +536,8 @@ treat_line_func (const gchar *cmde, gboolean *out_cmde_exec_ok)
 
  exit:
 	g_free (loc_cmde);
-	g_main_loop_quit (main_loop);
+	if (main_loop)
+		g_main_loop_quit (main_loop);
 	return FALSE;
 }
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]