diff --git a/app/widgets/gimpfiledialog.c b/app/widgets/gimpfiledialog.c index cad6eaec4c..7f77e93e2e 100644 --- a/app/widgets/gimpfiledialog.c +++ b/app/widgets/gimpfiledialog.c @@ -387,6 +387,8 @@ gimp_file_dialog_dispose (GObject *object) { GimpFileDialog *dialog = GIMP_FILE_DIALOG (object); + gimp_widget_free_native_handle (GTK_WIDGET (dialog), &dialog->window_handle); + G_OBJECT_CLASS (parent_class)->dispose (object); dialog->progress = NULL; @@ -396,8 +398,6 @@ gimp_file_dialog_dispose (GObject *object) g_clear_pointer (&dialog->automatic_help_id, g_free); g_clear_pointer (&dialog->automatic_label, g_free); g_clear_pointer (&dialog->file_filter_label, g_free); - - gimp_widget_free_native_handle (GTK_WIDGET (dialog), &dialog->window_handle); } static gboolean diff --git a/libgimpwidgets/gimpwidgetsutils.c b/libgimpwidgets/gimpwidgetsutils.c index 65140c5da8..9ef5d0ef9c 100644 --- a/libgimpwidgets/gimpwidgetsutils.c +++ b/libgimpwidgets/gimpwidgetsutils.c @@ -1179,12 +1179,18 @@ gimp_widget_set_native_handle (GtkWidget *widget, * * Disposes a widget's native window handle created, possibly * asynchronously, by a previous call to [func@GimpUi.widget_set_native_handle]. - * Call this function on `dispose()` or `finalize()`. * * Depending on the platform, this function may also execute other * necessary clean up so you should call it and not simply free the * [struct@GLib.Bytes] yourself. * + * You should call this function in the `dispose()` implementation of + * your custom widget **before** chaining up with the parent class' + * `dispose()` call. The first call to the parent's `dispose()` will + * destroy the `GdkWindow` which will prevent this function to do part + * of its cleanup when run after. This may result in crashes on some + * platforms. + * * This is safe to call even if deferenced @window_handle is %NULL, i.e. * that you don't have to check if the window handle was actually set. *