From e8541a5c91928684ed9b70a118c85436ec426879 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Sch=C3=BCrmann?= Date: Mon, 5 Jul 2021 14:11:33 +0200 Subject: [PATCH 01/10] Fix uninitialized variable --- src/coreservices.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/coreservices.cpp b/src/coreservices.cpp index 0b8b43c595f..f9899bfe36a 100644 --- a/src/coreservices.cpp +++ b/src/coreservices.cpp @@ -102,7 +102,8 @@ inline QLocale inputLocale() { namespace mixxx { CoreServices::CoreServices(const CmdlineArgs& args) - : m_runtime_timer(QLatin1String("CoreServices::runtime")), + : m_pLV2Backend(nullptr), + m_runtime_timer(QLatin1String("CoreServices::runtime")), m_cmdlineArgs(args) { } From ef2bcd14afc4671166a4f2a95feca1e78c3f1cf5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Sch=C3=BCrmann?= Date: Mon, 5 Jul 2021 14:21:32 +0200 Subject: [PATCH 02/10] Add function preInitialize() to CoreServices --- src/coreservices.cpp | 6 ++++++ src/coreservices.h | 5 ++++- src/mixxx.cpp | 3 +-- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/coreservices.cpp b/src/coreservices.cpp index f9899bfe36a..9dc79d3da38 100644 --- a/src/coreservices.cpp +++ b/src/coreservices.cpp @@ -123,6 +123,12 @@ void CoreServices::initializeSettings() { m_pSettingsManager = std::make_unique(settingsPath); } +void CoreServices::preInitialize() { + ScopedTimer t("CoreServices::preInitialize"); + initializeSettings(); + initializeKeyboard(); +} + void CoreServices::initialize(QApplication* pApp) { m_runtime_timer.start(); mixxx::Time::start(); diff --git a/src/coreservices.h b/src/coreservices.h index d9f94288123..110b482713d 100644 --- a/src/coreservices.h +++ b/src/coreservices.h @@ -37,8 +37,11 @@ class CoreServices : public QObject { ~CoreServices() = default; void initializeSettings(); - // FIXME: should be private, but WMainMenuBar needs it initialized early void initializeKeyboard(); + + // The short first run that is done without start up screen + void preInitialize(); + // The secondary long run which should be called after displaying the start up screen void initialize(QApplication* pApp); void shutdown(); diff --git a/src/mixxx.cpp b/src/mixxx.cpp index 351e972979f..8bc4802aeba 100644 --- a/src/mixxx.cpp +++ b/src/mixxx.cpp @@ -104,8 +104,7 @@ MixxxMainWindow::MixxxMainWindow( m_toolTipsCfg(mixxx::TooltipsPreference::TOOLTIPS_ON) { DEBUG_ASSERT(pApp); DEBUG_ASSERT(pCoreServices); - m_pCoreServices->initializeSettings(); - m_pCoreServices->initializeKeyboard(); + m_pCoreServices->preInitialize(); // These depend on the settings createMenuBar(); m_pMenuBar->hide(); From 4ffe39ccf1299749588c2ff7881720701d4564a8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Sch=C3=BCrmann?= Date: Mon, 5 Jul 2021 14:51:31 +0200 Subject: [PATCH 03/10] Move Stats and translation init to peInitialize(). with a duration 5 ms, compared to 500 ms for initalize(). --- src/coreservices.cpp | 40 ++++++++++++++++++++-------------------- src/coreservices.h | 3 ++- src/mixxx.cpp | 2 +- 3 files changed, 23 insertions(+), 22 deletions(-) diff --git a/src/coreservices.cpp b/src/coreservices.cpp index 9dc79d3da38..182525c68a1 100644 --- a/src/coreservices.cpp +++ b/src/coreservices.cpp @@ -123,17 +123,7 @@ void CoreServices::initializeSettings() { m_pSettingsManager = std::make_unique(settingsPath); } -void CoreServices::preInitialize() { - ScopedTimer t("CoreServices::preInitialize"); - initializeSettings(); - initializeKeyboard(); -} - -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); @@ -143,6 +133,25 @@ void CoreServices::initialize(QApplication* pApp) { m_cmdlineArgs.getLogLevel(), m_cmdlineArgs.getLogFlushLevel(), logFlags); +} + +void CoreServices::preInitialize(QApplication* pApp) { + ScopedTimer t("CoreServices::preInitialize"); + 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(); +} + +void CoreServices::initialize(QApplication* pApp) { + m_runtime_timer.start(); + mixxx::Time::start(); + ScopedTimer t("CoreServices::initialize"); VERIFY_OR_DEBUG_ASSERT(SoundSourceProxy::registerProviders()) { qCritical() << "Failed to register any SoundSource providers"; @@ -151,15 +160,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 diff --git a/src/coreservices.h b/src/coreservices.h index 110b482713d..84d160567f2 100644 --- a/src/coreservices.h +++ b/src/coreservices.h @@ -38,9 +38,10 @@ class CoreServices : public QObject { void initializeSettings(); void initializeKeyboard(); + void initializeLogging(); // The short first run that is done without start up screen - void preInitialize(); + void preInitialize(QApplication* pApp); // The secondary long run which should be called after displaying the start up screen void initialize(QApplication* pApp); void shutdown(); diff --git a/src/mixxx.cpp b/src/mixxx.cpp index 8bc4802aeba..c914d0dfdcf 100644 --- a/src/mixxx.cpp +++ b/src/mixxx.cpp @@ -104,7 +104,7 @@ MixxxMainWindow::MixxxMainWindow( m_toolTipsCfg(mixxx::TooltipsPreference::TOOLTIPS_ON) { DEBUG_ASSERT(pApp); DEBUG_ASSERT(pCoreServices); - m_pCoreServices->preInitialize(); + m_pCoreServices->preInitialize(pApp); // These depend on the settings createMenuBar(); m_pMenuBar->hide(); From 8a38e81a20b732dfc01cf950f270a7d6183611bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Sch=C3=BCrmann?= Date: Thu, 8 Jul 2021 17:13:09 +0200 Subject: [PATCH 04/10] Move initalizer to the header --- src/coreservices.cpp | 3 +-- src/coreservices.h | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/coreservices.cpp b/src/coreservices.cpp index 182525c68a1..e029e06374b 100644 --- a/src/coreservices.cpp +++ b/src/coreservices.cpp @@ -102,8 +102,7 @@ inline QLocale inputLocale() { namespace mixxx { CoreServices::CoreServices(const CmdlineArgs& args) - : m_pLV2Backend(nullptr), - m_runtime_timer(QLatin1String("CoreServices::runtime")), + : m_runtime_timer(QLatin1String("CoreServices::runtime")), m_cmdlineArgs(args) { } diff --git a/src/coreservices.h b/src/coreservices.h index 84d160567f2..84f5db20de3 100644 --- a/src/coreservices.h +++ b/src/coreservices.h @@ -116,7 +116,7 @@ class CoreServices : public QObject { std::shared_ptr m_pSettingsManager; std::shared_ptr m_pEffectsManager; // owned by EffectsManager - LV2Backend* m_pLV2Backend; + LV2Backend* m_pLV2Backend{}; std::shared_ptr m_pEngine; std::shared_ptr m_pSoundManager; std::shared_ptr m_pPlayerManager; From 419a3df4ed2305173cf62c54fe6a4c8e62b38af3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Sch=C3=BCrmann?= Date: Thu, 8 Jul 2021 17:22:15 +0200 Subject: [PATCH 05/10] Fix unused warning --- src/coreservices.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/coreservices.cpp b/src/coreservices.cpp index e029e06374b..18083cb8f13 100644 --- a/src/coreservices.cpp +++ b/src/coreservices.cpp @@ -167,6 +167,8 @@ void CoreServices::initialize(QApplication* pApp) { XESetWireToError(QX11Info::display(), i, &__xErrorHandler); } } +#else + Q_UNUSED(pApp); #endif UserSettingsPointer pConfig = m_pSettingsManager->settings(); From 434f6cf4adb124fea0cacab798d3304f29e0d2f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Sch=C3=BCrmann?= Date: Sun, 25 Jul 2021 13:10:15 +0200 Subject: [PATCH 06/10] move pCoreServices->preInitialize() to runMixxx --- src/main.cpp | 9 +++++---- src/mixxxmainwindow.cpp | 2 +- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 0840fd58c65..24fdcd38c36 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -22,9 +22,10 @@ namespace { constexpr int kFatalErrorOnStartupExitCode = 1; constexpr int kParseCmdlineArgsErrorExitCode = 2; -int runMixxx(MixxxApplication* app, const CmdlineArgs& args) { - auto coreServices = std::make_shared(args); - MixxxMainWindow mainWindow(app, coreServices); +int runMixxx(MixxxApplication* pApp, const CmdlineArgs& args) { + auto pCoreServices = std::make_shared(args); + pCoreServices->preInitialize(pApp); + MixxxMainWindow mainWindow(pApp, pCoreServices); // If startup produced a fatal error, then don't even start the // Qt event loop. if (ErrorDialogHandler::instance()->checkError()) { @@ -34,7 +35,7 @@ int runMixxx(MixxxApplication* app, const CmdlineArgs& args) { mainWindow.show(); qDebug() << "Running Mixxx"; - return app->exec(); + return pApp->exec(); } } diff --git a/src/mixxxmainwindow.cpp b/src/mixxxmainwindow.cpp index 349f39144a9..cfb0a74e27d 100644 --- a/src/mixxxmainwindow.cpp +++ b/src/mixxxmainwindow.cpp @@ -104,7 +104,7 @@ MixxxMainWindow::MixxxMainWindow( m_toolTipsCfg(mixxx::TooltipsPreference::TOOLTIPS_ON) { DEBUG_ASSERT(pApp); DEBUG_ASSERT(pCoreServices); - m_pCoreServices->preInitialize(pApp); + // These depend on the settings createMenuBar(); m_pMenuBar->hide(); From b1f0434defde7c386b0bee718c93baa18c3b8859 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Sch=C3=BCrmann?= Date: Sat, 31 Jul 2021 01:46:57 +0200 Subject: [PATCH 07/10] move preInitalize to the constructor and make init functions private --- src/coreservices.cpp | 3 ++- src/coreservices.h | 18 +++++++++--------- src/main.cpp | 3 +-- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/coreservices.cpp b/src/coreservices.cpp index b06f84b8e4a..640a044a683 100644 --- a/src/coreservices.cpp +++ b/src/coreservices.cpp @@ -102,9 +102,10 @@ 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) { + preInitialize(pApp); } void CoreServices::initializeSettings() { diff --git a/src/coreservices.h b/src/coreservices.h index 40e224baf5f..58ae12c25fb 100644 --- a/src/coreservices.h +++ b/src/coreservices.h @@ -34,17 +34,10 @@ class CoreServices : public QObject { Q_OBJECT public: - CoreServices(const CmdlineArgs& args); + CoreServices(const CmdlineArgs& args, QApplication* pApp); ~CoreServices() = default; - void initializeSettings(); - void initializeKeyboard(); - void initializeScreensaverManager(); - void initializeLogging(); - - // The short first run that is done without start up screen - void preInitialize(QApplication* pApp); - // The secondary long run which should be called after displaying the start up screen + /// The secondary long run which should be called after displaying the start up screen void initialize(QApplication* pApp); void shutdown(); @@ -118,6 +111,13 @@ class CoreServices : public QObject { private: bool initializeDatabase(); + void initializeSettings(); + void initializeKeyboard(); + void initializeScreensaverManager(); + void initializeLogging(); + + /// The short first run that is done without start up screen + void preInitialize(QApplication* pApp); std::shared_ptr m_pSettingsManager; std::shared_ptr m_pEffectsManager; diff --git a/src/main.cpp b/src/main.cpp index 24fdcd38c36..3ec98e4bc22 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -23,8 +23,7 @@ constexpr int kFatalErrorOnStartupExitCode = 1; constexpr int kParseCmdlineArgsErrorExitCode = 2; int runMixxx(MixxxApplication* pApp, const CmdlineArgs& args) { - auto pCoreServices = std::make_shared(args); - pCoreServices->preInitialize(pApp); + auto pCoreServices = std::make_shared(args, pApp); MixxxMainWindow mainWindow(pApp, pCoreServices); // If startup produced a fatal error, then don't even start the // Qt event loop. From acda4ccb93fefa5b74404ecced32293fceb07130 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Sch=C3=BCrmann?= Date: Sat, 31 Jul 2021 02:50:55 +0200 Subject: [PATCH 08/10] Remove initalizing of m_pLV2Backend --- src/coreservices.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/coreservices.h b/src/coreservices.h index f7edd9830e4..032adc95e5f 100644 --- a/src/coreservices.h +++ b/src/coreservices.h @@ -130,7 +130,7 @@ class CoreServices : public QObject { std::shared_ptr m_pControlIndicatorTimer; std::shared_ptr m_pEffectsManager; // owned by EffectsManager - LV2Backend* m_pLV2Backend{}; + LV2Backend* m_pLV2Backend; std::shared_ptr m_pEngine; std::shared_ptr m_pSoundManager; std::shared_ptr m_pPlayerManager; From 9c9e00f2a06c9179dc112b8b0db8376fed7c02b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Sch=C3=BCrmann?= Date: Sun, 1 Aug 2021 11:07:53 +0200 Subject: [PATCH 09/10] inline CoreService::preInitalize() --- src/coreservices.cpp | 14 +++++++++++++- src/coreservices.h | 3 --- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/coreservices.cpp b/src/coreservices.cpp index 78ba6e13a40..20b8daf4553 100644 --- a/src/coreservices.cpp +++ b/src/coreservices.cpp @@ -106,7 +106,19 @@ namespace mixxx { CoreServices::CoreServices(const CmdlineArgs& args, QApplication* pApp) : m_runtime_timer(QLatin1String("CoreServices::runtime")), m_cmdlineArgs(args) { - preInitialize(pApp); + 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(); } CoreServices::~CoreServices() = default; diff --git a/src/coreservices.h b/src/coreservices.h index 032adc95e5f..e69da355c6c 100644 --- a/src/coreservices.h +++ b/src/coreservices.h @@ -123,9 +123,6 @@ class CoreServices : public QObject { void initializeScreensaverManager(); void initializeLogging(); - /// The short first run that is done without start up screen - void preInitialize(QApplication* pApp); - std::shared_ptr m_pSettingsManager; std::shared_ptr m_pControlIndicatorTimer; std::shared_ptr m_pEffectsManager; From d0eb10486f212fd7fc5fc27ad6e21d3d33217674 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Sch=C3=BCrmann?= Date: Sun, 1 Aug 2021 11:08:34 +0200 Subject: [PATCH 10/10] over runtime measurement to CoreServices c-tor --- src/coreservices.cpp | 18 ++---------------- 1 file changed, 2 insertions(+), 16 deletions(-) diff --git a/src/coreservices.cpp b/src/coreservices.cpp index 20b8daf4553..6269c33e1bc 100644 --- a/src/coreservices.cpp +++ b/src/coreservices.cpp @@ -106,6 +106,8 @@ namespace mixxx { 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 @@ -151,22 +153,7 @@ void CoreServices::initializeLogging() { logFlags); } -void CoreServices::preInitialize(QApplication* pApp) { - ScopedTimer t("CoreServices::preInitialize"); - 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(); -} - void CoreServices::initialize(QApplication* pApp) { - m_runtime_timer.start(); - mixxx::Time::start(); ScopedTimer t("CoreServices::initialize"); VERIFY_OR_DEBUG_ASSERT(SoundSourceProxy::registerProviders()) { @@ -176,7 +163,6 @@ void CoreServices::initialize(QApplication* pApp) { VersionStore::logBuildDetails(); - #if defined(Q_OS_LINUX) // XESetWireToError will segfault if running as a Wayland client if (pApp->platformName() == QLatin1String("xcb")) {