diff options
author | Christian Kandeler <christian.kandeler@digia.com> | 2014-07-14 10:22:37 +0200 |
---|---|---|
committer | Christian Kandeler <christian.kandeler@digia.com> | 2014-07-14 11:23:46 +0200 |
commit | 20bfe889e9f38d46551654121cc7f2af052ab81e (patch) | |
tree | b49a97ff506384f6ad52f7cb594fc1a02a4ee6c8 /src/plugins/qbsprojectmanager/qbsproject.cpp | |
parent | 051bccf89e4c34f3d42c73c01eb9dbf799cbcd5e (diff) | |
download | qt-creator-20bfe889e9f38d46551654121cc7f2af052ab81e.tar.gz |
QbsProjectManager: Fix handling of overlapping parse requests.
The current code simply asserts when a new parse request comes in while
parsing. However, that condition is easily triggered, for instance if a
project file is saved to disk during a parse operation. Such updates
currently have no effect at all (other than triggering an error
message).
Instead, we now cancel the old parse job and start a new one.
Change-Id: If2eeb93b85b5163dcea99785a0fc89a254d082db
Reviewed-by: Joerg Bornemann <joerg.bornemann@digia.com>
Diffstat (limited to 'src/plugins/qbsprojectmanager/qbsproject.cpp')
-rw-r--r-- | src/plugins/qbsprojectmanager/qbsproject.cpp | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/src/plugins/qbsprojectmanager/qbsproject.cpp b/src/plugins/qbsprojectmanager/qbsproject.cpp index eaafb89c81..deb49bdfc7 100644 --- a/src/plugins/qbsprojectmanager/qbsproject.cpp +++ b/src/plugins/qbsprojectmanager/qbsproject.cpp @@ -102,6 +102,7 @@ QbsProject::QbsProject(QbsManager *manager, const QString &fileName) : m_qbsUpdateFutureInterface(0), m_forceParsing(false), m_parsingScheduled(false), + m_cancelingParsing(false), m_currentBc(0) { m_parsingDelay.setInterval(1000); // delay parsing by 1s. @@ -275,12 +276,23 @@ void QbsProject::handleQbsParsingDone(bool success) { QTC_ASSERT(m_qbsProjectParser, return); + // If this parse operation was canceled, start a new one right away, ignoring the old result. + if (m_cancelingParsing) { + m_cancelingParsing = false; + m_qbsProjectParser->deleteLater(); + m_qbsProjectParser = 0; + parseCurrentBuildConfiguration(m_forceParsing); + return; + } + generateErrors(m_qbsProjectParser->error()); if (success) { m_qbsProject = m_qbsProjectParser->qbsProject(); QTC_CHECK(m_qbsProject.isValid()); readQbsData(); + } else { + m_qbsUpdateFutureInterface->reportCanceled(); } m_qbsProjectParser->deleteLater(); @@ -369,12 +381,27 @@ void QbsProject::parseCurrentBuildConfiguration(bool force) m_parsingScheduled = false; if (!m_forceParsing) m_forceParsing = force; + if (m_cancelingParsing) + return; if (!activeTarget()) return; QbsBuildConfiguration *bc = qobject_cast<QbsBuildConfiguration *>(activeTarget()->activeBuildConfiguration()); if (!bc) return; + + // New parse requests override old ones. + // NOTE: We need to wait for the current operation to finish, since otherwise there could + // be a conflict. Consider the case where the old qbs::ProjectSetupJob is writing + // to the build graph file when the cancel request comes in. If we don't wait for + // acknowledgment, it might still be doing that when the new one already reads from the + // same file. + if (m_qbsProjectParser) { + m_cancelingParsing = true; + m_qbsProjectParser->cancel(); + return; + } + parse(bc->qbsConfiguration(), bc->environment(), bc->buildDirectory().toString()); } |