mirror of
https://github.com/ZoiteChat/zoitechat.git
synced 2026-03-16 02:30:19 +00:00
Updated the Windows GTK3 native file-dialog flow to use asynchronous handling (gtk_native_dialog_show + "response" signal) instead of synchronous gtk_native_dialog_run, reducing risky dispose/unrealize timing during dialog close.
Added gtkutil_native_file_req_response() to keep completion semantics consistent: process selected files on accept, send the trailing callback(..., NULL) completion notification, free request state, and defer dialog unref to idle.
This commit is contained in:
@@ -499,6 +499,23 @@ gtkutil_native_dialog_unref_idle (gpointer native)
|
|||||||
g_object_unref (native);
|
g_object_unref (native);
|
||||||
return G_SOURCE_REMOVE;
|
return G_SOURCE_REMOVE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gtkutil_native_file_req_response (GtkNativeDialog *dialog, gint res, struct file_req *freq)
|
||||||
|
{
|
||||||
|
if (res == GTK_RESPONSE_ACCEPT)
|
||||||
|
gtkutil_file_req_done_chooser (GTK_FILE_CHOOSER (dialog), freq);
|
||||||
|
|
||||||
|
/* Match gtk dialog flow by always sending NULL to indicate completion. */
|
||||||
|
freq->callback (freq->userdata, NULL);
|
||||||
|
g_free (freq);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Defer unref until idle to avoid disposing the native chooser while
|
||||||
|
* still in the button-release signal stack on Windows.
|
||||||
|
*/
|
||||||
|
g_idle_add (gtkutil_native_dialog_unref_idle, dialog);
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void
|
void
|
||||||
@@ -529,7 +546,6 @@ gtkutil_file_req (GtkWindow *parent, const char *title, void *callback, void *us
|
|||||||
(flags & FRF_WRITE) ? _("_Save") : _("_Open"),
|
(flags & FRF_WRITE) ? _("_Save") : _("_Open"),
|
||||||
_("_Cancel"));
|
_("_Cancel"));
|
||||||
GtkFileChooser *native_chooser = GTK_FILE_CHOOSER (native);
|
GtkFileChooser *native_chooser = GTK_FILE_CHOOSER (native);
|
||||||
int response;
|
|
||||||
|
|
||||||
if (flags & FRF_MULTIPLE)
|
if (flags & FRF_MULTIPLE)
|
||||||
gtk_file_chooser_set_select_multiple (native_chooser, TRUE);
|
gtk_file_chooser_set_select_multiple (native_chooser, TRUE);
|
||||||
@@ -587,16 +603,9 @@ gtkutil_file_req (GtkWindow *parent, const char *title, void *callback, void *us
|
|||||||
freq->callback = callback;
|
freq->callback = callback;
|
||||||
freq->userdata = userdata;
|
freq->userdata = userdata;
|
||||||
|
|
||||||
response = gtk_native_dialog_run (GTK_NATIVE_DIALOG (native));
|
g_signal_connect (native, "response",
|
||||||
if (response == GTK_RESPONSE_ACCEPT)
|
G_CALLBACK (gtkutil_native_file_req_response), freq);
|
||||||
gtkutil_file_req_done_chooser (native_chooser, freq);
|
gtk_native_dialog_show (GTK_NATIVE_DIALOG (native));
|
||||||
|
|
||||||
/*
|
|
||||||
* Defer unref until idle to avoid disposing the native chooser while
|
|
||||||
* still in the button-release signal stack on Windows.
|
|
||||||
*/
|
|
||||||
g_idle_add (gtkutil_native_dialog_unref_idle, native);
|
|
||||||
g_free (freq);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user