GCC Code Coverage Report


Directory: ./
File: service/main.cpp
Date: 2023-04-20 22:59:23
Exec Total Coverage
Lines: 0 16 0.0%
Branches: 0 6 0.0%

Line Branch Exec Source
1 /*
2 * Copyright (C) 2014 Daniel Vratil <dvratil@redhat.com>
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17 *
18 */
19 #include <QDBusConnection>
20 #include <QGuiApplication>
21 #include <QSessionManager>
22
23 #include "backendloader.h"
24 #include "disman_backend_launcher_debug.h"
25 #include "log.h"
26
27 #include <memory>
28
29 int main(int argc, char** argv)
30 {
31 Disman::Log::instance();
32 QGuiApplication::setDesktopSettingsAware(false);
33 QGuiApplication app(argc, argv);
34
35 auto disableSessionManagement
36 = [](QSessionManager& sm) { sm.setRestartHint(QSessionManager::RestartNever); };
37 QObject::connect(&app, &QGuiApplication::commitDataRequest, disableSessionManagement);
38 QObject::connect(&app, &QGuiApplication::saveStateRequest, disableSessionManagement);
39
40 if (!QDBusConnection::sessionBus().registerService(QStringLiteral("org.kwinft.disman"))) {
41 qCWarning(DISMAN_BACKEND_LAUNCHER)
42 << "Cannot register Disman service. Another launcher already running?";
43 return -1;
44 }
45
46 // The backend must be destroyed and unloaded while the QApplication object
47 // and its XCB connection still exist. This is guaranteed by the fact that
48 // local variables are destructed in the reverse order of construction.
49 auto loader = std::make_unique<BackendLoader>();
50 if (!loader->init()) {
51 return -2;
52 }
53
54 const int ret = app.exec();
55
56 return ret;
57 }
58