fix: Occasional crash when using favorites
This commit is contained in:
parent
ea9457c08c
commit
60649d1cba
@ -947,7 +947,6 @@
|
||||
"hex.builtin.common.deny": "Verweigern",
|
||||
"hex.builtin.common.warning": "Warnung",
|
||||
"hex.builtin.pattern_drawer.export": "Pattern exportieren als...",
|
||||
"hex.builtin.pattern_drawer.updating": "Favoriten werden aktualisiert...",
|
||||
"hex.builtin.pl_visualizer.coordinates.latitude": "Breitengrade",
|
||||
"hex.builtin.pl_visualizer.coordinates.longitude": "Längengrad",
|
||||
"hex.builtin.pl_visualizer.coordinates.query": "Adresse finden",
|
||||
|
@ -436,7 +436,6 @@
|
||||
"hex.builtin.pattern_drawer.tree_style.auto_expanded": "Auto Expanded Tree",
|
||||
"hex.builtin.pattern_drawer.tree_style.flattened": "Flattened",
|
||||
"hex.builtin.pattern_drawer.type": "Type",
|
||||
"hex.builtin.pattern_drawer.updating": "Updating Favorites...",
|
||||
"hex.builtin.pattern_drawer.value": "Value",
|
||||
"hex.builtin.pattern_drawer.var_name": "Name",
|
||||
"hex.builtin.pattern_drawer.visualizer.unknown": "Unknown visualizer",
|
||||
|
@ -948,7 +948,6 @@
|
||||
"hex.builtin.pattern_drawer.end": "结束",
|
||||
"hex.builtin.pattern_drawer.export": "导出为...",
|
||||
"hex.builtin.pattern_drawer.start": "开始",
|
||||
"hex.builtin.pattern_drawer.updating": "正在更新收藏...",
|
||||
"hex.builtin.pl_visualizer.coordinates.latitude": "维度",
|
||||
"hex.builtin.pl_visualizer.coordinates.longitude": "精度",
|
||||
"hex.builtin.pl_visualizer.coordinates.query": "查找地址",
|
||||
|
@ -37,6 +37,8 @@ namespace hex::plugin::builtin::ui {
|
||||
|
||||
namespace {
|
||||
|
||||
std::mutex s_favoritesMutex;
|
||||
|
||||
constexpr auto DisplayEndDefault = 50U;
|
||||
|
||||
using namespace ::std::literals::string_literals;
|
||||
@ -1086,6 +1088,8 @@ namespace hex::plugin::builtin::ui {
|
||||
if (!patterns.empty() && !this->m_favoritesUpdateTask.isRunning()) {
|
||||
this->m_favoritesUpdateTask = TaskManager::createTask("hex.builtin.pattern_drawer.updating"_lang, TaskManager::NoProgress, [this, patterns](auto &task) {
|
||||
size_t updatedFavorites = 0;
|
||||
|
||||
std::scoped_lock lock(s_favoritesMutex);
|
||||
for (auto &pattern : patterns) {
|
||||
std::vector<std::string> patternPath;
|
||||
traversePatternTree(*pattern, patternPath, [&, this](pl::ptrn::Pattern &pattern) {
|
||||
@ -1128,12 +1132,13 @@ namespace hex::plugin::builtin::ui {
|
||||
ImGui::TableHeadersRow();
|
||||
|
||||
this->m_showFavoriteStars = false;
|
||||
if (!this->m_favorites.empty() && !patterns.empty()) {
|
||||
ImGui::TableNextColumn();
|
||||
ImGui::TableNextColumn();
|
||||
ImGui::PushID(1);
|
||||
if (ImGui::TreeNodeEx("hex.builtin.pattern_drawer.favorites"_lang, ImGuiTreeNodeFlags_SpanFullWidth)) {
|
||||
if (!this->m_favoritesUpdateTask.isRunning()) {
|
||||
if (!this->m_favoritesUpdateTask.isRunning()) {
|
||||
|
||||
if (!this->m_favorites.empty() && !patterns.empty()) {
|
||||
ImGui::TableNextColumn();
|
||||
ImGui::TableNextColumn();
|
||||
ImGui::PushID(1);
|
||||
if (ImGui::TreeNodeEx("hex.builtin.pattern_drawer.favorites"_lang, ImGuiTreeNodeFlags_SpanFullWidth)) {
|
||||
for (auto &[path, pattern] : this->m_favorites) {
|
||||
if (pattern == nullptr)
|
||||
continue;
|
||||
@ -1142,27 +1147,22 @@ namespace hex::plugin::builtin::ui {
|
||||
this->draw(*pattern);
|
||||
ImGui::PopID();
|
||||
}
|
||||
} else {
|
||||
ImGui::TableNextRow();
|
||||
ImGui::TableNextColumn();
|
||||
ImGui::TableNextColumn();
|
||||
ImGui::TextSpinner("hex.builtin.pattern_drawer.updating"_lang);
|
||||
|
||||
ImGui::TreePop();
|
||||
}
|
||||
|
||||
ImGui::TreePop();
|
||||
ImGui::PopID();
|
||||
}
|
||||
ImGui::PopID();
|
||||
}
|
||||
|
||||
this->m_showFavoriteStars = true;
|
||||
this->m_showFavoriteStars = true;
|
||||
|
||||
int id = 2;
|
||||
for (auto &pattern : this->m_sortedPatterns) {
|
||||
ImGui::PushID(id);
|
||||
this->draw(*pattern);
|
||||
ImGui::PopID();
|
||||
int id = 2;
|
||||
for (auto &pattern : this->m_sortedPatterns) {
|
||||
ImGui::PushID(id);
|
||||
this->draw(*pattern);
|
||||
ImGui::PopID();
|
||||
|
||||
id += 1;
|
||||
id += 1;
|
||||
}
|
||||
}
|
||||
|
||||
ImGui::EndTable();
|
||||
@ -1178,6 +1178,9 @@ namespace hex::plugin::builtin::ui {
|
||||
this->m_lastVisualizerError.clear();
|
||||
this->m_currPatternPath.clear();
|
||||
|
||||
this->m_favoritesUpdateTask.interrupt();
|
||||
|
||||
std::scoped_lock lock(s_favoritesMutex);
|
||||
for (auto &[path, pattern] : this->m_favorites)
|
||||
pattern = nullptr;
|
||||
this->m_favoritesUpdated = false;
|
||||
|
Loading…
Reference in New Issue
Block a user