From d8e3e28cea69c2f0b44c100c679b06712272f256 Mon Sep 17 00:00:00 2001 From: Andy Hertzfeld Date: Fri, 9 Feb 2001 02:14:53 +0000 Subject: fixed bug 6458, crash if you quickly press cancel after pressing OK in the * libnautilus-extensions/nautilus-gnome-extensions.c: (widget_destroy_callback), (icon_selected_callback), (icon_cancel_pressed): fixed bug 6458, crash if you quickly press cancel after pressing OK in the icon picker; fixed by setting a boolean once the picker has been dismissed, and checking it so we don't do it twice. --- ChangeLog | 9 +++++++++ libnautilus-extensions/nautilus-gnome-extensions.c | 22 ++++++++++++++++------ libnautilus-private/nautilus-gnome-extensions.c | 22 ++++++++++++++++------ 3 files changed, 41 insertions(+), 12 deletions(-) diff --git a/ChangeLog b/ChangeLog index 8b8a78fdf..7a8bf4ecf 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2001-02-08 Andy Hertzfeld + + * libnautilus-extensions/nautilus-gnome-extensions.c: + (widget_destroy_callback), (icon_selected_callback), + (icon_cancel_pressed): + fixed bug 6458, crash if you quickly press cancel after pressing + OK in the icon picker; fixed by setting a boolean once the + picker has been dismissed, and checking it so we don't do it twice. + 2001-02-08 Andy Hertzfeld * src/nautilus-location-bar.c,h: (get_file_info_list), diff --git a/libnautilus-extensions/nautilus-gnome-extensions.c b/libnautilus-extensions/nautilus-gnome-extensions.c index cb39245c7..a94339426 100644 --- a/libnautilus-extensions/nautilus-gnome-extensions.c +++ b/libnautilus-extensions/nautilus-gnome-extensions.c @@ -53,7 +53,9 @@ struct IconSelectionData { GtkWidget *icon_selection; GtkWidget *file_entry; + GtkWidget *top_level_window; GtkWindow *owning_window; + gboolean dismissed; NautilusIconSelectionFunction selection_function; gpointer callback_data; }; @@ -611,7 +613,9 @@ nautilus_gnome_open_terminal (const char *command) static gboolean widget_destroy_callback (gpointer callback_data) { - gtk_widget_destroy (GTK_WIDGET (callback_data)); + IconSelectionData *selection_data = (IconSelectionData*) callback_data; + gtk_widget_destroy (selection_data->top_level_window); + g_free (selection_data); return FALSE; } @@ -636,7 +640,6 @@ icon_selected_callback (GtkWidget *button, IconSelectionData *selection_data) nautilus_show_error_dialog (_("No image was selected. You must click on an image to select it."), _("No selection made"), selection_data->owning_window); - } else { /* invoke the callback to inform it of the file path */ selection_data->selection_function (icon_path, selection_data->callback_data); @@ -644,16 +647,23 @@ icon_selected_callback (GtkWidget *button, IconSelectionData *selection_data) /* we have to get rid of the icon selection dialog, but we can't do it now, since the * file entry might still need it. Do it when the next idle rolls around - */ - g_idle_add (widget_destroy_callback, gtk_widget_get_toplevel (button)); - g_free (selection_data); + */ + selection_data->dismissed = TRUE; + selection_data->top_level_window = gtk_widget_get_toplevel (button); + gtk_idle_add ((GtkFunction) widget_destroy_callback, selection_data); } /* handle the cancel button being pressed */ static void icon_cancel_pressed (GtkWidget *button, IconSelectionData *selection_data) { - gnome_icon_selection_stop_loading(GNOME_ICON_SELECTION (selection_data->icon_selection)); + /* nothing to do if it's already been dismissed */ + if (selection_data->dismissed) { + return; + } + + gnome_icon_selection_stop_loading(GNOME_ICON_SELECTION (selection_data->icon_selection)); + /* remove pending idle routine, if necessary */ g_free (selection_data); gtk_widget_destroy (gtk_widget_get_toplevel (button)); } diff --git a/libnautilus-private/nautilus-gnome-extensions.c b/libnautilus-private/nautilus-gnome-extensions.c index cb39245c7..a94339426 100644 --- a/libnautilus-private/nautilus-gnome-extensions.c +++ b/libnautilus-private/nautilus-gnome-extensions.c @@ -53,7 +53,9 @@ struct IconSelectionData { GtkWidget *icon_selection; GtkWidget *file_entry; + GtkWidget *top_level_window; GtkWindow *owning_window; + gboolean dismissed; NautilusIconSelectionFunction selection_function; gpointer callback_data; }; @@ -611,7 +613,9 @@ nautilus_gnome_open_terminal (const char *command) static gboolean widget_destroy_callback (gpointer callback_data) { - gtk_widget_destroy (GTK_WIDGET (callback_data)); + IconSelectionData *selection_data = (IconSelectionData*) callback_data; + gtk_widget_destroy (selection_data->top_level_window); + g_free (selection_data); return FALSE; } @@ -636,7 +640,6 @@ icon_selected_callback (GtkWidget *button, IconSelectionData *selection_data) nautilus_show_error_dialog (_("No image was selected. You must click on an image to select it."), _("No selection made"), selection_data->owning_window); - } else { /* invoke the callback to inform it of the file path */ selection_data->selection_function (icon_path, selection_data->callback_data); @@ -644,16 +647,23 @@ icon_selected_callback (GtkWidget *button, IconSelectionData *selection_data) /* we have to get rid of the icon selection dialog, but we can't do it now, since the * file entry might still need it. Do it when the next idle rolls around - */ - g_idle_add (widget_destroy_callback, gtk_widget_get_toplevel (button)); - g_free (selection_data); + */ + selection_data->dismissed = TRUE; + selection_data->top_level_window = gtk_widget_get_toplevel (button); + gtk_idle_add ((GtkFunction) widget_destroy_callback, selection_data); } /* handle the cancel button being pressed */ static void icon_cancel_pressed (GtkWidget *button, IconSelectionData *selection_data) { - gnome_icon_selection_stop_loading(GNOME_ICON_SELECTION (selection_data->icon_selection)); + /* nothing to do if it's already been dismissed */ + if (selection_data->dismissed) { + return; + } + + gnome_icon_selection_stop_loading(GNOME_ICON_SELECTION (selection_data->icon_selection)); + /* remove pending idle routine, if necessary */ g_free (selection_data); gtk_widget_destroy (gtk_widget_get_toplevel (button)); } -- cgit v1.2.1