fix: Hang when filtering for a large number of items in the pattern data view
This commit is contained in:
parent
b206e9fc95
commit
126868c251
@ -15,6 +15,7 @@ namespace hex::plugin::builtin {
|
||||
|
||||
private:
|
||||
bool m_rowColoring = false;
|
||||
u32 m_maxFilterItems = 128;
|
||||
ui::PatternDrawer::TreeStyle m_treeStyle = ui::PatternDrawer::TreeStyle::Default;
|
||||
|
||||
PerProvider<std::unique_ptr<ui::PatternDrawer>> m_patternDrawer;
|
||||
|
@ -481,6 +481,7 @@
|
||||
"hex.builtin.setting.general.max_mem_file_size": "Maximum size of file to load into memory",
|
||||
"hex.builtin.setting.general.max_mem_file_size.desc": "Small files are loaded into memory to prevent them from being modified directly on disk.\n\nIncreasing this size allows larger files to be loaded into memory before ImHex resorts to streaming in data from disk.",
|
||||
"hex.builtin.setting.general.network_interface": "Enable network interface",
|
||||
"hex.builtin.setting.general.pattern_data_max_filter_items": "Max number of items shown when filtering pattern data",
|
||||
"hex.builtin.setting.general.save_recent_providers": "Save recently used providers",
|
||||
"hex.builtin.setting.general.show_tips": "Show tips on startup",
|
||||
"hex.builtin.setting.general.sync_pattern_source": "Sync pattern source code between providers",
|
||||
|
@ -755,6 +755,8 @@ namespace hex::plugin::builtin {
|
||||
ContentRegistry::Settings::add<AutoBackupWidget>("hex.builtin.setting.general", "", "hex.builtin.setting.general.auto_backup_time");
|
||||
ContentRegistry::Settings::add<Widgets::SliderDataSize>("hex.builtin.setting.general", "", "hex.builtin.setting.general.max_mem_file_size", 512_MiB, 0_bytes, 32_GiB, 1_MiB)
|
||||
.setTooltip("hex.builtin.setting.general.max_mem_file_size.desc");
|
||||
ContentRegistry::Settings::add<Widgets::SliderInteger>("hex.builtin.setting.general", "hex.builtin.setting.general.patterns", "hex.builtin.setting.general.pattern_data_max_filter_items", 128, 32, 1024);
|
||||
|
||||
ContentRegistry::Settings::add<Widgets::Checkbox>("hex.builtin.setting.general", "hex.builtin.setting.general.patterns", "hex.builtin.setting.general.auto_load_patterns", true);
|
||||
ContentRegistry::Settings::add<Widgets::Checkbox>("hex.builtin.setting.general", "hex.builtin.setting.general.patterns", "hex.builtin.setting.general.sync_pattern_source", false);
|
||||
ContentRegistry::Settings::add<Widgets::Checkbox>("hex.builtin.setting.general", "hex.builtin.setting.general.network", "hex.builtin.setting.general.network_interface", false);
|
||||
|
@ -25,6 +25,12 @@ namespace hex::plugin::builtin {
|
||||
drawer->enableRowColoring(m_rowColoring);
|
||||
});
|
||||
|
||||
ContentRegistry::Settings::onChange("hex.builtin.setting.general", "hex.builtin.setting.general.pattern_data_max_filter_items", [this](const ContentRegistry::Settings::SettingsValue &value) {
|
||||
m_maxFilterItems = value.get<u32>(128);
|
||||
for (auto &drawer : m_patternDrawer.all())
|
||||
drawer->setMaxFilterDisplayItems(m_maxFilterItems);
|
||||
});
|
||||
|
||||
EventPatternEvaluating::subscribe(this, [this]{
|
||||
(*m_patternDrawer)->reset();
|
||||
});
|
||||
|
@ -36,6 +36,8 @@ namespace hex::ui {
|
||||
void setHoverCallback(std::function<void(const pl::ptrn::Pattern *)> callback) { m_hoverCallback = std::move(callback); }
|
||||
void enableRowColoring(bool enabled) { m_rowColoring = enabled; }
|
||||
void enablePatternEditing(bool enabled) { m_editingEnabled = enabled; }
|
||||
void setMaxFilterDisplayItems(u32 count) { m_maxFilterDisplayItems = count; }
|
||||
|
||||
void reset();
|
||||
|
||||
void jumpToPattern(const pl::ptrn::Pattern *pattern) { m_jumpToPattern = pattern; }
|
||||
@ -134,5 +136,7 @@ namespace hex::ui {
|
||||
|
||||
pl::gen::fmt::FormatterArray m_formatters;
|
||||
u64 m_lastRunId = 0;
|
||||
|
||||
u32 m_maxFilterDisplayItems = 128;
|
||||
};
|
||||
}
|
@ -248,9 +248,17 @@ namespace hex::ui {
|
||||
|
||||
std::vector<std::string> treePath;
|
||||
for (auto &pattern : m_sortedPatterns) {
|
||||
traversePatternTree(*pattern, treePath, [this, &treePath](auto &pattern){
|
||||
if (matchesFilter(m_filter.path, treePath, false))
|
||||
m_filteredPatterns.push_back(&pattern);
|
||||
if (m_filteredPatterns.size() > m_maxFilterDisplayItems)
|
||||
break;
|
||||
|
||||
traversePatternTree(*pattern, treePath, [this, &treePath](auto &pattern) {
|
||||
if (m_filteredPatterns.size() > m_maxFilterDisplayItems)
|
||||
return;
|
||||
|
||||
if (matchesFilter(m_filter.path, treePath, false)) {
|
||||
if (pattern.getValue() == m_filter.value)
|
||||
m_filteredPatterns.push_back(&pattern);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user