fix: Make sure all textures are destroyed before glfw gets uninitialized

This commit is contained in:
WerWolv
2025-01-27 22:10:30 +01:00
parent 6e6c5bbc67
commit 24e7c2f3db
17 changed files with 104 additions and 56 deletions

View File

@@ -6,6 +6,8 @@
#include <init/run.hpp>
#include <window.hpp>
#include <GLFW/glfw3.h>
namespace hex::init {
int runImHex() {
@@ -27,14 +29,22 @@
handleFileOpenRequest();
}
// Main window
{
Window window;
window.loop();
// Initialize GLFW
if (!glfwInit()) {
log::fatal("Failed to initialize GLFW!");
std::abort();
}
ON_SCOPE_EXIT { glfwTerminate(); };
// Main window
{
Window window;
window.loop();
}
deinitializeImHex();
}
deinitializeImHex();
} while (shouldRestart);
return EXIT_SUCCESS;

View File

@@ -2,6 +2,7 @@
#include <emscripten.h>
#include <emscripten/html5.h>
#include <GLFW/glfw3.h>
#include <hex/api/imhex_api.hpp>
#include <hex/api/events/requests_lifecycle.hpp>
@@ -49,9 +50,12 @@
emscripten_cancel_main_loop();
ON_SCOPE_EXIT { glfwTerminate(); };
try {
saveFsData();
deinitializeImHex();
return "";
} catch (const std::exception &e) {
static std::string message;
@@ -65,6 +69,12 @@
emscripten_cancel_main_loop();
// Initialize GLFW
if (!glfwInit()) {
log::fatal("Failed to initialize GLFW!");
std::abort();
}
// Main window
static std::optional<Window> window;
window.emplace();