From 253fd4ad2d8095cc3c640c99d75ab3fd1cb7282e Mon Sep 17 00:00:00 2001 From: Mason Reed Date: Sun, 12 Oct 2025 22:48:41 -0400 Subject: [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 --- plugins/warp/ui/shared/fetcher.h | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) (limited to 'plugins/warp/ui/shared/fetcher.h') diff --git a/plugins/warp/ui/shared/fetcher.h b/plugins/warp/ui/shared/fetcher.h index 52d0a0e2..3464ecd4 100644 --- a/plugins/warp/ui/shared/fetcher.h +++ b/plugins/warp/ui/shared/fetcher.h @@ -24,11 +24,10 @@ class WarpFetcher std::mutex m_requestMutex; std::vector m_pendingRequests; std::unordered_set m_processedGuids; - - // List of callbacks to call when done fetching data, assume that others are using this as well. - std::vector> m_completionCallbacks; - public: + using CallbackId = uint64_t; + using CompletionCallback = std::function; + explicit WarpFetcher(); // The global fetcher instance, this is used for the fetch dialog and the sidebar. @@ -36,10 +35,18 @@ public: std::atomic m_requestInProgress = false; - void AddCompletionCallback(std::function cb) + [[nodiscard]] CallbackId AddCompletionCallback(CompletionCallback cb) { std::lock_guard lock(m_requestMutex); - m_completionCallbacks.push_back(std::move(cb)); + const CallbackId id = m_nextCallbackId++; + m_completionCallbacks.emplace(id, std::move(cb)); + return id; + } + + void RemoveCompletionCallback(CallbackId id) + { + std::lock_guard lock(m_requestMutex); + m_completionCallbacks.erase(id); } void AddPendingFunction(const FunctionRef& func); @@ -49,7 +56,10 @@ public: void ClearProcessed(); private: - std::vector FlushPendingFunctions(); - + // List of callbacks to call when done fetching data, assume that others are using this as well. + std::atomic m_nextCallbackId = 1; + std::unordered_map m_completionCallbacks; void ExecuteCompletionCallback(); + + std::vector FlushPendingFunctions(); }; -- cgit v1.3.1