[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    [kdevplatform] util/duchainify: Make duchainify finish only when everything is done in background pa
From:       Alexander Dymo <adymo () kdevelop ! org>
Date:       2012-10-25 14:12:19
Message-ID: 20121025141219.24762A6078 () git ! kde ! org
[Download RAW message or body]

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(), \
SIGNAL(hideProgress(KDevelop::IStatus*)), this, SLOT(finish())); +
     for(int i=0; i<m_args->count(); i++)
     {
         addToBackgroundParser(m_args->arg(i), (TopDUContext::Features)features);
@@ -144,10 +151,6 @@ void Manager::init()
         std::cout << "Added " << m_total << " files to the background parser" << \
                std::endl;
         const int threads = \
                ICore::self()->languageController()->backgroundParser()->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::endl;
         QCoreApplication::exit(0);
@@ -172,11 +175,6 @@ void Manager::updateReady(IndexedString url, \
ReferencedTopDUContext 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 gracefully
         void init();
         void updateReady(KDevelop::IndexedString url, \
KDevelop::ReferencedTopDUContext topContext); +        void finish();
 };
 
 #endif


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic