From 10b82e6255251e22d106d7df0f5df3812cc76f86 Mon Sep 17 00:00:00 2001 From: baldurk Date: Fri, 13 Jul 2018 13:05:32 +0100 Subject: [PATCH] Fix possible race condition with capture loading * The event browser called SetEventID from OnCaptureLoaded, which would then call OnEventChanged on all viewers, which if they kicked off work could happen at the same time as the later call to OpCaptureLoaded for them. * In the mesh viewer this seemed to lead to a race condition and had a chance to corrupt memory. --- qrenderdoc/Code/CaptureContext.cpp | 7 +++++-- qrenderdoc/Windows/EventBrowser.cpp | 2 -- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/qrenderdoc/Code/CaptureContext.cpp b/qrenderdoc/Code/CaptureContext.cpp index 629b2fe8d..d0217f095 100644 --- a/qrenderdoc/Code/CaptureContext.cpp +++ b/qrenderdoc/Code/CaptureContext.cpp @@ -194,9 +194,9 @@ void CaptureContext::LoadCapture(const rdcstr &captureFile, const rdcstr &origFi // make sure we're on a consistent event before invoking viewer forms if(m_LastDrawcall) - SetEventID(viewers, m_LastDrawcall->eventId, true); + SetEventID(viewers, m_LastDrawcall->eventId, m_LastDrawcall->eventId, true); else if(!m_Drawcalls->empty()) - SetEventID(viewers, m_Drawcalls->back().eventId, true); + SetEventID(viewers, m_Drawcalls->back().eventId, m_Drawcalls->back().eventId, true); GUIInvoke::blockcall(m_MainWindow, [&viewers]() { // notify all the registers viewers that a capture has been loaded @@ -213,6 +213,9 @@ void CaptureContext::LoadCapture(const rdcstr &captureFile, const rdcstr &origFi ShowCommentView(); RaiseDockWindow(GetCommentView()->Widget()); } + + // refresh the UI without forcing the replay + SetEventID({}, m_SelectedEventID, m_EventID, false); } } diff --git a/qrenderdoc/Windows/EventBrowser.cpp b/qrenderdoc/Windows/EventBrowser.cpp index 48d29f8ce..7ff93c91f 100644 --- a/qrenderdoc/Windows/EventBrowser.cpp +++ b/qrenderdoc/Windows/EventBrowser.cpp @@ -252,8 +252,6 @@ void EventBrowser::OnCaptureLoaded() ui->exportDraws->setEnabled(true); ui->stepPrev->setEnabled(true); ui->stepNext->setEnabled(true); - - m_Ctx.SetEventID({this}, lastEIDDraw.first, lastEIDDraw.first); } void EventBrowser::OnCaptureClosed()