fix: Error when opening a file
This commit is contained in:
parent
b372d20ab0
commit
9bf9788689
@ -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");
|
||||
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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")) {
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user