diff --git a/kdevplatform/shell/core.cpp b/kdevplatform/shell/core.cpp --- a/kdevplatform/shell/core.cpp +++ b/kdevplatform/shell/core.cpp @@ -239,6 +239,15 @@ uiController.data()->initialize(); } languageController.data()->initialize(); + languageController->backgroundParser()->suspend(); + // eventually resume the background parser once the project controller + // has been initialized. At that point we know whether there are projects loading + // which the background parser is handling internally to defer parse jobs + QObject::connect(projectController.data(), &ProjectController::initialized, + m_core, [this]() { + languageController.data()->backgroundParser()->resume(); + }); + if (partController) { partController.data()->initialize(); } diff --git a/kdevplatform/shell/projectcontroller.h b/kdevplatform/shell/projectcontroller.h --- a/kdevplatform/shell/projectcontroller.h +++ b/kdevplatform/shell/projectcontroller.h @@ -150,6 +150,9 @@ virtual void initialize(); +Q_SIGNALS: + void initialized(); + private: //FIXME Do not load all of this just for the project being opened... //void legacyLoading(); diff --git a/kdevplatform/shell/projectcontroller.cpp b/kdevplatform/shell/projectcontroller.cpp --- a/kdevplatform/shell/projectcontroller.cpp +++ b/kdevplatform/shell/projectcontroller.cpp @@ -35,6 +35,7 @@ #include #include #include +#include #include #include @@ -648,16 +649,19 @@ KSharedConfigPtr config = Core::self()->activeSession()->config(); KConfigGroup group = config->group( "General Options" ); - QList openProjects = group.readEntry( "Open Projects", QList() ); - - QMetaObject::invokeMethod(this, "openProjects", Qt::QueuedConnection, Q_ARG(QList, openProjects)); + const auto projects = group.readEntry( "Open Projects", QList() ); connect( Core::self()->selectionController(), &ISelectionController::selectionChanged, this, [&] () { d->updateActionStates(); } ); connect(this, &ProjectController::projectOpened, this, [&] () { d->updateActionStates(); }); connect(this, &ProjectController::projectClosing, this, [&] () { d->updateActionStates(); }); + + QTimer::singleShot(0, this, [this, projects](){ + openProjects(projects); + emit initialized(); + }); } void ProjectController::openProjects(const QList& projects) diff --git a/kdevplatform/shell/tests/test_projectcontroller.cpp b/kdevplatform/shell/tests/test_projectcontroller.cpp --- a/kdevplatform/shell/tests/test_projectcontroller.cpp +++ b/kdevplatform/shell/tests/test_projectcontroller.cpp @@ -172,6 +172,10 @@ m_scratchDir = QDir(QDir::tempPath()); m_scratchDir.mkdir(QStringLiteral("prjctrltest")); m_scratchDir.cd(QStringLiteral("prjctrltest")); + + QSignalSpy projectControllerInitializedSpy(m_core->projectControllerInternal(), + &ProjectController::initialized); + QVERIFY(projectControllerInitializedSpy.wait(100)); } void TestProjectController::cleanupTestCase()