fix: Potential race condition with sorting in the pattern drawer
This commit is contained in:
parent
c2f661f021
commit
dd8e7025d0
@ -209,6 +209,12 @@ namespace hex::ui {
|
|||||||
|
|
||||||
void PatternDrawer::updateFilter() {
|
void PatternDrawer::updateFilter() {
|
||||||
m_filteredPatterns.clear();
|
m_filteredPatterns.clear();
|
||||||
|
|
||||||
|
if (m_filter.path.empty()) {
|
||||||
|
m_filteredPatterns = m_sortedPatterns;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
std::vector<std::string> treePath;
|
std::vector<std::string> treePath;
|
||||||
for (auto &pattern : m_sortedPatterns) {
|
for (auto &pattern : m_sortedPatterns) {
|
||||||
traversePatternTree(*pattern, treePath, [this, &treePath](auto &pattern){
|
traversePatternTree(*pattern, treePath, [this, &treePath](auto &pattern){
|
||||||
@ -1132,12 +1138,13 @@ namespace hex::ui {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!m_favoritesUpdateTask.isRunning()) {
|
||||||
sortedPatterns.clear();
|
sortedPatterns.clear();
|
||||||
std::transform(patterns.begin(), patterns.end(), std::back_inserter(sortedPatterns), [](const std::shared_ptr<pl::ptrn::Pattern> &pattern) {
|
std::transform(patterns.begin(), patterns.end(), std::back_inserter(sortedPatterns), [](const std::shared_ptr<pl::ptrn::Pattern> &pattern) {
|
||||||
return pattern.get();
|
return pattern.get();
|
||||||
});
|
});
|
||||||
|
|
||||||
std::sort(sortedPatterns.begin(), sortedPatterns.end(), [this, &sortSpecs](const pl::ptrn::Pattern *left, const pl::ptrn::Pattern *right) -> bool {
|
std::stable_sort(sortedPatterns.begin(), sortedPatterns.end(), [this, &sortSpecs](const pl::ptrn::Pattern *left, const pl::ptrn::Pattern *right) -> bool {
|
||||||
return this->sortPatterns(sortSpecs, left, right);
|
return this->sortPatterns(sortSpecs, left, right);
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -1148,6 +1155,7 @@ namespace hex::ui {
|
|||||||
}
|
}
|
||||||
|
|
||||||
sortSpecs->SpecsDirty = false;
|
sortSpecs->SpecsDirty = false;
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user