summaryrefslogtreecommitdiff
path: root/plugins/warp/ui/shared/fetcher.cpp
diff options
context:
space:
mode:
authorMason Reed <mason@vector35.com>2025-10-12 22:48:41 -0400
committerMason Reed <mason@vector35.com>2025-10-12 22:50:20 -0400
commit253fd4ad2d8095cc3c640c99d75ab3fd1cb7282e (patch)
tree2bb2549d4aa29971143ec013df9cc6971abc6be2 /plugins/warp/ui/shared/fetcher.cpp
parent40f7d40e394657575001a8146d8233f1fc4356fd (diff)
[WARP] Fix misc sidebar navigation / focus event bugs
- Fixed crash related to pending fetch callback for deleted view frame - Fixed focus not being kept for tables in the sidebar, as well as focus in general - Made matched function list navigation require a double click, to fix accidental navigation to other functions
Diffstat (limited to 'plugins/warp/ui/shared/fetcher.cpp')
-rw-r--r--plugins/warp/ui/shared/fetcher.cpp20
1 files changed, 13 insertions, 7 deletions
diff --git a/plugins/warp/ui/shared/fetcher.cpp b/plugins/warp/ui/shared/fetcher.cpp
index 1a262878..403d7cdb 100644
--- a/plugins/warp/ui/shared/fetcher.cpp
+++ b/plugins/warp/ui/shared/fetcher.cpp
@@ -24,14 +24,20 @@ std::vector<FunctionRef> WarpFetcher::FlushPendingFunctions()
void WarpFetcher::ExecuteCompletionCallback()
{
- BinaryNinja::ExecuteOnMainThread([this]() {
- // TODO: Holding the mutex here is dangerous!
+ std::vector<std::pair<CallbackId, CompletionCallback>> callbacks;
+ {
std::lock_guard<std::mutex> lock(m_requestMutex);
- m_completionCallbacks.erase(
- std::ranges::remove_if(m_completionCallbacks, [](const auto& cb) { return cb() == RemoveCallback; })
- .begin(),
- m_completionCallbacks.end());
- });
+ callbacks.insert(callbacks.end(), m_completionCallbacks.begin(), m_completionCallbacks.end());
+ }
+
+ std::vector<CallbackId> toRemove = {};
+ for (auto& [id, cb] : callbacks)
+ if (cb() == RemoveCallback)
+ toRemove.push_back(id);
+
+ std::lock_guard<std::mutex> lock(m_requestMutex);
+ for (auto id : toRemove)
+ m_completionCallbacks.erase(id);
}
std::shared_ptr<WarpFetcher> WarpFetcher::Global()