From fa16fbace4add7bb3a9acd08bd54da3a1ea8c6ec Mon Sep 17 00:00:00 2001 From: BearOso Date: Mon, 26 Jun 2023 15:59:06 -0500 Subject: [PATCH] Fix OpenGL ImGui shutdown. Fix config folder on Windows. --- qt/src/EmuCanvasOpenGL.cpp | 6 ++++++ qt/src/EmuConfig.cpp | 17 ++++++++++++++++- qt/src/Snes9xController.cpp | 2 +- 3 files changed, 23 insertions(+), 2 deletions(-) diff --git a/qt/src/EmuCanvasOpenGL.cpp b/qt/src/EmuCanvasOpenGL.cpp index 379ab1af..7e790aae 100644 --- a/qt/src/EmuCanvasOpenGL.cpp +++ b/qt/src/EmuCanvasOpenGL.cpp @@ -332,6 +332,12 @@ void EmuCanvasOpenGL::paintEvent(QPaintEvent *event) void EmuCanvasOpenGL::deinit() { shader_parameters_dialog.reset(); + if (ImGui::GetCurrentContext()) + { + ImGui_ImplOpenGL3_Shutdown(); + ImGui::DestroyContext(); + } + context.reset(); } diff --git a/qt/src/EmuConfig.cpp b/qt/src/EmuConfig.cpp index 3af1d649..5be54b10 100644 --- a/qt/src/EmuConfig.cpp +++ b/qt/src/EmuConfig.cpp @@ -144,6 +144,7 @@ std::string EmuConfig::findConfigDir() char *dir; fs::path path; +#ifndef _WIN32 if ((dir = getenv("XDG_CONFIG_HOME"))) { path = dir; @@ -158,9 +159,23 @@ std::string EmuConfig::findConfigDir() { path = "./.snes9x"; } +#else + if ((dir = getenv("LOCALAPPDATA"))) + { + path = dir; + path /= "Snes9x"; + } + else if ((dir = getenv("APPDATA"))) + { + path = dir; + path /= "Snes9x"; + } + else + path = "snes9x"; +#endif if (!fs::exists(path)) - fs::create_directory(path); + fs::create_directories(path); return path.string(); } diff --git a/qt/src/Snes9xController.cpp b/qt/src/Snes9xController.cpp index 6206d11b..cbd473e0 100644 --- a/qt/src/Snes9xController.cpp +++ b/qt/src/Snes9xController.cpp @@ -408,7 +408,7 @@ std::string S9xGetDirectory(s9x_getdirtype dirtype) if (!fs::exists(path)) { - fs::create_directory(path); + fs::create_directories(path); } else if ((fs::status(path).permissions() & fs::perms::owner_write) == fs::perms::none) {