mirror of
https://github.com/ZoiteChat/zoitechat.git
synced 2026-03-10 07:50:19 +00:00
Updated Linux URL launching in fe_open_url_inner to capture gtk_show_uri errors instead of discarding them, so failures are no longer silent.
Added an xdg-open fallback path when gtk_show_uri fails, which improves behavior in AppImage/sandbox-like environments where GTK/GIO handler resolution can fail. Added warning logs for both the primary gtk_show_uri failure and fallback failure to make future debugging much easier.
This commit is contained in:
@@ -1680,9 +1680,29 @@ fe_open_url_inner (const char *url)
|
||||
#elif defined(__APPLE__)
|
||||
osx_show_uri (url);
|
||||
#else
|
||||
GError *error = NULL;
|
||||
char *escaped_url = maybe_escape_uri (url);
|
||||
gchar *xdg_open_argv[] = {(gchar *) "xdg-open", escaped_url, NULL};
|
||||
g_debug ("Opening URL \"%s\" (%s)", escaped_url, url);
|
||||
gtk_show_uri (NULL, escaped_url, GDK_CURRENT_TIME, NULL);
|
||||
if (gtk_show_uri (NULL, escaped_url, GDK_CURRENT_TIME, &error))
|
||||
{
|
||||
g_free (escaped_url);
|
||||
return;
|
||||
}
|
||||
|
||||
g_warning ("gtk_show_uri failed for '%s': %s", escaped_url, error ? error->message : "unknown error");
|
||||
g_clear_error (&error);
|
||||
|
||||
/* AppImage and sandboxed environments can fail to resolve URI handlers
|
||||
* through GTK/GIO. Fall back to xdg-open when available. */
|
||||
if (!g_spawn_async (NULL, xdg_open_argv, NULL,
|
||||
G_SPAWN_SEARCH_PATH | G_SPAWN_STDOUT_TO_DEV_NULL | G_SPAWN_STDERR_TO_DEV_NULL,
|
||||
NULL, NULL, NULL, &error))
|
||||
{
|
||||
g_warning ("xdg-open fallback failed for '%s': %s", escaped_url, error ? error->message : "unknown error");
|
||||
g_clear_error (&error);
|
||||
}
|
||||
|
||||
g_free (escaped_url);
|
||||
#endif
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user