mirror of
https://github.com/ZoiteChat/zoitechat.git
synced 2026-03-16 02:30:19 +00:00
Fixed the Windows GTK3 native file chooser lifetime handling by adding an idle callback (gtkutil_native_dialog_unref_idle) that performs g_object_unref(native) outside the button-release signal stack. This avoids the crash path when cancelling the Load file dialog.
Updated the native chooser code path to replace immediate unref with deferred unref via g_idle_add(...) after gtk_native_dialog_run, while preserving the existing accept-only file handling behavior.
This commit is contained in:
@@ -492,6 +492,15 @@ gtkutil_file_req_response (GtkWidget *dialog, gint res, struct file_req *freq)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if defined (WIN32) && HAVE_GTK3
|
||||||
|
static gboolean
|
||||||
|
gtkutil_native_dialog_unref_idle (gpointer native)
|
||||||
|
{
|
||||||
|
g_object_unref (native);
|
||||||
|
return G_SOURCE_REMOVE;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
void
|
void
|
||||||
gtkutil_file_req (GtkWindow *parent, const char *title, void *callback, void *userdata, char *filter, char *extensions,
|
gtkutil_file_req (GtkWindow *parent, const char *title, void *callback, void *userdata, char *filter, char *extensions,
|
||||||
int flags)
|
int flags)
|
||||||
@@ -582,7 +591,11 @@ gtkutil_file_req (GtkWindow *parent, const char *title, void *callback, void *us
|
|||||||
if (response == GTK_RESPONSE_ACCEPT)
|
if (response == GTK_RESPONSE_ACCEPT)
|
||||||
gtkutil_file_req_done_chooser (native_chooser, freq);
|
gtkutil_file_req_done_chooser (native_chooser, freq);
|
||||||
|
|
||||||
g_object_unref (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);
|
g_free (freq);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user