2
* Copyright (C) 2013 Canonical, Ltd.
4
* This program is free software: you can redistribute it and/or modify it under
5
* the terms of the GNU Lesser General Public License version 3, as published by
6
* the Free Software Foundation.
8
* This program is distributed in the hope that it will be useful, but WITHOUT
9
* ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
10
* SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11
* Lesser General Public License for more details.
13
* You should have received a copy of the GNU Lesser General Public License
14
* along with this program. If not, see <http://www.gnu.org/licenses/>.
19
#include <QCoreApplication>
23
#include "qmirserver.h"
26
QMirServer::QMirServer(const QSharedPointer<MirServerConfiguration> &config, QObject *parent)
28
, m_mirServer(new MirServerWorker(config))
30
m_mirServer->moveToThread(&m_mirThread);
32
connect(this, &QMirServer::run, m_mirServer, &MirServerWorker::run);
33
connect(this, &QMirServer::stop, m_mirServer, &MirServerWorker::stop);
35
connect(QCoreApplication::instance(), &QCoreApplication::aboutToQuit, this, &QMirServer::shutDownMirServer);
36
connect(m_mirServer, &MirServerWorker::stopped, this, &QMirServer::shutDownQApplication, Qt::DirectConnection); // since no event loop
38
m_mirThread.start(QThread::TimeCriticalPriority);
42
QMirServer::~QMirServer()
47
void QMirServer::shutDownMirServer()
49
if (m_mirThread.isRunning()) {
55
void QMirServer::shutDownQApplication()
57
if (m_mirThread.isRunning())
60
// if unexpected mir server stop, better quit the QApplication
61
if (!QCoreApplication::closingDown()) {
62
QCoreApplication::quit();