Changeset View
Changeset View
Standalone View
Standalone View
shell/main.cpp
Show First 20 Lines • Show All 82 Lines • ▼ Show 20 Line(s) | 81 | KAboutData aboutData(QStringLiteral("plasmashell"), | |||
---|---|---|---|---|---|
83 | QStringLiteral(PROJECT_VERSION), | 83 | QStringLiteral(PROJECT_VERSION), | ||
84 | i18n("Plasma Shell"), | 84 | i18n("Plasma Shell"), | ||
85 | KAboutLicense::GPL); | 85 | KAboutLicense::GPL); | ||
86 | 86 | | |||
87 | KAboutData::setApplicationData(aboutData); | 87 | KAboutData::setApplicationData(aboutData); | ||
88 | 88 | | |||
89 | app.setQuitOnLastWindowClosed(false); | 89 | app.setQuitOnLastWindowClosed(false); | ||
90 | 90 | | |||
91 | bool replace = false; | ||||
91 | { | 92 | { | ||
92 | QCommandLineParser cliOptions; | 93 | QCommandLineParser cliOptions; | ||
93 | 94 | | |||
94 | QCommandLineOption dbgOption(QStringList() << QStringLiteral("d") << | 95 | QCommandLineOption dbgOption(QStringList() << QStringLiteral("d") << | ||
95 | QStringLiteral("qmljsdebugger"), | 96 | QStringLiteral("qmljsdebugger"), | ||
96 | i18n("Enable QML Javascript debugger")); | 97 | i18n("Enable QML Javascript debugger")); | ||
97 | 98 | | |||
98 | QCommandLineOption noRespawnOption(QStringList() << QStringLiteral("n") << | 99 | QCommandLineOption noRespawnOption(QStringList() << QStringLiteral("n") << | ||
▲ Show 20 Lines • Show All 68 Lines • ▼ Show 20 Line(s) | 159 | if (cliOptions.isSet(standaloneOption)) { | |||
167 | } else { | 168 | } else { | ||
168 | cliOptions.showHelp(1); | 169 | cliOptions.showHelp(1); | ||
169 | } | 170 | } | ||
170 | } else { | 171 | } else { | ||
171 | // Tells libnotificationmanager that we're the only true application that may own notification and job progress services | 172 | // Tells libnotificationmanager that we're the only true application that may own notification and job progress services | ||
172 | qApp->setProperty("_plasma_dbus_master", true); | 173 | qApp->setProperty("_plasma_dbus_master", true); | ||
173 | } | 174 | } | ||
174 | 175 | | |||
175 | if (cliOptions.isSet(replaceOption)) { | | |||
176 | auto message = QDBusMessage::createMethodCall(QStringLiteral("org.kde.plasmashell"), | | |||
177 | QStringLiteral("/MainApplication"), | | |||
178 | QStringLiteral("org.qtproject.Qt.QCoreApplication"), | | |||
179 | QStringLiteral("quit")); | | |||
180 | auto reply = QDBusConnection::sessionBus().call(message); //deliberately block until it's done, so we register the name after the app quits | | |||
181 | | ||||
182 | while (QDBusConnection::sessionBus().interface()->isServiceRegistered(QStringLiteral("org.kde.plasmashell"))) { | | |||
183 | QCoreApplication::processEvents(QEventLoop::AllEvents); | | |||
184 | } | | |||
185 | } | | |||
186 | QObject::connect(corona, &ShellCorona::glInitializationFailed, &app, [&app]() { | 176 | QObject::connect(corona, &ShellCorona::glInitializationFailed, &app, [&app]() { | ||
187 | //scene graphs errors come from a thread | 177 | //scene graphs errors come from a thread | ||
188 | //even though we process them in the main thread, app.exit could still process these events | 178 | //even though we process them in the main thread, app.exit could still process these events | ||
189 | static bool s_multipleInvokations = false; | 179 | static bool s_multipleInvokations = false; | ||
190 | if (s_multipleInvokations) { | 180 | if (s_multipleInvokations) { | ||
191 | return; | 181 | return; | ||
192 | } | 182 | } | ||
193 | s_multipleInvokations = true; | 183 | s_multipleInvokations = true; | ||
194 | 184 | | |||
195 | qCritical("Open GL context could not be created"); | 185 | qCritical("Open GL context could not be created"); | ||
196 | auto configGroup = KSharedConfig::openConfig()->group("QtQuickRendererSettings"); | 186 | auto configGroup = KSharedConfig::openConfig()->group("QtQuickRendererSettings"); | ||
197 | if (configGroup.readEntry("SceneGraphBackend") != QLatin1String("software")) { | 187 | if (configGroup.readEntry("SceneGraphBackend") != QLatin1String("software")) { | ||
198 | configGroup.writeEntry("SceneGraphBackend", "software", KConfigBase::Global | KConfigBase::Persistent); | 188 | configGroup.writeEntry("SceneGraphBackend", "software", KConfigBase::Global | KConfigBase::Persistent); | ||
199 | configGroup.sync(); | 189 | configGroup.sync(); | ||
200 | QProcess::startDetached(QStringLiteral("plasmashell"), app.arguments()); | 190 | QProcess::startDetached(QStringLiteral("plasmashell"), app.arguments()); | ||
201 | } else { | 191 | } else { | ||
202 | QCoreApplication::setAttribute(Qt::AA_ForceRasterWidgets); | 192 | QCoreApplication::setAttribute(Qt::AA_ForceRasterWidgets); | ||
203 | QMessageBox::critical(nullptr, i18n("Plasma Failed To Start"), | 193 | QMessageBox::critical(nullptr, i18n("Plasma Failed To Start"), | ||
204 | i18n("Plasma is unable to start as it could not correctly use OpenGL 2 or software fallback\nPlease check that your graphic drivers are set up correctly.")); | 194 | i18n("Plasma is unable to start as it could not correctly use OpenGL 2 or software fallback\nPlease check that your graphic drivers are set up correctly.")); | ||
205 | } | 195 | } | ||
206 | app.exit(-1); | 196 | app.exit(-1); | ||
207 | }); | 197 | }); | ||
198 | replace = cliOptions.isSet(replaceOption); | ||||
208 | } | 199 | } | ||
209 | 200 | | |||
210 | KDBusService service(KDBusService::Unique); | 201 | KDBusService service(KDBusService::Unique | KDBusService::StartupOption(replace ? KDBusService::Replace : 0)); | ||
211 | 202 | | |||
212 | SoftwareRendererNotifier::notifyIfRelevant(); | 203 | SoftwareRendererNotifier::notifyIfRelevant(); | ||
213 | 204 | | |||
214 | return app.exec(); | 205 | return app.exec(); | ||
215 | } | 206 | } |