diff --git a/controls.cpp b/controls.cpp index 878c809f..ac9b34e9 100644 --- a/controls.cpp +++ b/controls.cpp @@ -1562,6 +1562,7 @@ s9xcommand_t S9xGetCommandT (const char *name) cmd.button.multi_idx = multis.size() - 1; cmd.type = S9xButtonMulti; + free(c); } else { diff --git a/gtk/src/gtk_config.cpp b/gtk/src/gtk_config.cpp index 88a04f92..9d8ceddb 100644 --- a/gtk/src/gtk_config.cpp +++ b/gtk/src/gtk_config.cpp @@ -65,6 +65,16 @@ void S9xParsePortConfig(ConfigFile &conf, int pass) Snes9xConfig::Snes9xConfig() { joystick_threshold = 40; + xrr_crtc_info = nullptr; + xrr_screen_resources = nullptr; +} + +Snes9xConfig::~Snes9xConfig() +{ + if (xrr_crtc_info) + XRRFreeCrtcInfo(xrr_crtc_info); + if (xrr_screen_resources) + XRRFreeScreenResources(xrr_screen_resources); } int Snes9xConfig::load_defaults() diff --git a/gtk/src/gtk_config.h b/gtk/src/gtk_config.h index 207af3f5..ff953c12 100644 --- a/gtk/src/gtk_config.h +++ b/gtk/src/gtk_config.h @@ -48,6 +48,7 @@ class Snes9xConfig { public: Snes9xConfig(); + ~Snes9xConfig(); int load_config_file(); int save_config_file(); int load_defaults(); diff --git a/gtk/src/gtk_display.cpp b/gtk/src/gtk_display.cpp index 138dd29d..6f57d222 100644 --- a/gtk/src/gtk_display.cpp +++ b/gtk/src/gtk_display.cpp @@ -793,10 +793,12 @@ void S9xQueryDrivers() Window xid = gdk_x11_window_get_xid(top_level->window->get_window()->gobj()); gui_config->allow_xrandr = true; - gui_config->xrr_screen_resources = XRRGetScreenResourcesCurrent(dpy, xid); - gui_config->xrr_crtc_info = XRRGetCrtcInfo(dpy, - gui_config->xrr_screen_resources, - gui_config->xrr_screen_resources->crtcs[0]); + if (!gui_config->xrr_screen_resources) + gui_config->xrr_screen_resources = XRRGetScreenResourcesCurrent(dpy, xid); + if (!gui_config->xrr_crtc_info) + gui_config->xrr_crtc_info = XRRGetCrtcInfo(dpy, + gui_config->xrr_screen_resources, + gui_config->xrr_screen_resources->crtcs[0]); } #endif diff --git a/gtk/src/gtk_glx_context.cpp b/gtk/src/gtk_glx_context.cpp index 463f2ae6..fcb3cd5a 100644 --- a/gtk/src/gtk_glx_context.cpp +++ b/gtk/src/gtk_glx_context.cpp @@ -60,6 +60,7 @@ bool GTKGLXContext::attach(Display *dpy, Window xid) } fbconfig = fbconfigs[0]; + free(fbconfigs); return true; } diff --git a/gtk/src/gtk_s9xwindow.cpp b/gtk/src/gtk_s9xwindow.cpp index 7eb3af86..73a11f50 100644 --- a/gtk/src/gtk_s9xwindow.cpp +++ b/gtk/src/gtk_s9xwindow.cpp @@ -1167,20 +1167,28 @@ void Snes9xWindow::enter_fullscreen_mode() { Display *dpy = gdk_x11_display_get_xdisplay(gdk_display); + auto xrr_screen_resources = XRRGetScreenResourcesCurrent(dpy, gdk_x11_window_get_xid(gdk_window)); + auto xrr_crtc_info = XRRGetCrtcInfo(dpy, + xrr_screen_resources, + xrr_screen_resources->crtcs[0]); + + gdk_display_sync(gdk_display); if (XRRSetCrtcConfig(dpy, - config->xrr_screen_resources, - config->xrr_screen_resources->crtcs[0], + xrr_screen_resources, + xrr_screen_resources->crtcs[0], CurrentTime, - config->xrr_crtc_info->x, - config->xrr_crtc_info->y, - config->xrr_screen_resources->modes[config->xrr_index].id, - config->xrr_crtc_info->rotation, - &config->xrr_crtc_info->outputs[0], + xrr_crtc_info->x, + xrr_crtc_info->y, + xrr_screen_resources->modes[config->xrr_index].id, + xrr_crtc_info->rotation, + &xrr_crtc_info->outputs[0], 1) != 0) { config->change_display_resolution = 0; } + XRRFreeCrtcInfo(xrr_crtc_info); + XRRFreeScreenResources(xrr_screen_resources); if (gui_config->auto_input_rate) { diff --git a/vulkan/vulkan_context.cpp b/vulkan/vulkan_context.cpp index 6d28e6ce..f84ae02f 100644 --- a/vulkan/vulkan_context.cpp +++ b/vulkan/vulkan_context.cpp @@ -10,11 +10,12 @@ namespace Vulkan Context::Context() { - auto dl = new vk::DynamicLoader; + vk::DynamicLoader dl; auto vkGetInstanceProcAddr = - dl->getProcAddress("vkGetInstanceProcAddr"); + dl.getProcAddress("vkGetInstanceProcAddr"); VULKAN_HPP_DEFAULT_DISPATCHER.init(vkGetInstanceProcAddr); + } Context::~Context()