Fix segfault when opening recent file with pattern sync; Don't show p… (#2448)

…attern selection popup when pattern is already open

This PR does two things. Most importantly, it fixes a segfault that can
be caused by opening a recent file with pattern sync enabled.
Secondly, it makes it so that the pattern selection popup does not
appear if you already have text in the pattern editor for a given
provider (due to CLI args, a project file, pattern sync, etc.). If you
open a file normally, that text field is empty and the popup will appear
so you can select a pre-made pattern like usual.
This commit is contained in:
Zackary Newman
2025-09-14 00:10:38 -04:00
committed by GitHub
parent f08b182bf2
commit 67efea6444
4 changed files with 110 additions and 82 deletions

View File

@@ -45,6 +45,7 @@
#include <fonts/fonts.hpp>
#include <hex/api/events/requests_gui.hpp>
#include <hex/helpers/menu_items.hpp>
#include <hex/helpers/logger.hpp>
namespace hex::plugin::builtin {
@@ -70,6 +71,16 @@ namespace hex::plugin::builtin {
return;
}
ui::TextEditor *editor = m_view->getTextEditor();
if (editor != nullptr) {
if (!editor->isEmpty()) {
this->close();
return;
}
} else {
log::warn("Text editor not found, provider is null");
}
ImGuiExt::TextFormattedWrapped("{}", static_cast<const char *>("hex.builtin.view.pattern_editor.accept_pattern.desc"_lang));
if (ImGui::BeginListBox("##patterns_accept", ImVec2(400_scaled, 0))) {