diff --git a/gtk/src/gtk_preferences.cpp b/gtk/src/gtk_preferences.cpp index 800c1fdd..7ef17738 100644 --- a/gtk/src/gtk_preferences.cpp +++ b/gtk/src/gtk_preferences.cpp @@ -20,14 +20,23 @@ #define SAME_AS_GAME _("Same location as current game") -void snes9x_preferences_open(Snes9xWindow *window, Snes9xConfig *config) -{ - static Snes9xPreferences *preferences = nullptr; +static Snes9xPreferences *preferences = nullptr; +void snes9x_preferences_create(Snes9xConfig *config) +{ + Glib::Thread::create([config] { + Snes9xPreferences *new_preferences; + new_preferences = new Snes9xPreferences(config); + preferences = new_preferences; + }, true); +} + +void snes9x_preferences_open(Snes9xWindow *window) +{ if (!preferences) - { - preferences = new Snes9xPreferences(config); - } + return; + + auto &config = preferences->config; window->pause_from_focus_change (); diff --git a/gtk/src/gtk_preferences.h b/gtk/src/gtk_preferences.h index 8d6acd7f..fea41256 100644 --- a/gtk/src/gtk_preferences.h +++ b/gtk/src/gtk_preferences.h @@ -11,7 +11,8 @@ #include "gtk_s9x.h" #include "gtk_builder_window.h" -void snes9x_preferences_open(Snes9xWindow *window, Snes9xConfig *config); +void snes9x_preferences_create(Snes9xConfig *config); +void snes9x_preferences_open(Snes9xWindow *window); class Snes9xPreferences : public GtkBuilderWindow { diff --git a/gtk/src/gtk_s9xwindow.cpp b/gtk/src/gtk_s9xwindow.cpp index 4eb741c4..516a7e3d 100644 --- a/gtk/src/gtk_s9xwindow.cpp +++ b/gtk/src/gtk_s9xwindow.cpp @@ -78,6 +78,8 @@ Snes9xWindow::Snes9xWindow(Snes9xConfig *config) cairo_owned = false; mouse_grabbed = false; + snes9x_preferences_create(config); + if (Gtk::IconTheme::get_default()->has_icon("snes9x")) { window->set_default_icon_name("snes9x"); @@ -86,7 +88,6 @@ Snes9xWindow::Snes9xWindow(Snes9xConfig *config) { auto loader = Gdk::PixbufLoader::create(); loader->write((const guint8 *)app_icon, sizeof(app_icon)); - loader->close(); window->set_default_icon(loader->get_pixbuf()); } @@ -244,7 +245,7 @@ void Snes9xWindow::connect_signals() }); get_object("preferences_item")->signal_activate().connect([&] { - snes9x_preferences_open(this, config); + snes9x_preferences_open(this); }); get_object("open_netplay_item")->signal_activate().connect([&] {