1
0
mirror of synced 2024-11-24 15:50:16 +01:00

fix: Error when opening a file

This commit is contained in:
WerWolv 2021-12-12 21:46:48 +01:00
parent b372d20ab0
commit 9bf9788689
5 changed files with 16 additions and 14 deletions

View File

@ -8,7 +8,7 @@ namespace hex::plugin::builtin {
void registerProviders() {
ContentRegistry::Provider::add<prv::GDBProvider>("hex.builtin.provider.file", false);
ContentRegistry::Provider::add<prv::FileProvider>("hex.builtin.provider.file", false);
ContentRegistry::Provider::add<prv::GDBProvider>("hex.builtin.provider.gdb");
ContentRegistry::Provider::add<prv::DiskProvider>("hex.builtin.provider.disk");

View File

@ -20,7 +20,7 @@ namespace hex::plugin::builtin::prv {
bool FileProvider::isAvailable() const {
#if defined(OS_WINDOWS)
return this->m_file != nullptr && this->m_mapping != nullptr && this->m_mappedFile != nullptr;
return this->m_file != INVALID_HANDLE_VALUE && this->m_mapping != INVALID_HANDLE_VALUE && this->m_mappedFile != nullptr;
#else
return this->m_file != -1 && this->m_mappedFile != nullptr;
#endif

View File

@ -481,7 +481,7 @@ namespace hex::plugin::builtin {
saveAs();
}
if (ImGui::MenuItem("hex.builtin.view.hexeditor.menu.file.close"_lang, "", false, providerValid && provider->isAvailable())) {
if (ImGui::MenuItem("hex.builtin.view.hexeditor.menu.file.close"_lang, "", false, providerValid)) {
EventManager::post<EventFileUnloaded>();
ImHexApi::Provider::remove(ImHexApi::Provider::get());
providerValid = false;
@ -728,6 +728,8 @@ namespace hex::plugin::builtin {
fileProvider->setPath(path);
if (!fileProvider->open()) {
View::showErrorPopup("hex.builtin.view.hexeditor.error.open"_lang);
ImHexApi::Provider::remove(provider);
return;
}
}

View File

@ -21,8 +21,6 @@ namespace hex::plugin::builtin {
void ViewSettings::drawContent() {
ImGui::SetNextWindowSizeConstraints(ImVec2(0, 0), ImVec2(FLT_MAX, FLT_MAX));
ImGui::SetNextWindowSize(ImVec2(500, 300) * SharedData::globalScale, ImGuiCond_Always);
if (ImGui::BeginPopupModal(View::toWindowName("hex.builtin.view.settings.name").c_str(), &this->getWindowOpenState(), ImGuiWindowFlags_NoResize)) {
if (ImGui::BeginTabBar("settings")) {

View File

@ -484,26 +484,28 @@ namespace hex {
call();
View::getDeferedCalls().clear();
View::drawCommonInterfaces();
for (auto &view : ContentRegistry::Views::getEntries()) {
GImGui->NextWindowData.ClearFlags();
ImGui::GetCurrentContext()->NextWindowData.ClearFlags();
view->drawAlwaysVisible();
if (!view->shouldProcess())
continue;
auto minSize = view->getMinSize();
minSize.x *= SharedData::globalScale;
minSize.y *= SharedData::globalScale;
if (view->isAvailable()) {
auto minSize = view->getMinSize();
minSize.x *= SharedData::globalScale;
minSize.y *= SharedData::globalScale;
ImGui::SetNextWindowSizeConstraints(minSize, view->getMaxSize());
view->drawContent();
GImGui->NextWindowData.ClearFlags();
ImGui::SetNextWindowSizeConstraints(minSize, view->getMaxSize());
view->drawContent();
}
view->handleShortcut(pressedKeys, ImGui::GetIO().KeyCtrl, ImGui::GetIO().KeyShift, ImGui::GetIO().KeyAlt);
}
View::drawCommonInterfaces();
#ifdef DEBUG
if (this->m_demoWindowOpen) {
ImGui::ShowDemoWindow(&this->m_demoWindowOpen);