diff options
Diffstat (limited to 'src/tools')
-rw-r--r-- | src/tools/appman/appman.cpp | 33 | ||||
-rw-r--r-- | src/tools/launcher-qml/launcher-qml.cpp | 10 |
2 files changed, 24 insertions, 19 deletions
diff --git a/src/tools/appman/appman.cpp b/src/tools/appman/appman.cpp index 06cc3ce6..02f32424 100644 --- a/src/tools/appman/appman.cpp +++ b/src/tools/appman/appman.cpp @@ -46,26 +46,31 @@ Q_DECL_EXPORT int main(int argc, char *argv[]) QCoreApplication::setOrganizationDomain(u"qt-project.org"_s); QCoreApplication::setApplicationVersion(QString::fromLatin1(QT_AM_VERSION_STR)); - try { - Main a(argc, argv, Main::InitFlag::ForkSudoServer | Main::InitFlag::InitializeLogging); - - Configuration cfg(additionalDescription, onlyOnePositionalArgument); - cfg.parseWithArguments(QCoreApplication::arguments()); + std::unique_ptr<Main> a; + std::unique_ptr<Configuration> cfg; -#if defined(AM_TESTRUNNER) - TestRunner::setup(&cfg); -#endif - a.setup(&cfg); - a.loadQml(cfg.loadDummyData()); - a.showWindow(cfg.fullscreen() && !cfg.noFullscreen()); + try { + a = std::make_unique<Main>(argc, argv, Main::InitFlag::ForkSudoServer + | Main::InitFlag::InitializeLogging); + cfg = std::make_unique<Configuration>(additionalDescription, onlyOnePositionalArgument); + cfg->parseWithArguments(QCoreApplication::arguments()); #if defined(AM_TESTRUNNER) - return TestRunner::exec(a.qmlEngine()); -#else - return Main::exec(); + TestRunner::setup(cfg.get()); #endif + a->setup(cfg.get()); + a->loadQml(cfg->loadDummyData()); + a->showWindow(cfg->fullscreen() && !cfg->noFullscreen()); } catch (const Exception &e) { qCCritical(LogSystem).noquote() << "ERROR:" << e.errorString(); return 2; } + + // we want the exec() outside of the try/catch block, so stray user exceptions trigger the + // CrashHandler's set_terminate callback. +#if defined(AM_TESTRUNNER) + return TestRunner::exec(a->qmlEngine()); +#else + return Main::exec(); +#endif } diff --git a/src/tools/launcher-qml/launcher-qml.cpp b/src/tools/launcher-qml/launcher-qml.cpp index c0953385..55b2a945 100644 --- a/src/tools/launcher-qml/launcher-qml.cpp +++ b/src/tools/launcher-qml/launcher-qml.cpp @@ -82,6 +82,7 @@ int main(int argc, char *argv[]) Logging::initialize(); std::unique_ptr<ApplicationMain> am; + std::unique_ptr<Controller> controller; // this needs to die BEFORE qApp does try { const QString socket = QDir(qEnvironmentVariable("XDG_RUNTIME_DIR")) @@ -116,8 +117,6 @@ int main(int argc, char *argv[]) StartupTimer::instance()->checkpoint("after basic initialization"); - std::unique_ptr<Controller> controller; // this needs to die BEFORE qApp does - if (!directLoadManifest.isEmpty()) { QString directLoadAppId; qsizetype appPos = directLoadManifest.indexOf(u"@"_s); @@ -136,13 +135,14 @@ int main(int argc, char *argv[]) StartupTimer::instance()->checkpoint("after dbus initialization"); controller.reset(new Controller(am.get(), quicklaunched)); } - - return am->exec(); - } catch (const std::exception &e) { qCCritical(LogQmlRuntime) << "ERROR:" << e.what(); return 2; } + + // we want the exec() outside of the try/catch block, so stray user exceptions trigger the + // CrashHandler's set_terminate callback. + return ApplicationMainBase::exec(); } Controller::Controller(ApplicationMain *am, bool quickLaunched) |