1
0
mirror of synced 2025-02-07 06:31:24 +01:00

fix: Crash when using "Open in new View" button in bookmarks

This commit is contained in:
WerWolv 2023-07-16 20:35:10 +02:00
parent 54891c6d8f
commit aac9bf3896

View File

@ -2,6 +2,7 @@
#include <hex/api/content_registry.hpp> #include <hex/api/content_registry.hpp>
#include <hex/api/project_file_manager.hpp> #include <hex/api/project_file_manager.hpp>
#include <hex/api/task.hpp>
#include <hex/helpers/fmt.hpp> #include <hex/helpers/fmt.hpp>
#include <hex/helpers/utils.hpp> #include <hex/helpers/utils.hpp>
@ -284,12 +285,14 @@ namespace hex::plugin::builtin {
ImGui::SameLine(); ImGui::SameLine();
if (ImGui::IconButton(ICON_VS_GO_TO_FILE, ImGui::GetStyleColorVec4(ImGuiCol_Text))) { if (ImGui::IconButton(ICON_VS_GO_TO_FILE, ImGui::GetStyleColorVec4(ImGuiCol_Text))) {
auto newProvider = ImHexApi::Provider::createProvider("hex.builtin.provider.view", true); TaskManager::doLater([region, provider]{
if (auto *viewProvider = dynamic_cast<ViewProvider*>(newProvider); viewProvider != nullptr) { auto newProvider = ImHexApi::Provider::createProvider("hex.builtin.provider.view", true);
viewProvider->setProvider(region.getStartAddress(), region.getSize(), provider); if (auto *viewProvider = dynamic_cast<ViewProvider*>(newProvider); viewProvider != nullptr) {
if (viewProvider->open()) viewProvider->setProvider(region.getStartAddress(), region.getSize(), provider);
EventManager::post<EventProviderOpened>(viewProvider); if (viewProvider->open())
} EventManager::post<EventProviderOpened>(viewProvider);
}
});
} }
ImGui::InfoTooltip("hex.builtin.view.bookmarks.tooltip.open_in_view"_lang); ImGui::InfoTooltip("hex.builtin.view.bookmarks.tooltip.open_in_view"_lang);