summaryrefslogtreecommitdiff
path: root/src/plugins/projectexplorer/buildmanager.cpp
diff options
context:
space:
mode:
authorEike Ziller <eike.ziller@nokia.com>2011-11-01 18:16:38 +0100
committerEike Ziller <eike.ziller@nokia.com>2011-11-01 18:16:38 +0100
commit912cd548c0b0950b3a1e80f2597c99b3bf898c83 (patch)
treec9eeb5ac857dcabcfb404f60356ad4522471d9ed /src/plugins/projectexplorer/buildmanager.cpp
parentddde938174f03544182adb79179d192502b50e51 (diff)
parent002820867cc0f4f5c67c5ae976eec26157275d4f (diff)
downloadqt-creator-912cd548c0b0950b3a1e80f2597c99b3bf898c83.tar.gz
Merge remote-tracking branch 'origin/2.4'
Conflicts: src/libs/qmljs/qmljsinterpreter.cpp src/libs/qmljs/qmljsinterpreter.h src/plugins/madde/maemopackagecreationstep.cpp src/plugins/projectexplorer/buildmanager.cpp src/plugins/qmljstools/qmljsqtstylecodeformatter.cpp src/plugins/qmljstools/qmljsqtstylecodeformatter.h tests/auto/qml/qmleditor/qmlcodeformatter/tst_qmlcodeformatter.cpp Change-Id: I63ab2ba5dac006c37ccfbae55b023396a4676ff7
Diffstat (limited to 'src/plugins/projectexplorer/buildmanager.cpp')
-rw-r--r--src/plugins/projectexplorer/buildmanager.cpp85
1 files changed, 63 insertions, 22 deletions
diff --git a/src/plugins/projectexplorer/buildmanager.cpp b/src/plugins/projectexplorer/buildmanager.cpp
index c4b7a277b8..0e669458ea 100644
--- a/src/plugins/projectexplorer/buildmanager.cpp
+++ b/src/plugins/projectexplorer/buildmanager.cpp
@@ -51,6 +51,7 @@
#include <utils/qtcassert.h>
#include <QtCore/QDir>
+#include <QtCore/QTime>
#include <QtCore/QTimer>
#include <QtCore/QMetaType>
#include <QtCore/QList>
@@ -88,6 +89,8 @@ struct BuildManagerPrivate {
QString m_currentConfiguration;
// used to decide if we are building a project to decide when to emit buildStateChanged(Project *)
QHash<Project *, int> m_activeBuildSteps;
+ QHash<Target *, int> m_activeBuildStepsPerTarget;
+ QHash<ProjectConfiguration *, int> m_activeBuildStepsPerProjectConfiguration;
Project *m_previousBuildStepProject;
// is set to true while canceling, so that nextBuildStep knows that the BuildStep finished because of canceling
bool m_canceling;
@@ -228,7 +231,7 @@ void BuildManager::cancel()
QTimer::singleShot(0, this, SLOT(emitCancelMessage()));
disconnectOutput(d->m_currentBuildStep);
- decrementActiveBuildSteps(d->m_currentBuildStep->project());
+ decrementActiveBuildSteps(d->m_currentBuildStep);
d->m_progressFutureInterface->setProgressValueAndText(d->m_progress*100, tr("Build/Deployment canceled")); //TODO NBS fix in qtconcurrent
clearBuildQueue();
@@ -261,7 +264,7 @@ void BuildManager::emitCancelMessage()
void BuildManager::clearBuildQueue()
{
foreach (BuildStep *bs, d->m_buildQueue) {
- decrementActiveBuildSteps(bs->project());
+ decrementActiveBuildSteps(bs);
disconnectOutput(bs);
}
@@ -358,7 +361,12 @@ void BuildManager::addToTaskWindow(const ProjectExplorer::Task &task)
void BuildManager::addToOutputWindow(const QString &string, BuildStep::OutputFormat format,
BuildStep::OutputNewlineSetting newLineSetting)
{
- QString stringToWrite = string;
+ QString stringToWrite;
+ if (format == BuildStep::MessageOutput || format == BuildStep::ErrorMessageOutput) {
+ stringToWrite = QTime::currentTime().toString();
+ stringToWrite += QLatin1String(": ");
+ }
+ stringToWrite += string;
if (newLineSetting == BuildStep::DoAppendNewline)
stringToWrite += QLatin1Char('\n');
d->m_outputWindow->appendText(stringToWrite, format);
@@ -387,7 +395,7 @@ void BuildManager::nextBuildQueue()
disconnectOutput(d->m_currentBuildStep);
++d->m_progress;
d->m_progressFutureInterface->setProgressValueAndText(d->m_progress*100, msgProgress(d->m_progress, d->m_maxProgress));
- decrementActiveBuildSteps(d->m_currentBuildStep->project());
+ decrementActiveBuildSteps(d->m_currentBuildStep);
bool result = d->m_watcher.result();
if (!result) {
@@ -496,7 +504,7 @@ bool BuildManager::buildQueueAppend(QList<BuildStep *> steps)
for (i = 0; i < count; ++i) {
++d->m_maxProgress;
d->m_buildQueue.append(steps.at(i));
- incrementActiveBuildSteps(steps.at(i)->target()->project());
+ incrementActiveBuildSteps(steps.at(i));
}
return true;
}
@@ -536,14 +544,29 @@ void BuildManager::appendStep(BuildStep *step)
startBuildQueue();
}
+template <class T>
+int count(const QHash<T *, int> &hash, T *key)
+{
+ typename QHash<T *, int>::const_iterator it = hash.find(key);
+ typename QHash<T *, int>::const_iterator end = hash.end();
+ if (it != end)
+ return *it;
+ return 0;
+}
+
bool BuildManager::isBuilding(Project *pro)
{
- QHash<Project *, int>::iterator it = d->m_activeBuildSteps.find(pro);
- QHash<Project *, int>::iterator end = d->m_activeBuildSteps.end();
- if (it == end || *it == 0)
- return false;
- else
- return true;
+ return count(d->m_activeBuildSteps, pro) > 0;
+}
+
+bool BuildManager::isBuilding(Target *t)
+{
+ return count(d->m_activeBuildStepsPerTarget, t) > 0;
+}
+
+bool BuildManager::isBuilding(ProjectConfiguration *p)
+{
+ return count(d->m_activeBuildStepsPerProjectConfiguration, p) > 0;
}
bool BuildManager::isBuilding(BuildStep *step)
@@ -551,33 +574,51 @@ bool BuildManager::isBuilding(BuildStep *step)
return (d->m_currentBuildStep == step) || d->m_buildQueue.contains(step);
}
-void BuildManager::incrementActiveBuildSteps(Project *pro)
+template <class T> bool increment(QHash<T *, int> &hash, T *key)
{
- QHash<Project *, int>::iterator it = d->m_activeBuildSteps.find(pro);
- QHash<Project *, int>::iterator end = d->m_activeBuildSteps.end();
+ typename QHash<T *, int>::iterator it = hash.find(key);
+ typename QHash<T *, int>::iterator end = hash.end();
if (it == end) {
- d->m_activeBuildSteps.insert(pro, 1);
- emit buildStateChanged(pro);
+ hash.insert(key, 1);
+ return true;
} else if (*it == 0) {
++*it;
- emit buildStateChanged(pro);
+ return true;
} else {
++*it;
}
+ return false;
}
-void BuildManager::decrementActiveBuildSteps(Project *pro)
+template <class T> bool decrement(QHash<T *, int> &hash, T *key)
{
- QHash<Project *, int>::iterator it = d->m_activeBuildSteps.find(pro);
- QHash<Project *, int>::iterator end = d->m_activeBuildSteps.end();
+ typename QHash<T *, int>::iterator it = hash.find(key);
+ typename QHash<T *, int>::iterator end = hash.end();
if (it == end) {
- Q_ASSERT(false && "BuildManager d->m_activeBuildSteps says project is not building, but apparently a build step was still in the queue.");
+ // Can't happen
} else if (*it == 1) {
--*it;
- emit buildStateChanged(pro);
+ return true;
} else {
--*it;
}
+ return false;
+}
+
+void BuildManager::incrementActiveBuildSteps(BuildStep *bs)
+{
+ increment<ProjectConfiguration>(d->m_activeBuildStepsPerProjectConfiguration, bs->projectConfiguration());
+ increment<Target>(d->m_activeBuildStepsPerTarget, bs->target());
+ if (increment<Project>(d->m_activeBuildSteps, bs->project()))
+ emit buildStateChanged(bs->project());
+}
+
+void BuildManager::decrementActiveBuildSteps(BuildStep *bs)
+{
+ decrement<ProjectConfiguration>(d->m_activeBuildStepsPerProjectConfiguration, bs->projectConfiguration());
+ decrement<Target>(d->m_activeBuildStepsPerTarget, bs->target());
+ if (decrement<Project>(d->m_activeBuildSteps, bs->project()))
+ emit buildStateChanged(bs->project());
}
void BuildManager::disconnectOutput(BuildStep *bs)