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() {
|
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::GDBProvider>("hex.builtin.provider.gdb");
|
||||||
ContentRegistry::Provider::add<prv::DiskProvider>("hex.builtin.provider.disk");
|
ContentRegistry::Provider::add<prv::DiskProvider>("hex.builtin.provider.disk");
|
||||||
|
|
||||||
|
@ -20,7 +20,7 @@ namespace hex::plugin::builtin::prv {
|
|||||||
|
|
||||||
bool FileProvider::isAvailable() const {
|
bool FileProvider::isAvailable() const {
|
||||||
#if defined(OS_WINDOWS)
|
#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
|
#else
|
||||||
return this->m_file != -1 && this->m_mappedFile != nullptr;
|
return this->m_file != -1 && this->m_mappedFile != nullptr;
|
||||||
#endif
|
#endif
|
||||||
|
@ -481,7 +481,7 @@ namespace hex::plugin::builtin {
|
|||||||
saveAs();
|
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>();
|
EventManager::post<EventFileUnloaded>();
|
||||||
ImHexApi::Provider::remove(ImHexApi::Provider::get());
|
ImHexApi::Provider::remove(ImHexApi::Provider::get());
|
||||||
providerValid = false;
|
providerValid = false;
|
||||||
@ -728,6 +728,8 @@ namespace hex::plugin::builtin {
|
|||||||
fileProvider->setPath(path);
|
fileProvider->setPath(path);
|
||||||
if (!fileProvider->open()) {
|
if (!fileProvider->open()) {
|
||||||
View::showErrorPopup("hex.builtin.view.hexeditor.error.open"_lang);
|
View::showErrorPopup("hex.builtin.view.hexeditor.error.open"_lang);
|
||||||
|
ImHexApi::Provider::remove(provider);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -21,8 +21,6 @@ namespace hex::plugin::builtin {
|
|||||||
|
|
||||||
void ViewSettings::drawContent() {
|
void ViewSettings::drawContent() {
|
||||||
|
|
||||||
ImGui::SetNextWindowSizeConstraints(ImVec2(0, 0), ImVec2(FLT_MAX, FLT_MAX));
|
|
||||||
|
|
||||||
ImGui::SetNextWindowSize(ImVec2(500, 300) * SharedData::globalScale, ImGuiCond_Always);
|
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::BeginPopupModal(View::toWindowName("hex.builtin.view.settings.name").c_str(), &this->getWindowOpenState(), ImGuiWindowFlags_NoResize)) {
|
||||||
if (ImGui::BeginTabBar("settings")) {
|
if (ImGui::BeginTabBar("settings")) {
|
||||||
|
@ -484,26 +484,28 @@ namespace hex {
|
|||||||
call();
|
call();
|
||||||
View::getDeferedCalls().clear();
|
View::getDeferedCalls().clear();
|
||||||
|
|
||||||
|
View::drawCommonInterfaces();
|
||||||
|
|
||||||
for (auto &view : ContentRegistry::Views::getEntries()) {
|
for (auto &view : ContentRegistry::Views::getEntries()) {
|
||||||
GImGui->NextWindowData.ClearFlags();
|
ImGui::GetCurrentContext()->NextWindowData.ClearFlags();
|
||||||
|
|
||||||
view->drawAlwaysVisible();
|
view->drawAlwaysVisible();
|
||||||
|
|
||||||
if (!view->shouldProcess())
|
if (!view->shouldProcess())
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
auto minSize = view->getMinSize();
|
if (view->isAvailable()) {
|
||||||
minSize.x *= SharedData::globalScale;
|
auto minSize = view->getMinSize();
|
||||||
minSize.y *= SharedData::globalScale;
|
minSize.x *= SharedData::globalScale;
|
||||||
|
minSize.y *= SharedData::globalScale;
|
||||||
|
|
||||||
ImGui::SetNextWindowSizeConstraints(minSize, view->getMaxSize());
|
ImGui::SetNextWindowSizeConstraints(minSize, view->getMaxSize());
|
||||||
view->drawContent();
|
view->drawContent();
|
||||||
GImGui->NextWindowData.ClearFlags();
|
}
|
||||||
|
|
||||||
view->handleShortcut(pressedKeys, ImGui::GetIO().KeyCtrl, ImGui::GetIO().KeyShift, ImGui::GetIO().KeyAlt);
|
view->handleShortcut(pressedKeys, ImGui::GetIO().KeyCtrl, ImGui::GetIO().KeyShift, ImGui::GetIO().KeyAlt);
|
||||||
}
|
}
|
||||||
|
|
||||||
View::drawCommonInterfaces();
|
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
if (this->m_demoWindowOpen) {
|
if (this->m_demoWindowOpen) {
|
||||||
ImGui::ShowDemoWindow(&this->m_demoWindowOpen);
|
ImGui::ShowDemoWindow(&this->m_demoWindowOpen);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user