4 Commits

Author SHA1 Message Date
deepend-tildeclub
c0e0fe4dcb Merge pull request #319 from ZoiteChat/css-use-after-free-fix
Fix channel tree font ownership/lifetime
2026-07-04 20:07:58 -06:00
deepend-tildeclub
9a189848ea Merge pull request #318 from ZoiteChat/windows-browser-preference
Prefer ShellExecuteW for Windows URL opens
2026-07-04 20:07:37 -06:00
9a6c913d89 Fix channel tree font ownership/lifetime 2026-07-02 13:08:48 -06:00
42010594be Prefer ShellExecuteW for Windows URL opens 2026-07-02 13:02:09 -06:00
2 changed files with 26 additions and 10 deletions

View File

@@ -79,6 +79,8 @@ struct _chanview
guint theme_listener_id;
};
static void chanview_set_font_desc (chanview *cv, const PangoFontDescription *font_desc);
struct _chan
{
chanview *cv; /* our owner */
@@ -169,6 +171,7 @@ chanview_apply_theme (chanview *cv)
w = GTK_WIDGET (tv->tree);
if (input_style)
font = input_style->font_desc;
chanview_set_font_desc (cv, font);
theme_manager_apply_channel_tree_style (w,
theme_manager_get_channel_tree_palette_behavior (font));
@@ -313,6 +316,14 @@ chanview_free_ch (chanview *cv, GtkTreeIter *iter)
g_free (ch);
}
static void
chanview_set_font_desc (chanview *cv, const PangoFontDescription *font_desc)
{
if (cv->font_desc)
pango_font_description_free (cv->font_desc);
cv->font_desc = font_desc ? pango_font_description_copy (font_desc) : NULL;
}
static void
chanview_destroy_store (chanview *cv) /* free every (chan *) in the store */
{
@@ -335,6 +346,9 @@ chanview_destroy (chanview *cv)
if (cv->box)
gtk_widget_destroy (cv->box);
if (cv->font_desc)
pango_font_description_free (cv->font_desc);
chanview_destroy_store (cv);
g_free (cv);
}
@@ -356,7 +370,7 @@ chanview_new (int type, int trunc_len, gboolean sort, gboolean use_icons,
cv = g_new0 (chanview, 1);
cv->store = gtk_tree_store_new (5, G_TYPE_STRING, G_TYPE_POINTER,
PANGO_TYPE_ATTR_LIST, GDK_TYPE_PIXBUF, G_TYPE_INT);
cv->font_desc = font_desc;
cv->font_desc = font_desc ? pango_font_description_copy (font_desc) : NULL;
cv->box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
cv->trunc_len = trunc_len;
cv->sorted = sort;

View File

@@ -1357,17 +1357,19 @@ fe_open_url_inner (const char *url)
gboolean opened = FALSE;
#ifdef WIN32
opened = g_app_info_launch_default_for_uri (escaped_url, NULL, &error);
gunichar2 *url_utf16 = g_utf8_to_utf16 (escaped_url, -1, NULL, NULL, NULL);
if (url_utf16 != NULL)
{
opened = ((INT_PTR) ShellExecuteW (0, L"open", url_utf16, NULL, NULL, SW_SHOWNORMAL)) > 32;
g_free (url_utf16);
}
if (!opened)
{
g_clear_error (&error);
gunichar2 *url_utf16 = g_utf8_to_utf16 (escaped_url, -1, NULL, NULL, NULL);
if (url_utf16 != NULL)
{
opened = ((INT_PTR) ShellExecuteW (0, L"open", url_utf16, NULL, NULL, SW_SHOWNORMAL)) > 32;
g_free (url_utf16);
}
opened = g_app_info_launch_default_for_uri (escaped_url, NULL, &error);
if (!opened)
g_clear_error (&error);
}
#else
{