Hold worker data lock for the whole draw frame

This commit is contained in:
Bartosz Taudul
2026-08-01 12:24:17 +02:00
parent 95811a658a
commit 5698b45820
2 changed files with 2 additions and 4 deletions
+1 -1
View File
@@ -339,6 +339,7 @@ static_assert( sizeof( CompressionName ) == sizeof( CompressionDesc ), "Unmatche
bool View::Draw()
{
Worker::MainThreadDataLockGuard lock = m_worker.ObtainLockForMainThread();
HandshakeStatus status = (HandshakeStatus)m_worker.GetHandshakeStatus();
switch( status )
{
@@ -863,7 +864,6 @@ bool View::DrawImpl()
ImGui::EndPopup();
}
}
Worker::MainThreadDataLockGuard lock = m_worker.ObtainLockForMainThread();
auto& threadHints = m_worker.GetPendingThreadHints();
if( !threadHints.empty() )
{
@@ -79,7 +79,6 @@ bool View::DrawConnection()
FrameImage lastFrameImage{};
{
Worker::MainThreadDataLockGuard lock = m_worker.ObtainLockForMainThread();
ImGui::SameLine();
TextFocused( "+", RealToString( m_worker.GetSendInFlight() ) );
const auto sz = m_worker.GetFrameCount( *m_frames );
@@ -94,7 +93,7 @@ bool View::DrawConnection()
TextFocused( "Frame time:", TimeToString( dt ) );
}
const auto& fis = m_worker.GetFrameImages();
// Keep a copy here since the worker may modify the frame images vector while we do not own the lock
// Keep a copy so the frame image data is retained independently of the worker storage.
if( !fis.empty() ) lastFrameImage = *fis.back();
}
@@ -130,7 +129,6 @@ bool View::DrawConnection()
ImGui::SameLine( 0, 2 * ty );
const char* stopStr = ICON_FA_PLUG " Stop";
Worker::MainThreadDataLockGuard lock = m_worker.ObtainLockForMainThread();
if( !m_disconnectIssued && m_worker.IsConnected() )
{
if( ImGui::Button( stopStr ) )