From 865f9002dad49f24ef5584e82c198de3bca50e31 Mon Sep 17 00:00:00 2001 From: baldurk Date: Tue, 1 Sep 2020 11:08:01 +0100 Subject: [PATCH] Keep remote server connection alive if it disconnects mid-replay * We need to keep it alive until we've shut down the replay controller, and we keep that alive until the user explicitly closes the capture. --- qrenderdoc/Code/ReplayManager.cpp | 30 +++++++++++++++++++++++++----- qrenderdoc/Code/ReplayManager.h | 1 + 2 files changed, 26 insertions(+), 5 deletions(-) diff --git a/qrenderdoc/Code/ReplayManager.cpp b/qrenderdoc/Code/ReplayManager.cpp index 14dbf3d9a..b6b7ac96e 100644 --- a/qrenderdoc/Code/ReplayManager.cpp +++ b/qrenderdoc/Code/ReplayManager.cpp @@ -340,7 +340,16 @@ void ReplayManager::DisconnectFromRemoteServer() if(m_Remote) { QMutexLocker autolock(&m_RemoteLock); - m_Remote->ShutdownConnection(); + // give the remote to the thread to shut down since the lifetime is tied to the replay + // controller it has. + if(m_Thread->isRunning()) + { + m_OrphanedRemote = m_Remote; + } + else + { + m_Remote->ShutdownConnection(); + } } m_RemoteHost = RemoteHost(); @@ -515,11 +524,22 @@ void ReplayManager::run(int proxyRenderer, const QString &capturefile, const Rep } } - // close the core renderer - if(m_Remote) - m_Remote->CloseCapture(m_Renderer); + // if the remote has been orphaned due to disconnection during replay, close the capture using it + // and then shut it down. + if(m_OrphanedRemote) + { + m_OrphanedRemote->CloseCapture(m_Renderer); + m_OrphanedRemote->ShutdownConnection(); + m_OrphanedRemote = NULL; + } else - m_Renderer->Shutdown(); + { + // close the core renderer + if(m_Remote) + m_Remote->CloseCapture(m_Renderer); + else + m_Renderer->Shutdown(); + } m_Renderer = NULL; diff --git a/qrenderdoc/Code/ReplayManager.h b/qrenderdoc/Code/ReplayManager.h index 3755d035e..0c89b7ab3 100644 --- a/qrenderdoc/Code/ReplayManager.h +++ b/qrenderdoc/Code/ReplayManager.h @@ -132,6 +132,7 @@ private: QMutex m_RemoteLock; RemoteHost m_RemoteHost; IRemoteServer *m_Remote = NULL; + IRemoteServer *m_OrphanedRemote = NULL; volatile bool m_Running; LambdaThread *m_Thread;