diff --git a/main/gui/source/init/tasks.cpp b/main/gui/source/init/tasks.cpp index ecc3ca3cc..639a8c572 100644 --- a/main/gui/source/init/tasks.cpp +++ b/main/gui/source/init/tasks.cpp @@ -19,6 +19,7 @@ #include #include +#include #include @@ -98,6 +99,7 @@ namespace hex::init { ContentRegistry::Views::impl::getEntries().clear(); impl::PopupBase::getOpenPopups().clear(); + impl::ToastBase::getQueuedToasts().clear(); ContentRegistry::Tools::impl::getEntries().clear(); diff --git a/main/gui/source/window/window.cpp b/main/gui/source/window/window.cpp index f80236f8b..1bb8bab0a 100644 --- a/main/gui/source/window/window.cpp +++ b/main/gui/source/window/window.cpp @@ -39,6 +39,7 @@ #include #include +#include namespace hex { @@ -673,10 +674,17 @@ namespace hex { static bool positionSet = false; static bool sizeSet = false; static double popupDelay = -2.0; + static u32 displayFrameCount = 0; static std::unique_ptr currPopup; static Lang name(""); + AT_FIRST_TIME { + EventImHexClosing::subscribe([] { + currPopup.reset(); + }); + }; + if (auto &popups = impl::PopupBase::getOpenPopups(); !popups.empty()) { if (!ImGui::IsPopupOpen(ImGuiID(0), ImGuiPopupFlags_AnyPopupId)) { if (popupDelay <= -1.0) { @@ -687,6 +695,7 @@ namespace hex { popupDelay = -2.0; currPopup = std::move(popups.back()); name = Lang(currPopup->getUnlocalizedName()); + displayFrameCount = 0; ImGui::OpenPopup(name); popups.pop_back(); @@ -720,6 +729,7 @@ namespace hex { const auto createPopup = [&](bool displaying) { if (displaying) { + displayFrameCount += 1; currPopup->drawContent(); if (ImGui::GetWindowSize().x > ImGui::GetStyle().FramePadding.x * 10) @@ -746,6 +756,10 @@ namespace hex { else createPopup(ImGui::BeginPopup(name, flags)); + if (!ImGui::IsPopupOpen(name) && displayFrameCount < 10) { + ImGui::OpenPopup(name); + } + if (currPopup->shouldClose()) { log::debug("Closing popup '{}'", name); positionSet = sizeSet = false;