From e32402b5c62eca7862b7ff9d2d065272b2826478 Mon Sep 17 00:00:00 2001 From: XinyuHou Date: Thu, 1 Sep 2016 11:51:12 +0100 Subject: [PATCH] #4740 Moved clipboard transfering back into main thread on server --- src/lib/server/Server.cpp | 35 +++++------------------------------ src/lib/server/Server.h | 5 ----- 2 files changed, 5 insertions(+), 35 deletions(-) diff --git a/src/lib/server/Server.cpp b/src/lib/server/Server.cpp index 6135d1be..cdec86f4 100644 --- a/src/lib/server/Server.cpp +++ b/src/lib/server/Server.cpp @@ -93,8 +93,7 @@ Server::Server( m_ignoreFileTransfer(false), m_enableDragDrop(enableDragDrop), m_sendDragInfoThread(NULL), - m_waitDragInfoThread(true), - m_sendClipboardThread(NULL) + m_waitDragInfoThread(true) { // must have a primary client and it must have a canonical name assert(m_primaryClient != NULL); @@ -496,18 +495,6 @@ 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; @@ -518,13 +505,11 @@ Server::switchScreen(BaseClientProxy* dst, m_active->enter(x, y, m_seqNum, m_primaryClient->getToggleMask(), forScreensaver); - + // send the clipboard data to new active screen - m_sendClipboardThread = new Thread( - new TMethodJob( - this, - &Server::sendClipboardThread, - NULL)); + for (ClipboardID id = 0; id < kClipboardEnd; ++id) { + m_active->setClipboard(id, &m_clipboards[id].m_clipboard); + } Server::SwitchToScreenInfo* info = Server::SwitchToScreenInfo::alloc(m_active->getName()); @@ -1864,16 +1849,6 @@ Server::sendDragInfo(BaseClientProxy* newScreen) } } -void -Server::sendClipboardThread(void*) -{ - for (ClipboardID id = 0; id < kClipboardEnd; ++id) { - m_active->setClipboard(id, &m_clipboards[id].m_clipboard); - } - - m_sendClipboardThread = NULL; -} - void Server::onMouseMoveSecondary(SInt32 dx, SInt32 dy) { diff --git a/src/lib/server/Server.h b/src/lib/server/Server.h index 4defc7b2..610718c4 100644 --- a/src/lib/server/Server.h +++ b/src/lib/server/Server.h @@ -367,9 +367,6 @@ private: // send drag info to new client screen void sendDragInfo(BaseClientProxy* newScreen); - // thread funciton for sending clipboard - void sendClipboardThread(void*); - public: bool m_mock; @@ -481,6 +478,4 @@ private: bool m_waitDragInfoThread; ClientListener* m_clientListener; - - Thread* m_sendClipboardThread; };