diff --git a/src/lib/server/Server.cpp b/src/lib/server/Server.cpp index 1f3bf3b2..7e85e811 100644 --- a/src/lib/server/Server.cpp +++ b/src/lib/server/Server.cpp @@ -496,6 +496,18 @@ Server::switchScreen(BaseClientProxy* dst, } } + // if already sending clipboard, we need to interupt it, otherwise + // clipboard data could be corrupted on the other side + // interrupt before switch active, as send clipboard uses active + // client proxy, which would cause race condition + if (m_sendClipboardThread != NULL) { + StreamChunker::setClipboardInterrupt(true); + m_sendClipboardThread->wait(); + delete m_sendClipboardThread; + m_sendClipboardThread = NULL; + StreamChunker::setClipboardInterrupt(false); + } + // cut over m_active = dst; @@ -506,15 +518,6 @@ Server::switchScreen(BaseClientProxy* dst, m_active->enter(x, y, m_seqNum, m_primaryClient->getToggleMask(), forScreensaver); - // if already sending clipboard, we need to interupt it, otherwise - // clipboard data could be corrupted on the other side - if (m_sendClipboardThread != NULL) { - StreamChunker::setClipboardInterrupt(true); - m_sendClipboardThread->wait(); - delete m_sendClipboardThread; - m_sendClipboardThread = NULL; - StreamChunker::setClipboardInterrupt(false); - } // send the clipboard data to new active screen m_sendClipboardThread = new Thread(