summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Rettberg2018-11-15 12:26:13 +0100
committerSimon Rettberg2018-11-15 12:26:13 +0100
commitb2ba47cde2cb63163831f013947fa1edb4a29c8b (patch)
treeb8d87bf88300431aeb133d6e52dc0be585a3e56e
parent[client] Stop projection on any key press (diff)
downloadpvs2-b2ba47cde2cb63163831f013947fa1edb4a29c8b.tar.gz
pvs2-b2ba47cde2cb63163831f013947fa1edb4a29c8b.tar.xz
pvs2-b2ba47cde2cb63163831f013947fa1edb4a29c8b.zip
[server] Fix adding/removing students to active projection
VNC server/client was not always properly started or stopped when adding/removing students to currently running projection with tutor as source.
-rw-r--r--src/server/mainwindow/mainwindow.cpp34
1 files changed, 25 insertions, 9 deletions
diff --git a/src/server/mainwindow/mainwindow.cpp b/src/server/mainwindow/mainwindow.cpp
index ec69a4c..0abfdff 100644
--- a/src/server/mainwindow/mainwindow.cpp
+++ b/src/server/mainwindow/mainwindow.cpp
@@ -893,22 +893,38 @@ void MainWindow::onButtonTutorToStudent()
else if (getTutorFrame()->client() == nullptr)
QMessageBox::critical(this, tr("Projection"), sStrTutorOffline);
else {
+ auto sourceClient = getTutorFrame()->client();
+ auto destinationClient = getSelectedFrame()->client();
// If this is the first call in this mode clear the watchers
if (_mode != Mode::Multicast) {
- for (QList<ConnectionFrame*>::iterator it(_clientFrames.begin()); it != _clientFrames.end(); ++it)
- if ((*it)->client() != nullptr)
- (*it)->client()->setDesiredProjectionSource(NO_SOURCE);
+ for (auto c : _clientFrames) {
+ if (c->client() != nullptr) {
+ c->client()->stopVncClient();
+ }
+ }
}
// If "to" already watches "from" stop it
- if (getSelectedFrame()->client()->desiredProjectionSource() == getTutorFrame()->client()->id() )
- getSelectedFrame()->client()->setDesiredProjectionSource(NO_SOURCE);
- else
- getSelectedFrame()->client()->setDesiredProjectionSource(getTutorFrame()->client()->id());
+ if (destinationClient->desiredProjectionSource() == sourceClient->id() ) {
+ destinationClient->stopVncClient();
+ } else {
+ destinationClient->setDesiredProjectionSource(sourceClient->id());
+ }
disableButtons();
- _mode = Mode::Multicast;
- startVncServerIfNecessary(getTutorFrame()->client()->id());
+ int numClients = 0;
+ for (auto c : _clientFrames) {
+ if (c->client() != nullptr && c->client()->desiredProjectionSource() == sourceClient->id()) {
+ numClients++;
+ }
+ }
+ if (numClients == 0) {
+ _mode = Mode::None;
+ sourceClient->stopVncServer();
+ } else {
+ _mode = Mode::Multicast;
+ startVncServerIfNecessary(sourceClient->id());
+ }
}
}