From kde-commits Thu Oct 25 14:12:19 2012 From: Alexander Dymo Date: Thu, 25 Oct 2012 14:12:19 +0000 To: kde-commits Subject: [kdevplatform] util/duchainify: Make duchainify finish only when everything is done in background pa Message-Id: <20121025141219.24762A6078 () git ! kde ! org> X-MARC-Message: https://marc.info/?l=kde-commits&m=135117434915283 Git commit 5673d6c81a0614cd1452210eea29d7dc9fe2042d by Alexander Dymo. Committed on 25/10/2012 at 16:09. Pushed by dymo into branch 'master'. Make duchainify finish only when everything is done in background parser. This doesn't let it crash when parse jobs add more documents to the parser = and duchainify doesn't have enough time to finish them all before quitting. M +13 -9 util/duchainify/main.cpp M +1 -0 util/duchainify/main.h http://commits.kde.org/kdevplatform/5673d6c81a0614cd1452210eea29d7dc9fe2042d diff --git a/util/duchainify/main.cpp b/util/duchainify/main.cpp index d195b33..6dadd5c 100644 --- a/util/duchainify/main.cpp +++ b/util/duchainify/main.cpp @@ -133,6 +133,13 @@ void Manager::init() } } = + // quit when everything is done + // background parser emits hideProgress() signal in two situations: + // when everything is done and when bgparser is suspended + // later doesn't happen in duchain, so just rely on hideProgress() + // and quit when it's emitted + connect(ICore::self()->languageController()->backgroundParser(), SIGNA= L(hideProgress(KDevelop::IStatus*)), this, SLOT(finish())); + for(int i=3D0; icount(); i++) { addToBackgroundParser(m_args->arg(i), (TopDUContext::Features)feat= ures); @@ -144,10 +151,6 @@ void Manager::init() std::cout << "Added " << m_total << " files to the background pars= er" << std::endl; const int threads =3D ICore::self()->languageController()->backgro= undParser()->threadCount(); std::cout << "parsing with " << threads << " threads" << std::endl; - if (m_waiting.isEmpty()) { - std::cout << "ready" << std::endl; - QApplication::quit(); - } } else { std::cout << "no files added to the background parser" << std::end= l; QCoreApplication::exit(0); @@ -172,11 +175,6 @@ void Manager::updateReady(IndexedString url, Reference= dTopDUContext topContext) } } } - if(m_waiting.isEmpty() && m_allFilesAdded) - { - std::cout << "ready" << std::endl; - QApplication::quit(); - } } = = @@ -210,6 +208,12 @@ QSet< KUrl > Manager::waiting() return m_waiting; } = +void Manager::finish() +{ + std::cout << "ready" << std::endl; + QApplication::quit(); +} + using namespace KDevelop; int main(int argc, char** argv) { diff --git a/util/duchainify/main.h b/util/duchainify/main.h index 7474d6b..0229c83 100644 --- a/util/duchainify/main.h +++ b/util/duchainify/main.h @@ -46,6 +46,7 @@ class Manager : public QObject { // delay init into event loop so the DUChain can always shutdown g= racefully void init(); void updateReady(KDevelop::IndexedString url, KDevelop::Referenced= TopDUContext topContext); + void finish(); }; = #endif