From da49924c228ea71abd3f71fa94737953dd763b53 Mon Sep 17 00:00:00 2001 From: Manuel Schneider Date: Mon, 21 Jul 2014 23:37:48 +0200 Subject: Finally implemented one click projectionsource change Prevent the new projectionsource from beeing killed by stop clients wrt the connections --- src/server/mainwindow/mainwindow.cpp | 47 ++++++++++++++++++++++-------------- 1 file changed, 29 insertions(+), 18 deletions(-) (limited to 'src/server/mainwindow/mainwindow.cpp') diff --git a/src/server/mainwindow/mainwindow.cpp b/src/server/mainwindow/mainwindow.cpp index c78f8de..9dee65b 100644 --- a/src/server/mainwindow/mainwindow.cpp +++ b/src/server/mainwindow/mainwindow.cpp @@ -1117,29 +1117,40 @@ void MainWindow::onVncServerStateChange(Client* client) */ void MainWindow::onVncClientStateChange(Client* client) { - if (client != NULL) + if (client != NULL) { // VNC Client stopped -> remove from watchers - if (!client->isActiveVncClient()){ - // _watchers.remove(client->id()); + if (!client->isActiveVncClient()){ if (getClientFromId(client->id()) != NULL) getClientFromId(client->id())->setWatcher(false); - // If noboody is watching the multicast stop VNC server - bool noWatchers = true; - for (QList::iterator it(_clientFrames.begin()); it != _clientFrames.end(); ++it) - { - if ((*it)->client() != NULL) - { - if ((*it)->client()->isWatcher()) - noWatchers = false; - } - } - if (noWatchers && _mode != Mode::Broadcast) - { - Client* c = getClientFromId(_streamingSource); - if (c != NULL) - c->stopVncServer(); + /* + * If noboody is watching the multicast stop VNC server + * If the past connection of this client is not the current + * _streamingSource then the manager has to have stopped it + * already. This is necessary for the race condition when a server + * is stopped and another started at the same time, since the new + * server would be killed if all client disconnect before any of + * the new connect. + */ + if (client->projectionSource() == _streamingSource) + { + bool noWatchers = true; + for (QList::iterator it(_clientFrames.begin()); + it != _clientFrames.end(); ++it) + { + if ((*it)->client() != NULL) + { + if ((*it)->client()->isWatcher()) + noWatchers = false; + } + } + if (noWatchers && _mode != Mode::Broadcast) + { + Client* c = getClientFromId(_streamingSource); + if (c != NULL) + c->stopVncServer(); + } } } } -- cgit v1.2.3-55-g7522