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