1
0
mirror of synced 2025-02-17 18:59:21 +01:00

fix: Weird behaviour when trying to open a non-existing file through the command line

This commit is contained in:
WerWolv 2023-07-15 00:12:09 +02:00
parent f4ae1fda6d
commit c1cdab72ef

View File

@ -22,8 +22,12 @@ namespace hex::plugin::builtin {
auto provider = ImHexApi::Provider::createProvider("hex.builtin.provider.file", true);
if (auto *fileProvider = dynamic_cast<FileProvider*>(provider); fileProvider != nullptr) {
fileProvider->setPath(path);
if (fileProvider->open())
if (!provider->open() || !provider->isAvailable()) {
PopupError::open(hex::format("hex.builtin.provider.error.open"_lang, provider->getErrorMessage()));
TaskManager::doLater([provider] { ImHexApi::Provider::remove(provider); });
} else {
EventManager::post<EventProviderOpened>(fileProvider);
}
}
}