From 7a34df3041844918e2a0c5c44cb5601cff4c451a Mon Sep 17 00:00:00 2001 From: Arx Cruz Date: Tue, 26 Jul 2011 10:08:31 -0300 Subject: [PATCH] Bug #592195. This fix made the --list mode return as soon as receive an ok or cancel response avoiding crash. --- src/tree.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/tree.c b/src/tree.c index cdc1599..c15f502 100644 --- a/src/tree.c +++ b/src/tree.c @@ -39,6 +39,7 @@ static gchar *separator; static gboolean print_all_columns = FALSE; static gint *print_columns = NULL; static gint *hide_columns = NULL; +static GIOChannel *channel; static int *zenity_tree_extract_column_indexes (char *indexes, gint n_columns); static gboolean zenity_tree_column_is_hidden (gint column_index); @@ -125,7 +126,10 @@ zenity_tree_handle_stdin (GIOChannel *channel, gint status; do { - status = g_io_channel_read_line_string (channel, string, NULL, &error); + if (channel->is_readable == TRUE) + status = g_io_channel_read_line_string (channel, string, NULL, &error); + else + return FALSE; while (gtk_events_pending ()) gtk_main_iteration (); @@ -196,8 +200,6 @@ zenity_tree_fill_entries_from_stdin (GtkTreeView *tree_view, gboolean toggles, gboolean editable) { - GIOChannel *channel; - g_object_set_data (G_OBJECT (tree_view), "n_columns", GINT_TO_POINTER (n_columns)); g_object_set_data (G_OBJECT (tree_view), "toggles", GINT_TO_POINTER (toggles)); g_object_set_data (G_OBJECT (tree_view), "editable", GINT_TO_POINTER (editable)); @@ -628,6 +630,9 @@ zenity_tree_dialog_response (GtkWidget *widget, int response, gpointer data) zen_data->exit_code = zenity_util_return_exit_code (ZENITY_ESC); break; } + if (channel != NULL) + g_io_channel_shutdown (channel, TRUE, NULL); + gtk_main_quit (); }