diff options
author | Matthias Clasen <mclasen@redhat.com> | 2022-11-29 19:25:54 -0500 |
---|---|---|
committer | Matthias Clasen <mclasen@redhat.com> | 2022-12-09 11:05:48 -0500 |
commit | 637ef84d040a89ea843b9d3dd1da19229f4d7589 (patch) | |
tree | 0526f4116830acb05ec9b50cac5d9a4e120a373e | |
parent | b297baed32c75af72c96b266ae39f83e7f56f6c7 (diff) | |
download | gtk+-637ef84d040a89ea843b9d3dd1da19229f4d7589.tar.gz |
colordialogbutton: Survive window closing
If the parent window of the button gets destroyed
while the dialog is open, we cancel the async op,
but we need to be a little more careful about not
stepping on glass.
-rw-r--r-- | gtk/gtkcolordialogbutton.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/gtk/gtkcolordialogbutton.c b/gtk/gtkcolordialogbutton.c index 76e007f6cc..10f527febf 100644 --- a/gtk/gtkcolordialogbutton.c +++ b/gtk/gtkcolordialogbutton.c @@ -338,8 +338,9 @@ drag_prepare (GtkDragSource *source, static void update_button_sensitivity (GtkColorDialogButton *self) { - gtk_widget_set_sensitive (self->button, - self->dialog != NULL && self->cancellable == NULL); + if (self->button) + gtk_widget_set_sensitive (self->button, + self->dialog != NULL && self->cancellable == NULL); } static void @@ -347,10 +348,11 @@ color_chosen (GObject *source, GAsyncResult *result, gpointer data) { + GtkColorDialog *dialog = GTK_COLOR_DIALOG (source); GtkColorDialogButton *self = data; GdkRGBA *color; - color = gtk_color_dialog_choose_rgba_finish (self->dialog, result, NULL); + color = gtk_color_dialog_choose_rgba_finish (dialog, result, NULL); if (color) { gtk_color_dialog_button_set_rgba (self, color); |