fix: Crash when not making a valid selection in provider load interfaces
This commit is contained in:
parent
0312027ca8
commit
7cdba75bef
@ -84,7 +84,7 @@ namespace hex::prv {
|
||||
|
||||
[[nodiscard]] virtual bool hasLoadInterface() const;
|
||||
[[nodiscard]] virtual bool hasInterface() const;
|
||||
virtual void drawLoadInterface();
|
||||
virtual bool drawLoadInterface();
|
||||
virtual void drawInterface();
|
||||
|
||||
[[nodiscard]] u32 getID() const;
|
||||
|
@ -243,7 +243,8 @@ namespace hex::prv {
|
||||
return false;
|
||||
}
|
||||
|
||||
void Provider::drawLoadInterface() {
|
||||
bool Provider::drawLoadInterface() {
|
||||
return true;
|
||||
}
|
||||
|
||||
void Provider::drawInterface() {
|
||||
|
@ -37,7 +37,7 @@ namespace hex::plugin::builtin {
|
||||
[[nodiscard]] std::vector<std::pair<std::string, std::string>> getDataDescription() const override;
|
||||
|
||||
[[nodiscard]] bool hasLoadInterface() const override { return true; }
|
||||
void drawLoadInterface() override;
|
||||
bool drawLoadInterface() override;
|
||||
|
||||
void loadSettings(const nlohmann::json &settings) override;
|
||||
[[nodiscard]] nlohmann::json storeSettings(nlohmann::json settings = { }) const override;
|
||||
|
@ -41,7 +41,7 @@ namespace hex::plugin::builtin {
|
||||
[[nodiscard]] bool isConnected() const;
|
||||
|
||||
[[nodiscard]] bool hasLoadInterface() const override { return true; }
|
||||
void drawLoadInterface() override;
|
||||
bool drawLoadInterface() override;
|
||||
|
||||
void loadSettings(const nlohmann::json &settings) override;
|
||||
[[nodiscard]] nlohmann::json storeSettings(nlohmann::json settings) const override;
|
||||
|
@ -312,7 +312,7 @@ namespace hex::plugin::builtin {
|
||||
#endif
|
||||
}
|
||||
|
||||
void DiskProvider::drawLoadInterface() {
|
||||
bool DiskProvider::drawLoadInterface() {
|
||||
#if defined(OS_WINDOWS)
|
||||
|
||||
if (this->m_availableDrives.empty())
|
||||
@ -340,6 +340,8 @@ namespace hex::plugin::builtin {
|
||||
this->m_path = this->m_pathBuffer;
|
||||
|
||||
#endif
|
||||
|
||||
return !this->m_path.empty();
|
||||
}
|
||||
|
||||
nlohmann::json DiskProvider::storeSettings(nlohmann::json settings) const {
|
||||
|
@ -308,7 +308,7 @@ namespace hex::plugin::builtin {
|
||||
}
|
||||
|
||||
|
||||
void GDBProvider::drawLoadInterface() {
|
||||
bool GDBProvider::drawLoadInterface() {
|
||||
ImGui::InputText("hex.builtin.provider.gdb.ip"_lang, this->m_ipAddress);
|
||||
ImGui::InputInt("hex.builtin.provider.gdb.port"_lang, &this->m_port, 0, 0);
|
||||
|
||||
@ -320,6 +320,8 @@ namespace hex::plugin::builtin {
|
||||
this->m_port = 0;
|
||||
else if (this->m_port > 0xFFFF)
|
||||
this->m_port = 0xFFFF;
|
||||
|
||||
return !this->m_ipAddress.empty() && this->m_port != 0;
|
||||
}
|
||||
|
||||
void GDBProvider::loadSettings(const nlohmann::json &settings) {
|
||||
|
@ -65,7 +65,7 @@ namespace hex::plugin::builtin {
|
||||
{
|
||||
ImGui::ColorButton("##color", ImColor(bookmark.color));
|
||||
ImGui::SameLine(0, 10);
|
||||
ImGui::TextUnformatted(bookmark.name.c_str());
|
||||
ImGui::TextFormatted("{} ", bookmark.name);
|
||||
|
||||
if (ImGui::GetIO().KeyShift) {
|
||||
ImGui::Indent();
|
||||
@ -78,7 +78,7 @@ namespace hex::plugin::builtin {
|
||||
ImGui::TableNextColumn();
|
||||
ImGui::TextFormatted("{}: ", "hex.builtin.common.region"_lang.get());
|
||||
ImGui::TableNextColumn();
|
||||
ImGui::TextFormatted("[ 0x{:08X} - 0x{:08X} ]", bookmark.region.getStartAddress(), bookmark.region.getEndAddress());
|
||||
ImGui::TextFormatted("[ 0x{:08X} - 0x{:08X} ] ", bookmark.region.getStartAddress(), bookmark.region.getEndAddress());
|
||||
|
||||
if (!bookmark.comment.empty() && bookmark.comment[0] != '\x00') {
|
||||
ImGui::TableNextRow();
|
||||
|
@ -29,11 +29,12 @@ namespace hex::plugin::builtin {
|
||||
|
||||
auto provider = hex::ImHexApi::Provider::get();
|
||||
if (provider != nullptr) {
|
||||
provider->drawLoadInterface();
|
||||
bool settingsValid = provider->drawLoadInterface();
|
||||
|
||||
ImGui::NewLine();
|
||||
ImGui::Separator();
|
||||
|
||||
ImGui::BeginDisabled(!settingsValid);
|
||||
if (ImGui::Button("hex.builtin.common.open"_lang)) {
|
||||
if (provider->open()) {
|
||||
EventManager::post<EventProviderOpened>(provider);
|
||||
@ -44,6 +45,7 @@ namespace hex::plugin::builtin {
|
||||
TaskManager::doLater([=] { ImHexApi::Provider::remove(provider); });
|
||||
}
|
||||
}
|
||||
ImGui::EndDisabled();
|
||||
|
||||
ImGui::SameLine();
|
||||
|
||||
|
@ -51,7 +51,7 @@ namespace hex::plugin::windows {
|
||||
|
||||
[[nodiscard]] bool hasLoadInterface() const override { return true; }
|
||||
[[nodiscard]] bool hasInterface() const override { return true; }
|
||||
void drawLoadInterface() override;
|
||||
bool drawLoadInterface() override;
|
||||
void drawInterface() override;
|
||||
|
||||
void loadSettings(const nlohmann::json &) override {}
|
||||
|
@ -55,7 +55,7 @@ namespace hex::plugin::windows {
|
||||
return { Region::Invalid(), false };
|
||||
}
|
||||
|
||||
void ProcessMemoryProvider::drawLoadInterface() {
|
||||
bool ProcessMemoryProvider::drawLoadInterface() {
|
||||
if (this->m_processes.empty() && !this->m_enumerationFailed) {
|
||||
DWORD numProcesses = 0;
|
||||
std::vector<DWORD> processIds;
|
||||
@ -162,6 +162,8 @@ namespace hex::plugin::windows {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return this->m_selectedProcess != nullptr;
|
||||
}
|
||||
|
||||
void ProcessMemoryProvider::drawInterface() {
|
||||
|
Loading…
x
Reference in New Issue
Block a user