1
0
mirror of synced 2024-11-12 02:00:52 +01:00

fix: ImHex not closing when trying to exit with unsaved changes

This commit is contained in:
WerWolv 2023-11-24 11:42:27 +01:00
parent d34ad33c3c
commit d6d379108b

View File

@ -38,6 +38,7 @@ namespace hex::plugin::builtin {
static bool imhexClosing = false;
EventManager::subscribe<EventWindowClosing>([](GLFWwindow *window) {
imhexClosing = false;
if (ImHexApi::Provider::isDirty() && !imhexClosing) {
glfwSetWindowShouldClose(window, GLFW_FALSE);
PopupQuestion::open("hex.builtin.popup.exit_application.desc"_lang,
@ -58,13 +59,16 @@ namespace hex::plugin::builtin {
}
});
EventManager::subscribe<EventProviderClosing>([](const hex::prv::Provider *provider, bool *shouldClose) {
EventManager::subscribe<EventProviderClosing>([](const prv::Provider *provider, bool *shouldClose) {
if (provider->isDirty()) {
*shouldClose = false;
PopupUnsavedChanges::open("hex.builtin.popup.close_provider.desc"_lang,
[]{
for (const auto &provider : ImHexApi::Provider::impl::getClosingProviders())
ImHexApi::Provider::remove(provider, true);
if (imhexClosing)
ImHexApi::System::closeImHex(true);
},
[] {
ImHexApi::Provider::impl::resetClosingProvider();