|
40 | 40 | namespace hex::plugin::builtin { |
41 | 41 |
|
42 | 42 | static void openFile(const std::fs::path &path) { |
43 | | - if (path.extension() == ".hexproj") { |
44 | | - if (!ProjectFile::load(path)) { |
45 | | - ui::ToastError::open(fmt::format("hex.builtin.popup.error.project.load"_lang, wolv::util::toUTF8String(path))); |
46 | | - } |
47 | | - |
48 | | - return; |
49 | | - } |
| 43 | + TaskManager::doLater([path] { |
| 44 | + if (path.extension() == ".hexproj") { |
| 45 | + if (!ProjectFile::load(path)) { |
| 46 | + ui::ToastError::open(fmt::format("hex.builtin.popup.error.project.load"_lang, wolv::util::toUTF8String(path))); |
| 47 | + } |
50 | 48 |
|
51 | | - auto provider = ImHexApi::Provider::createProvider("hex.builtin.provider.file", true); |
52 | | - if (auto *fileProvider = dynamic_cast<FileProvider*>(provider); fileProvider != nullptr) { |
53 | | - fileProvider->setPath(path); |
54 | | - if (!provider->open() || !provider->isAvailable()) { |
55 | | - ui::ToastError::open(fmt::format("hex.builtin.provider.error.open"_lang, provider->getErrorMessage())); |
56 | | - TaskManager::doLater([provider] { ImHexApi::Provider::remove(provider); }); |
57 | 49 | return; |
58 | 50 | } |
59 | 51 |
|
60 | | - EventProviderOpened::post(fileProvider); |
61 | | - AchievementManager::unlockAchievement("hex.builtin.achievement.starting_out", "hex.builtin.achievement.starting_out.open_file.name"); |
62 | | - ImHexApi::Provider::setCurrentProvider(provider); |
| 52 | + auto provider = ImHexApi::Provider::createProvider("hex.builtin.provider.file", true); |
| 53 | + if (auto *fileProvider = dynamic_cast<FileProvider*>(provider); fileProvider != nullptr) { |
| 54 | + fileProvider->setPath(path); |
| 55 | + if (!provider->open() || !provider->isAvailable()) { |
| 56 | + ui::ToastError::open(fmt::format("hex.builtin.provider.error.open"_lang, provider->getErrorMessage())); |
| 57 | + TaskManager::doLater([provider] { ImHexApi::Provider::remove(provider); }); |
| 58 | + return; |
| 59 | + } |
| 60 | + |
| 61 | + EventProviderOpened::post(fileProvider); |
| 62 | + AchievementManager::unlockAchievement("hex.builtin.achievement.starting_out", "hex.builtin.achievement.starting_out.open_file.name"); |
| 63 | + ImHexApi::Provider::setCurrentProvider(provider); |
63 | 64 |
|
64 | | - glfwRequestWindowAttention(ImHexApi::System::getMainWindowHandle()); |
65 | | - glfwFocusWindow(ImHexApi::System::getMainWindowHandle()); |
66 | | - } |
| 65 | + glfwRequestWindowAttention(ImHexApi::System::getMainWindowHandle()); |
| 66 | + glfwFocusWindow(ImHexApi::System::getMainWindowHandle()); |
| 67 | + } |
| 68 | + }); |
67 | 69 | } |
68 | 70 |
|
69 | 71 | void registerEventHandlers() { |
|
0 commit comments