diff --git a/src/coreservices.cpp b/src/coreservices.cpp index 36d1c0725c7..6269c33e1bc 100644 --- a/src/coreservices.cpp +++ b/src/coreservices.cpp @@ -103,10 +103,23 @@ inline QLocale inputLocale() { namespace mixxx { -CoreServices::CoreServices(const CmdlineArgs& args) +CoreServices::CoreServices(const CmdlineArgs& args, QApplication* pApp) : m_runtime_timer(QLatin1String("CoreServices::runtime")), m_cmdlineArgs(args) { + m_runtime_timer.start(); + mixxx::Time::start(); + ScopedTimer t("CoreServices::CoreServices"); + // All this here is running without without start up screen + // Defere long initialisations to CoreServices::initialize() which is + // called after the GUI is initalized initializeSettings(); + initializeLogging(); + // Only record stats in developer mode. + if (m_cmdlineArgs.getDeveloper()) { + StatsManager::createInstance(); + } + mixxx::Translations::initializeTranslations( + m_pSettingsManager->settings(), pApp, m_cmdlineArgs.getLocale()); initializeKeyboard(); } @@ -128,11 +141,7 @@ void CoreServices::initializeSettings() { m_pSettingsManager = std::make_unique(settingsPath); } -void CoreServices::initialize(QApplication* pApp) { - m_runtime_timer.start(); - mixxx::Time::start(); - ScopedTimer t("CoreServices::initialize"); - +void CoreServices::initializeLogging() { mixxx::LogFlags logFlags = mixxx::LogFlag::LogToFile; if (m_cmdlineArgs.getDebugAssertBreak()) { logFlags.setFlag(mixxx::LogFlag::DebugAssertBreak); @@ -142,6 +151,10 @@ void CoreServices::initialize(QApplication* pApp) { m_cmdlineArgs.getLogLevel(), m_cmdlineArgs.getLogFlushLevel(), logFlags); +} + +void CoreServices::initialize(QApplication* pApp) { + ScopedTimer t("CoreServices::initialize"); VERIFY_OR_DEBUG_ASSERT(SoundSourceProxy::registerProviders()) { qCritical() << "Failed to register any SoundSource providers"; @@ -150,16 +163,6 @@ void CoreServices::initialize(QApplication* pApp) { VersionStore::logBuildDetails(); - // Only record stats in developer mode. - if (m_cmdlineArgs.getDeveloper()) { - StatsManager::createInstance(); - } - - initializeKeyboard(); - - mixxx::Translations::initializeTranslations( - m_pSettingsManager->settings(), pApp, m_cmdlineArgs.getLocale()); - #if defined(Q_OS_LINUX) // XESetWireToError will segfault if running as a Wayland client if (pApp->platformName() == QLatin1String("xcb")) { @@ -167,6 +170,8 @@ void CoreServices::initialize(QApplication* pApp) { XESetWireToError(QX11Info::display(), i, &__xErrorHandler); } } +#else + Q_UNUSED(pApp); #endif UserSettingsPointer pConfig = m_pSettingsManager->settings(); diff --git a/src/coreservices.h b/src/coreservices.h index d1447e3d407..e69da355c6c 100644 --- a/src/coreservices.h +++ b/src/coreservices.h @@ -37,9 +37,10 @@ class CoreServices : public QObject { Q_OBJECT public: - CoreServices(const CmdlineArgs& args); + CoreServices(const CmdlineArgs& args, QApplication* pApp); ~CoreServices(); + /// The secondary long run which should be called after displaying the start up screen void initialize(QApplication* pApp); void shutdown(); @@ -119,6 +120,8 @@ class CoreServices : public QObject { bool initializeDatabase(); void initializeKeyboard(); void initializeSettings(); + void initializeScreensaverManager(); + void initializeLogging(); std::shared_ptr m_pSettingsManager; std::shared_ptr m_pControlIndicatorTimer; diff --git a/src/main.cpp b/src/main.cpp index c29eb564d20..8684b3dce19 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -22,17 +22,17 @@ namespace { constexpr int kFatalErrorOnStartupExitCode = 1; constexpr int kParseCmdlineArgsErrorExitCode = 2; -int runMixxx(MixxxApplication* app, const CmdlineArgs& args) { - const auto pCoreServices = std::make_shared(args); +int runMixxx(MixxxApplication* pApp, const CmdlineArgs& args) { + const auto pCoreServices = std::make_shared(args, pApp); - MixxxMainWindow mainWindow(app, pCoreServices); - app->installEventFilter(&mainWindow); + MixxxMainWindow mainWindow(pApp, pCoreServices); + pApp->installEventFilter(&mainWindow); QObject::connect(pCoreServices.get(), &mixxx::CoreServices::initializationProgressUpdate, &mainWindow, &MixxxMainWindow::initializationProgressUpdate); - pCoreServices->initialize(app); + pCoreServices->initialize(pApp); mainWindow.initialize(); // If startup produced a fatal error, then don't even start the @@ -44,7 +44,7 @@ int runMixxx(MixxxApplication* app, const CmdlineArgs& args) { mainWindow.show(); qDebug() << "Running Mixxx"; - return app->exec(); + return pApp->exec(); } } diff --git a/src/test/coreservicestest.cpp b/src/test/coreservicestest.cpp index cf4971056e1..5e318124c91 100644 --- a/src/test/coreservicestest.cpp +++ b/src/test/coreservicestest.cpp @@ -17,7 +17,7 @@ TEST_F(CoreServicesTest, DISABLED_TestInitialization) { char* argv[] = {progName, safeMode}; cmdlineArgs.parse(argc, argv); - const auto pCoreServices = std::make_unique(cmdlineArgs); + const auto pCoreServices = std::make_unique(cmdlineArgs, application()); pCoreServices->initialize(application()); EXPECT_NE(pCoreServices->getControllerManager(), nullptr);