diff --git a/language/duchain/duchain.cpp b/language/duchain/duchain.cpp --- a/language/duchain/duchain.cpp +++ b/language/duchain/duchain.cpp @@ -286,7 +286,7 @@ //Just to make sure the cache is cleared periodically ModificationRevisionSet::clearCache(); - m_data->doMoreCleanup(SOFT_CLEANUP_STEPS); + m_data->doMoreCleanup(SOFT_CLEANUP_STEPS, true, true); if(m_stopRunning) break; } @@ -684,7 +684,7 @@ ///doing the cleanup without permanently locking the du-chain. During these steps the consistency ///of the disk-storage is not guaranteed, but only few changes will be done during these steps, ///so the final step where the duchain is permanently locked is much faster. - void doMoreCleanup(int retries = 0, bool needLockRepository = true) { + void doMoreCleanup(int retries = 0, bool needLockRepository = true, bool tryLock = false) { if(m_cleanupDisabled) return; @@ -697,25 +697,32 @@ Q_ASSERT(!instance->lock()->currentThreadHasReadLock() && !instance->lock()->currentThreadHasWriteLock()); DUChainWriteLocker writeLock(instance->lock()); - PersistentSymbolTable::self().clearCache(); //This is used to stop all parsing before starting to do the cleanup. This way less happens during the //soft cleanups, and we have a good chance that during the "hard" cleanup only few data has to be written. - QList lockedParseMutexes; - QList locked; if(needLockRepository) { - + QList languages; if (ICore* core = ICore::self()) if (ILanguageController* lc = core->languageController()) - lockedParseMutexes = lc->loadedLanguages(); + languages = lc->loadedLanguages(); writeLock.unlock(); //Here we wait for all parsing-threads to stop their processing - foreach(const auto language, lockedParseMutexes) { - language->parseLock()->lockForWrite(); + foreach(const auto language, languages) { + if (tryLock) { + if (!language->parseLock()->tryLockForWrite()) { + // some language is still parsing, don't interfere with the cleanup + foreach(auto* lock, locked) { + lock->unlock(); + } + return; + } + } else { + language->parseLock()->lockForWrite(); + } locked << language->parseLock(); } @@ -726,6 +733,7 @@ } QTime startTime = QTime::currentTime(); + PersistentSymbolTable::self().clearCache(); storeAllInformation(!retries, writeLock); //Puts environment-information into a repository