GTK3: Fix crash on changing theme

SDL uses GTK to draw window title bars on Wayland, and can crash
when the color scheme is changed. Disconnecting from the portal
before launching the emulator works around this.
This commit is contained in:
robxnano 2024-08-28 01:18:32 +01:00
parent 208c2645da
commit 8c1580ebc8
No known key found for this signature in database
GPG Key ID: 9FB6B03B782D1E42
4 changed files with 19 additions and 1 deletions

View File

@ -287,4 +287,13 @@ color_scheme_set_async (AppColorScheme scheme)
init_color_scheme_async();
}
void
color_scheme_disconnect (void)
{
if (desktop_portal)
{
g_object_unref(desktop_portal);
}
}
#endif // GTK_CHECK_VERSION

View File

@ -432,6 +432,10 @@ static void gui_startup (void)
#endif
if (use_gui && !PrefsEditor())
QuitEmulator();
#ifdef ENABLE_GTK_3_22
else
color_scheme_disconnect();
#endif
}
#ifdef ENABLE_GTK3

View File

@ -54,5 +54,6 @@ gboolean color_scheme_is_dark_theme (void);
gboolean color_scheme_toggle (void);
AppColorScheme color_scheme_get_app_scheme (void);
DesktopColorScheme color_scheme_get_desktop_scheme (void);
void color_scheme_disconnect (void);
G_END_DECLS

View File

@ -767,10 +767,14 @@ GtkWindow *win;
static void gui_startup (void)
{
#ifdef ENABLE_GTK_3_22
color_scheme_set(APP_PREFERS_LIGHT);
color_scheme_set(APP_PREFERS_LIGHT);
#endif
if (use_gui && !PrefsEditor())
QuitEmulator();
#ifdef ENABLE_GTK_3_22
else
color_scheme_disconnect();
#endif
}
#ifdef ENABLE_GTK3