mirror of
https://github.com/WerWolv/ImHex.git
synced 2026-04-02 05:27:41 -05:00
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:
@@ -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))) {
|
||||
|
||||
Reference in New Issue
Block a user