diff options
author | hjk <hjk121@nokiamail.com> | 2013-09-05 14:36:20 +0200 |
---|---|---|
committer | hjk <hjk121@nokiamail.com> | 2013-09-05 15:37:43 +0200 |
commit | ad58c2bb4445567ecc349a0987bf3f8a781cc883 (patch) | |
tree | 243654c2889746d14dfe8a0c6ccf9471cbb611af /src/plugins/projectexplorer/buildmanager.cpp | |
parent | e5c7ac61ece24e956badea69cc45dd8bc5437790 (diff) | |
download | qt-creator-ad58c2bb4445567ecc349a0987bf3f8a781cc883.tar.gz |
BuildManager: apply 'static' pattern
Change-Id: I00bb591c027a22088d5f1feedc84aa28523dcca2
Reviewed-by: David Schulz <david.schulz@digia.com>
Diffstat (limited to 'src/plugins/projectexplorer/buildmanager.cpp')
-rw-r--r-- | src/plugins/projectexplorer/buildmanager.cpp | 50 |
1 files changed, 31 insertions, 19 deletions
diff --git a/src/plugins/projectexplorer/buildmanager.cpp b/src/plugins/projectexplorer/buildmanager.cpp index bdfbbfa146..ab4d01d00d 100644 --- a/src/plugins/projectexplorer/buildmanager.cpp +++ b/src/plugins/projectexplorer/buildmanager.cpp @@ -111,9 +111,15 @@ BuildManagerPrivate::BuildManagerPrivate() : { } +static BuildManagerPrivate *d = 0; +static BuildManager *m_instance = 0; + BuildManager::BuildManager(QObject *parent, QAction *cancelBuildAction) - : QObject(parent), d(new BuildManagerPrivate) + : QObject(parent) { + m_instance = this; + d = new BuildManagerPrivate; + connect(&d->m_watcher, SIGNAL(finished()), this, SLOT(nextBuildQueue())); @@ -148,6 +154,11 @@ BuildManager::BuildManager(QObject *parent, QAction *cancelBuildAction) this, SLOT(finish())); } +QObject *BuildManager::instance() +{ + return m_instance; +} + void BuildManager::extensionsInitialized() { TaskHub::addCategory(Constants::TASK_CATEGORY_COMPILE, @@ -161,6 +172,7 @@ void BuildManager::extensionsInitialized() BuildManager::~BuildManager() { cancel(); + m_instance = 0; ExtensionSystem::PluginManager::removeObject(d->m_taskWindow); delete d->m_taskWindow; @@ -170,7 +182,7 @@ BuildManager::~BuildManager() delete d; } -void BuildManager::aboutToRemoveProject(ProjectExplorer::Project *p) +void BuildManager::aboutToRemoveProject(Project *p) { QHash<Project *, int>::iterator it = d->m_activeBuildSteps.find(p); QHash<Project *, int>::iterator end = d->m_activeBuildSteps.end(); @@ -182,13 +194,13 @@ void BuildManager::aboutToRemoveProject(ProjectExplorer::Project *p) } } -bool BuildManager::isBuilding() const +bool BuildManager::isBuilding() { // we are building even if we are not running yet return !d->m_buildQueue.isEmpty() || d->m_running; } -int BuildManager::getErrorTaskCount() const +int BuildManager::getErrorTaskCount() { const int errors = d->m_taskWindow->errorTaskCount(Constants::TASK_CATEGORY_BUILDSYSTEM) @@ -213,7 +225,7 @@ void BuildManager::updateTaskCount() { const int errors = getErrorTaskCount(); ProgressManager::setApplicationLabel(errors > 0 ? QString::number(errors) : QString()); - emit tasksChanged(); + emit m_instance->tasksChanged(); } void BuildManager::finish() @@ -254,7 +266,7 @@ void BuildManager::clearBuildQueue() d->m_futureProgress = 0; d->m_maxProgress = 0; - emit buildQueueFinished(false); + emit m_instance->buildQueueFinished(false); } @@ -273,7 +285,7 @@ void BuildManager::toggleTaskWindow() d->m_taskWindow->toggle(IOutputPane::ModeSwitch); } -bool BuildManager::tasksAvailable() const +bool BuildManager::tasksAvailable() { const int count = d->m_taskWindow->taskCount(Constants::TASK_CATEGORY_BUILDSYSTEM) @@ -285,7 +297,7 @@ bool BuildManager::tasksAvailable() const void BuildManager::startBuildQueue(const QStringList &preambleMessage) { if (d->m_buildQueue.isEmpty()) { - emit buildQueueFinished(true); + emit m_instance->buildQueueFinished(true); return; } if (!d->m_running) { @@ -302,7 +314,7 @@ void BuildManager::startBuildQueue(const QStringList &preambleMessage) d->m_futureProgress = ProgressManager::addTask(d->m_progressFutureInterface->future(), QString(), "ProjectExplorer.Task.Build", ProgressManager::KeepOnFinish | ProgressManager::ShowInApplicationIcon); - connect(d->m_futureProgress.data(), SIGNAL(clicked()), this, SLOT(showBuildResults())); + connect(d->m_futureProgress.data(), SIGNAL(clicked()), m_instance, SLOT(showBuildResults())); d->m_futureProgress.data()->setWidget(new Internal::BuildProgress(d->m_taskWindow)); d->m_futureProgress.data()->setStatusBarWidget(new Internal::BuildProgress(d->m_taskWindow, Qt::Horizontal)); @@ -352,7 +364,7 @@ void BuildManager::addToOutputWindow(const QString &string, BuildStep::OutputFor void BuildManager::buildStepFinishedAsync() { disconnect(d->m_currentBuildStep, SIGNAL(finished()), - this, SLOT(buildStepFinishedAsync())); + m_instance, SLOT(buildStepFinishedAsync())); d->m_futureInterfaceForAysnc = QFutureInterface<bool>(); nextBuildQueue(); } @@ -361,7 +373,7 @@ void BuildManager::nextBuildQueue() { if (d->m_canceling) { d->m_canceling = false; - QTimer::singleShot(0, this, SLOT(emitCancelMessage())); + QTimer::singleShot(0, m_instance, SLOT(emitCancelMessage())); disconnectOutput(d->m_currentBuildStep); decrementActiveBuildSteps(d->m_currentBuildStep); @@ -443,7 +455,7 @@ void BuildManager::nextStep() if (d->m_currentBuildStep->runInGuiThread()) { connect (d->m_currentBuildStep, SIGNAL(finished()), - this, SLOT(buildStepFinishedAsync())); + m_instance, SLOT(buildStepFinishedAsync())); d->m_watcher.setFuture(d->m_futureInterfaceForAysnc.future()); d->m_currentBuildStep->run(d->m_futureInterfaceForAysnc); } else { @@ -458,7 +470,7 @@ void BuildManager::nextStep() delete d->m_progressFutureInterface; d->m_progressFutureInterface = 0; d->m_maxProgress = 0; - emit buildQueueFinished(true); + emit m_instance->buildQueueFinished(true); } } @@ -471,9 +483,9 @@ bool BuildManager::buildQueueAppend(QList<BuildStep *> steps, QStringList names) for (; i < count; ++i) { BuildStep *bs = steps.at(i); connect(bs, SIGNAL(addTask(ProjectExplorer::Task)), - this, SLOT(addToTaskWindow(ProjectExplorer::Task))); + m_instance, SLOT(addToTaskWindow(ProjectExplorer::Task))); connect(bs, SIGNAL(addOutput(QString,ProjectExplorer::BuildStep::OutputFormat,ProjectExplorer::BuildStep::OutputNewlineSetting)), - this, SLOT(addToOutputWindow(QString,ProjectExplorer::BuildStep::OutputFormat,ProjectExplorer::BuildStep::OutputNewlineSetting))); + m_instance, SLOT(addToOutputWindow(QString,ProjectExplorer::BuildStep::OutputFormat,ProjectExplorer::BuildStep::OutputNewlineSetting))); if (bs->enabled()) { init = bs->init(); if (!init) @@ -616,7 +628,7 @@ 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()); + emit m_instance->buildStateChanged(bs->project()); } void BuildManager::decrementActiveBuildSteps(BuildStep *bs) @@ -624,16 +636,16 @@ 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()); + emit m_instance->buildStateChanged(bs->project()); } void BuildManager::disconnectOutput(BuildStep *bs) { disconnect(bs, SIGNAL(addTask(ProjectExplorer::Task)), - this, SLOT(addToTaskWindow(ProjectExplorer::Task))); + m_instance, SLOT(addToTaskWindow(ProjectExplorer::Task))); disconnect(bs, SIGNAL(addOutput(QString, ProjectExplorer::BuildStep::OutputFormat, ProjectExplorer::BuildStep::OutputNewlineSetting)), - this, SLOT(addToOutputWindow(QString, ProjectExplorer::BuildStep::OutputFormat, + m_instance, SLOT(addToOutputWindow(QString, ProjectExplorer::BuildStep::OutputFormat, ProjectExplorer::BuildStep::OutputNewlineSetting))); } |