diff options
| author | TryTwo <taolas@gmail.com> | 2024-06-24 14:18:41 -0700 |
|---|---|---|
| committer | TryTwo <taolas@gmail.com> | 2025-01-19 23:18:38 -0700 |
| commit | 32e135e6a94de9aba7e08ef0b32fac35f4647ab3 (patch) | |
| tree | 31124b80643cb9d91d2eead5f4c5aad8865a0312 /Source/Core/DolphinQt/Debugger/MemoryViewWidget.cpp | |
| parent | 3edb5acccab983b08a181356c75177a635ad3c0b (diff) | |
MemoryViewWidget: Add OnFrameEnd callback to auto-update memory while a game is running.
Diffstat (limited to 'Source/Core/DolphinQt/Debugger/MemoryViewWidget.cpp')
| -rw-r--r-- | Source/Core/DolphinQt/Debugger/MemoryViewWidget.cpp | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/Source/Core/DolphinQt/Debugger/MemoryViewWidget.cpp b/Source/Core/DolphinQt/Debugger/MemoryViewWidget.cpp index abe179e96e..9928632273 100644 --- a/Source/Core/DolphinQt/Debugger/MemoryViewWidget.cpp +++ b/Source/Core/DolphinQt/Debugger/MemoryViewWidget.cpp @@ -311,7 +311,12 @@ constexpr int GetCharacterCount(MemoryViewWidget::Type type) void MemoryViewWidget::UpdateDispatcher(UpdateType type) { - if (!isVisible()) + std::unique_lock lock(m_updating, std::defer_lock); + + // A full update may change parameters like row count, so make sure it goes through. + if (type == UpdateType::Full) + lock.lock(); + else if (!isVisible() || !lock.try_lock()) return; // Check if table needs to be created. @@ -331,6 +336,10 @@ void MemoryViewWidget::UpdateDispatcher(UpdateType type) GetValues(); UpdateColumns(); break; + case UpdateType::Auto: + // Values were captured on CPU thread while doing a callback. + if (m_values.size() != 0) + UpdateColumns(); default: break; } @@ -522,6 +531,18 @@ void MemoryViewWidget::UpdateColumns() } } +// Always runs on CPU thread from a callback. +void MemoryViewWidget::UpdateOnFrameEnd() +{ + std::unique_lock lock(m_updating, std::try_to_lock); + if (lock) + { + GetValues(); + // Should not directly trigger widget updates on a cpu thread. Signal main thread to do it. + emit AutoUpdate(); + } +} + void MemoryViewWidget::GetValues() { m_values.clear(); |
