summaryrefslogtreecommitdiffstats
path: root/src/server/mainwindow/mainwindow.cpp
diff options
context:
space:
mode:
authorBjörn Hagemeister2014-06-05 18:45:50 +0200
committerBjörn Hagemeister2014-06-05 18:45:50 +0200
commitccc1b7e667ceaaeb878ffaa728245c3268c5cf73 (patch)
tree4747e14b2d9d80f301e32cfbfcd31d95a5503ba7 /src/server/mainwindow/mainwindow.cpp
parentMerge branch 'master' of git.openslx.org:pvs2 (diff)
downloadpvs2-ccc1b7e667ceaaeb878ffaa728245c3268c5cf73.tar.gz
pvs2-ccc1b7e667ceaaeb878ffaa728245c3268c5cf73.tar.xz
pvs2-ccc1b7e667ceaaeb878ffaa728245c3268c5cf73.zip
Fixed SegFauls by setting _streamingSource to integer and just using the clients id, instead of real pointers.
Diffstat (limited to 'src/server/mainwindow/mainwindow.cpp')
-rw-r--r--src/server/mainwindow/mainwindow.cpp74
1 files changed, 44 insertions, 30 deletions
diff --git a/src/server/mainwindow/mainwindow.cpp b/src/server/mainwindow/mainwindow.cpp
index a6c90c0..6ac7422 100644
--- a/src/server/mainwindow/mainwindow.cpp
+++ b/src/server/mainwindow/mainwindow.cpp
@@ -57,7 +57,7 @@ MainWindow::MainWindow(QString ipListUrl, QWidget* parent) :
_tutorFrame = NULL;
_selectedFrame = NULL;
_mode = Mode::Multicast;
- _streamingSource = NULL;
+ _streamingSource = 0;
_sessionNameWindow = new SessionNameWindow(this);
_helpWindow = new HelpWindow(this);
@@ -266,10 +266,14 @@ void MainWindow::tellClientCurrentSituation(Client* client)
if (_mode == Mode::Broadcast){
// _watchers.insert(client->id(), client);
client->setWatcher(true);
- client->startVncClient(_streamingSource);
+ Client* c = getClientFromId(_streamingSource);
+ if (c != NULL) {
+ client->startVncClient(c);
+ }
}
else if (_mode == Mode::LockedMulticast)
client->lockScreen(true);
+
}
/***************************************************************************//**
@@ -384,8 +388,8 @@ void MainWindow::reset()
(*it)->client()->lockScreen(false);
// Stop server (Clients get stopped on ACK)
- if (_streamingSource != NULL)
- _streamingSource->stopVncServer();
+ if (getClientFromId(_streamingSource) != NULL)
+ getClientFromId(_streamingSource)->stopVncServer();
}
/*
@@ -489,7 +493,7 @@ void MainWindow::changeProjection(Client *from, Mode mode, Client *to)
// Set all clients as watchers
for (QList<ConnectionFrame*>::iterator it(_clientFrames.begin()); it != _clientFrames.end(); ++it)
{
- if ((*it)->client() != NULL && (*it)->client() != _streamingSource)
+ if ((*it)->client() != NULL && (*it)->client() != getClientFromId(_streamingSource))
{
// _watchers.insert((*it)->client()->id(), (*it)->client());
(*it)->client()->setWatcher(true);
@@ -528,17 +532,20 @@ void MainWindow::changeProjection(Client *from, Mode mode, Client *to)
_mode = mode;
// if there is a server running which is not "from" stop it.
- if (_streamingSource != NULL && _streamingSource != from)
- _streamingSource->stopVncServer();
+ if (getClientFromId(_streamingSource) != NULL && getClientFromId(_streamingSource) != from)
+ getClientFromId(_streamingSource)->stopVncServer();
// Set new streaming source
- _streamingSource = from;
+ _streamingSource = from->id();
// If streaming source is already active avoid a restart
- if (_streamingSource->isActiveVncServer())
- this->onVncServerStateChange(_streamingSource);
- else // Could not take shortcut, (re)start VNC server on source
- _streamingSource->startVncServer();
+ Client* c = getClientFromId(_streamingSource);
+ if (c != NULL) {
+ if (c->isActiveVncServer())
+ this->onVncServerStateChange(c);
+ else // Could not take shortcut, (re)start VNC server on source
+ c->startVncServer();
+ }
}
/***************************************************************************//**
@@ -882,7 +889,7 @@ void MainWindow::onClientAuthenticated(Client* client)
*/
void MainWindow::onVncServerStateChange(Client* client)
{
- if (client == _streamingSource)
+ if (client == getClientFromId(_streamingSource))
EnableButtons();
if (client->isActiveVncServer())
@@ -910,7 +917,7 @@ void MainWindow::onVncServerStateChange(Client* client)
if ( (*it)->client() != NULL)
{
// if (_watchers.contains((*it)->client()->id()))
- if (getClientFromId((*it)->client()->id())->isWatcher())
+ if ((*it)->client()->isWatcher())
{
// Unlock destination and connect VNCclient
(*it)->client()->lockScreen(false);
@@ -957,25 +964,32 @@ void MainWindow::onVncServerStateChange(Client* client)
*/
void MainWindow::onVncClientStateChange(Client* client)
{
- // VNC Client stopped -> remove from watchers
- if (!client->isActiveVncClient()){
- // _watchers.remove(client->id());
- getClientFromId(client->id())->setWatcher(false);
-
- // If noboody is watching the multicast stop VNC server
- // if (_watchers.isEmpty() && _mode != Mode::Broadcast)
- // _streamingSource->stopVncServer();
- bool noWatchers = true;
- for (QList<ConnectionFrame*>::iterator it(_clientFrames.begin()); it != _clientFrames.end(); ++it)
- {
- if ((*it)->client() != NULL)
+ if (client != NULL)
+ {
+ // VNC Client stopped -> remove from watchers
+ if (!client->isActiveVncClient()){
+ // _watchers.remove(client->id());
+ getClientFromId(client->id())->setWatcher(false);
+
+ // If noboody is watching the multicast stop VNC server
+ // if (_watchers.isEmpty() && _mode != Mode::Broadcast)
+ // _streamingSource->stopVncServer();
+ bool noWatchers = true;
+ for (QList<ConnectionFrame*>::iterator it(_clientFrames.begin()); it != _clientFrames.end(); ++it)
{
- if ((*it)->client()->isWatcher())
- noWatchers = false;
+ 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 (noWatchers && _mode != Mode::Broadcast)
- _streamingSource->stopVncServer();
}
}