summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndre Heinecke <aheinecke@intevation.de>2016-08-04 10:45:48 (GMT)
committerAndre Heinecke <aheinecke@intevation.de>2016-08-04 10:49:00 (GMT)
commit42ff7ff278ee2f03325eee4e09eaad0602b06c2b (patch)
tree4571112dc09ec9c10706d74cd2d10eed57e3b0af
parent36ff83c012335bfec009353c412e96ed38854f05 (diff)
Fix startup on UI-Server errors
This fixes the start when GPA is running. The try / catch block was way too large and included important initialisation code that was not run when the Server.start threw an exception. Also only show the error / selftest problem on Windows as it's not important currently for users of other platforms.
-rw-r--r--src/commands/selftestcommand.cpp8
-rw-r--r--src/main.cpp80
2 files changed, 44 insertions, 44 deletions
diff --git a/src/commands/selftestcommand.cpp b/src/commands/selftestcommand.cpp
index 50fc205..b92d4a3 100644
--- a/src/commands/selftestcommand.cpp
+++ b/src/commands/selftestcommand.cpp
@@ -138,6 +138,10 @@ private:
#if defined(Q_OS_WIN)
//Q_EMIT q->info( i18n("Checking Windows Registry...") );
tests.push_back(makeGpgProgramRegistryCheckSelfTest());
+#if defined(HAVE_KLEOPATRACLIENT_LIBRARY)
+ //Q_EMIT q->info( i18n("Checking Ui Server connectivity...") );
+ tests.push_back(makeUiServerConnectivitySelfTest());
+#endif
#endif
//Q_EMIT q->info( i18n("Checking gpg installation...") );
tests.push_back(makeGpgEngineCheckSelfTest());
@@ -149,10 +153,6 @@ private:
//Q_EMIT q->info( i18n("Checking %1 configuration...", components[i]) );
tests.push_back(makeGpgConfCheckConfigurationSelfTest(components[i]));
}
-#if defined( HAVE_KLEOPATRACLIENT_LIBRARY )
- //Q_EMIT q->info( i18n("Checking Ui Server connectivity...") );
- tests.push_back(makeUiServerConnectivitySelfTest());
-#endif
#ifndef Q_OS_WIN
tests.push_back(makeGpgAgentConnectivitySelfTest());
#endif
diff --git a/src/main.cpp b/src/main.cpp
index 24f3a85..9d83e89 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -180,9 +180,8 @@ int main(int argc, char **argv)
Kleo::ArchiveDefinition::setInstallPath(Kleo::gnupgInstallPath());
int rc;
+ Kleo::UiServer server(parser.value(QStringLiteral("uiserver-socket")));
try {
- Kleo::UiServer server(parser.value(QStringLiteral("uiserver-socket")));
-
qCDebug(KLEOPATRA_LOG) << "Startup timing:" << timer.elapsed() << "ms elapsed: UiServer created";
QObject::connect(&server, &Kleo::UiServer::startKeyManagerRequested, &app, &KleopatraApplication::openOrRaiseMainWindow);
@@ -212,52 +211,53 @@ int main(int argc, char **argv)
server.start();
qCDebug(KLEOPATRA_LOG) << "Startup timing:" << timer.elapsed() << "ms elapsed: UiServer started";
-
- const bool daemon = parser.isSet(QStringLiteral("daemon"));
- if (!daemon && app.isSessionRestored()) {
- app.restoreMainWindow();
- }
-
- if (!selfCheck()) {
- return EXIT_FAILURE;
- }
- qCDebug(KLEOPATRA_LOG) << "Startup timing:" << timer.elapsed() << "ms elapsed: SelfCheck completed";
-
- fillKeyCache(&server);
-#ifndef QT_NO_SYSTEMTRAYICON
- app.startMonitoringSmartCard();
-#endif
- app.setIgnoreNewInstance(false);
-
- if (!daemon) {
- const QString err = app.newInstance(parser);
- if (!err.isEmpty()) {
- std::cerr << i18n("Invalid arguments: %1", err).toLocal8Bit().constData() << "\n";
- return EXIT_FAILURE;
- }
- qCDebug(KLEOPATRA_LOG) << "Startup timing:" << timer.elapsed() << "ms elapsed: new instance created";
- }
-
- rc = app.exec();
-
- app.setIgnoreNewInstance(true);
- QObject::disconnect(&server, &Kleo::UiServer::startKeyManagerRequested, &app, &KleopatraApplication::openOrRaiseMainWindow);
- QObject::disconnect(&server, &Kleo::UiServer::startConfigDialogRequested, &app, &KleopatraApplication::openOrRaiseConfigDialog);
-
- server.stop();
- server.waitForStopped();
} catch (const std::exception &e) {
+ qCDebug(KLEOPATRA_LOG) << "Failed to start UI Server: " << e.what();
+#ifdef Q_OS_WIN
+ // Once there actually is a plugin for other systems then Windows this
+ // error should probably be shown, too. But currently only Windows users need
+ // to care.
QMessageBox::information(0, i18n("GPG UI Server Error"),
i18n("<qt>The Kleopatra GPG UI Server Module could not be initialized.<br/>"
"The error given was: <b>%1</b><br/>"
"You can use Kleopatra as a certificate manager, but cryptographic plugins that "
"rely on a GPG UI Server being present might not work correctly, or at all.</qt>",
QString::fromUtf8(e.what()).toHtmlEscaped()));
- app.startMonitoringSmartCard();
- app.setIgnoreNewInstance(false);
- rc = app.exec();
- app.setIgnoreNewInstance(true);
+#endif
}
+ const bool daemon = parser.isSet(QStringLiteral("daemon"));
+ if (!daemon && app.isSessionRestored()) {
+ app.restoreMainWindow();
+ }
+
+ if (!selfCheck()) {
+ return EXIT_FAILURE;
+ }
+ qCDebug(KLEOPATRA_LOG) << "Startup timing:" << timer.elapsed() << "ms elapsed: SelfCheck completed";
+
+ fillKeyCache(&server);
+#ifndef QT_NO_SYSTEMTRAYICON
+ app.startMonitoringSmartCard();
+#endif
+ app.setIgnoreNewInstance(false);
+
+ if (!daemon) {
+ const QString err = app.newInstance(parser);
+ if (!err.isEmpty()) {
+ std::cerr << i18n("Invalid arguments: %1", err).toLocal8Bit().constData() << "\n";
+ return EXIT_FAILURE;
+ }
+ qCDebug(KLEOPATRA_LOG) << "Startup timing:" << timer.elapsed() << "ms elapsed: new instance created";
+ }
+
+ rc = app.exec();
+
+ app.setIgnoreNewInstance(true);
+ QObject::disconnect(&server, &Kleo::UiServer::startKeyManagerRequested, &app, &KleopatraApplication::openOrRaiseMainWindow);
+ QObject::disconnect(&server, &Kleo::UiServer::startConfigDialogRequested, &app, &KleopatraApplication::openOrRaiseConfigDialog);
+
+ server.stop();
+ server.waitForStopped();
return rc;
}