From 3cb8e3718293246c72d898af3d6085de52306caa Mon Sep 17 00:00:00 2001 From: WerWolv Date: Sat, 20 May 2023 11:52:24 +0200 Subject: [PATCH] fix: Broken file open logic Closes #1090 --- plugins/builtin/source/content/events.cpp | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/plugins/builtin/source/content/events.cpp b/plugins/builtin/source/content/events.cpp index 465a27f4d..6b02960d0 100644 --- a/plugins/builtin/source/content/events.cpp +++ b/plugins/builtin/source/content/events.cpp @@ -85,22 +85,25 @@ namespace hex::plugin::builtin { EventManager::post(newProvider); } else if (name == "Open File") { fs::openFileBrowser(fs::DialogMode::Open, { }, [](const auto &path) { - if(path.extension() == ".hexproj"){ + if (path.extension() == ".hexproj") { if (!ProjectFile::load(path)) { PopupError::open("hex.builtin.popup.error.project.load"_lang); } - }else{ + } else { FileProvider* newProvider = static_cast( ImHexApi::Provider::createProvider("hex.builtin.provider.file", true) ); + + if (newProvider == nullptr) + return; + newProvider->setPath(path); - newProvider->open(); - if (newProvider != nullptr && !newProvider->open()) + if (!newProvider->open()) hex::ImHexApi::Provider::remove(newProvider); else EventManager::post(newProvider); } - }); + }); } else if (name == "Open Project") { fs::openFileBrowser(fs::DialogMode::Open, { {"Project File", "hexproj"} }, [](const auto &path) {