2009-02-25 09:15:00 +01:00
|
|
|
/**************************************************************************
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
|
|
|
|
** This file is part of Qt Creator
|
|
|
|
|
**
|
2012-01-26 18:33:46 +01:00
|
|
|
** Copyright (c) 2012 Nokia Corporation and/or its subsidiary(-ies).
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
2012-07-19 12:26:56 +02:00
|
|
|
** Contact: http://www.qt-project.org/
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
2008-12-02 14:17:16 +01:00
|
|
|
**
|
2009-02-25 09:15:00 +01:00
|
|
|
** GNU Lesser General Public License Usage
|
2008-12-02 14:17:16 +01:00
|
|
|
**
|
2011-04-13 08:42:33 +02:00
|
|
|
** This file may be used under the terms of the GNU Lesser General Public
|
|
|
|
|
** License version 2.1 as published by the Free Software Foundation and
|
|
|
|
|
** appearing in the file LICENSE.LGPL included in the packaging of this file.
|
|
|
|
|
** Please review the following information to ensure the GNU Lesser General
|
|
|
|
|
** Public License version 2.1 requirements will be met:
|
|
|
|
|
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
2008-12-02 14:17:16 +01:00
|
|
|
**
|
2010-12-17 16:01:08 +01:00
|
|
|
** In addition, as a special exception, Nokia gives you certain additional
|
2011-04-13 08:42:33 +02:00
|
|
|
** rights. These rights are described in the Nokia Qt LGPL Exception
|
2010-12-17 16:01:08 +01:00
|
|
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
|
|
|
|
**
|
2011-04-13 08:42:33 +02:00
|
|
|
** Other Usage
|
|
|
|
|
**
|
|
|
|
|
** Alternatively, this file may be used in accordance with the terms and
|
|
|
|
|
** conditions contained in a signed written agreement between you and Nokia.
|
|
|
|
|
**
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
2009-02-25 09:15:00 +01:00
|
|
|
**************************************************************************/
|
2008-12-02 16:19:05 +01:00
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
#include "runconfiguration.h"
|
2010-01-07 18:17:24 +01:00
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
#include "project.h"
|
2010-02-08 15:50:06 +01:00
|
|
|
#include "target.h"
|
2011-02-01 18:36:00 +01:00
|
|
|
#include "toolchain.h"
|
2011-08-18 13:46:52 +02:00
|
|
|
#include "abi.h"
|
2009-10-28 17:21:27 +01:00
|
|
|
#include "buildconfiguration.h"
|
2010-09-02 17:17:35 +02:00
|
|
|
#include "projectexplorerconstants.h"
|
2012-04-24 15:49:09 +02:00
|
|
|
#include "profileinformation.h"
|
2010-02-08 15:50:06 +01:00
|
|
|
#include <extensionsystem/pluginmanager.h>
|
2011-01-17 13:52:14 +01:00
|
|
|
|
2010-08-20 14:19:25 +02:00
|
|
|
#include <utils/qtcassert.h>
|
2011-08-18 13:46:52 +02:00
|
|
|
#include <utils/outputformatter.h>
|
2011-01-17 13:52:14 +01:00
|
|
|
#include <utils/checkablemessagebox.h>
|
|
|
|
|
|
|
|
|
|
#include <coreplugin/icore.h>
|
2010-02-08 15:50:06 +01:00
|
|
|
|
2012-02-15 10:42:41 +01:00
|
|
|
#include <QTimer>
|
|
|
|
|
#include <QSettings>
|
|
|
|
|
#include <QMessageBox>
|
|
|
|
|
#include <QPushButton>
|
2008-12-02 12:01:29 +01:00
|
|
|
|
|
|
|
|
#ifdef Q_OS_MAC
|
2012-02-23 17:40:48 +01:00
|
|
|
#include <ApplicationServices/ApplicationServices.h>
|
2008-12-02 12:01:29 +01:00
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
using namespace ProjectExplorer;
|
|
|
|
|
|
2010-02-08 15:50:06 +01:00
|
|
|
namespace {
|
|
|
|
|
|
2012-02-22 15:19:42 +01:00
|
|
|
const char USE_CPP_DEBUGGER_KEY[] = "RunConfiguration.UseCppDebugger";
|
|
|
|
|
const char USE_QML_DEBUGGER_KEY[] = "RunConfiguration.UseQmlDebugger";
|
|
|
|
|
const char USE_QML_DEBUGGER_AUTO_KEY[] = "RunConfiguration.UseQmlDebuggerAuto";
|
|
|
|
|
const char QML_DEBUG_SERVER_PORT_KEY[] = "RunConfiguration.QmlDebugServerPort";
|
2012-03-28 09:37:02 +02:00
|
|
|
const char USE_MULTIPROCESS_KEY[] = "RunConfiguration.UseMultiProcess";
|
2012-02-22 15:19:42 +01:00
|
|
|
|
2010-02-08 15:50:06 +01:00
|
|
|
} // namespace
|
|
|
|
|
|
2011-05-31 09:48:00 +02:00
|
|
|
/*!
|
|
|
|
|
\class ProjectExplorer::ProcessHandle
|
|
|
|
|
\brief Helper class to describe a process.
|
|
|
|
|
|
2011-07-06 10:25:18 +02:00
|
|
|
Encapsulates parameters of a running process, local (PID) or remote (to be done,
|
|
|
|
|
address, port, etc).
|
2011-05-31 09:48:00 +02:00
|
|
|
*/
|
|
|
|
|
|
2011-07-06 10:25:18 +02:00
|
|
|
ProcessHandle::ProcessHandle(quint64 pid) :
|
|
|
|
|
m_pid(pid)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool ProcessHandle::isValid() const
|
|
|
|
|
{
|
|
|
|
|
return m_pid != 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ProcessHandle::setPid(quint64 pid)
|
|
|
|
|
{
|
|
|
|
|
m_pid = pid;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
quint64 ProcessHandle::pid() const
|
|
|
|
|
{
|
|
|
|
|
return m_pid;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString ProcessHandle::toString() const
|
|
|
|
|
{
|
|
|
|
|
if (m_pid)
|
|
|
|
|
return RunControl::tr("PID %1").arg(m_pid);
|
|
|
|
|
//: Invalid process handle.
|
|
|
|
|
return RunControl::tr("Invalid");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool ProcessHandle::equals(const ProcessHandle &rhs) const
|
|
|
|
|
{
|
|
|
|
|
return m_pid == rhs.m_pid;
|
|
|
|
|
}
|
|
|
|
|
|
2012-02-17 19:05:11 +01:00
|
|
|
/*!
|
2012-02-23 14:41:28 +01:00
|
|
|
\class ProjectExplorer::DebuggerRunConfigurationAspect
|
2012-02-17 19:05:11 +01:00
|
|
|
*/
|
|
|
|
|
|
2012-02-23 14:41:28 +01:00
|
|
|
DebuggerRunConfigurationAspect::DebuggerRunConfigurationAspect(RunConfiguration *rc) :
|
2012-02-23 13:36:09 +01:00
|
|
|
m_runConfiguration(rc),
|
2012-02-17 19:05:11 +01:00
|
|
|
m_useCppDebugger(true),
|
|
|
|
|
m_useQmlDebugger(AutoEnableQmlDebugger),
|
2012-02-22 15:16:56 +01:00
|
|
|
m_qmlDebugServerPort(Constants::QML_DEFAULT_DEBUG_SERVER_PORT),
|
2012-03-28 09:37:02 +02:00
|
|
|
m_useMultiProcess(false),
|
2012-02-24 16:03:08 +01:00
|
|
|
m_suppressDisplay(false),
|
2012-02-24 12:29:22 +01:00
|
|
|
m_suppressQmlDebuggingOptions(false),
|
2012-02-24 16:03:08 +01:00
|
|
|
m_suppressCppDebuggingOptions(false),
|
2012-02-24 12:29:22 +01:00
|
|
|
m_suppressQmlDebuggingSpinbox(false)
|
2012-02-17 19:05:11 +01:00
|
|
|
{}
|
|
|
|
|
|
2012-02-23 14:41:28 +01:00
|
|
|
DebuggerRunConfigurationAspect::DebuggerRunConfigurationAspect(DebuggerRunConfigurationAspect *other) :
|
2012-02-23 13:36:09 +01:00
|
|
|
m_runConfiguration(other->m_runConfiguration),
|
2012-02-17 19:05:11 +01:00
|
|
|
m_useCppDebugger(other->m_useCppDebugger),
|
|
|
|
|
m_useQmlDebugger(other->m_useQmlDebugger),
|
2012-02-24 12:29:22 +01:00
|
|
|
m_qmlDebugServerPort(other->m_qmlDebugServerPort),
|
2012-03-28 09:37:02 +02:00
|
|
|
m_useMultiProcess(other->m_useMultiProcess),
|
2012-02-24 16:03:08 +01:00
|
|
|
m_suppressDisplay(other->m_suppressDisplay),
|
2012-02-24 12:29:22 +01:00
|
|
|
m_suppressQmlDebuggingOptions(other->m_suppressQmlDebuggingOptions),
|
2012-02-24 16:03:08 +01:00
|
|
|
m_suppressCppDebuggingOptions(other->m_suppressCppDebuggingOptions),
|
2012-02-24 12:29:22 +01:00
|
|
|
m_suppressQmlDebuggingSpinbox(other->m_suppressQmlDebuggingSpinbox)
|
2012-02-17 19:05:11 +01:00
|
|
|
{}
|
|
|
|
|
|
2012-02-23 14:41:28 +01:00
|
|
|
RunConfiguration *DebuggerRunConfigurationAspect::runConfiguration()
|
2012-02-23 13:36:09 +01:00
|
|
|
{
|
|
|
|
|
return m_runConfiguration;
|
|
|
|
|
}
|
|
|
|
|
|
2012-02-23 14:41:28 +01:00
|
|
|
void DebuggerRunConfigurationAspect::setUseQmlDebugger(bool value)
|
2012-02-17 19:05:11 +01:00
|
|
|
{
|
|
|
|
|
m_useQmlDebugger = value ? EnableQmlDebugger : DisableQmlDebugger;
|
|
|
|
|
emit debuggersChanged();
|
|
|
|
|
}
|
|
|
|
|
|
2012-02-23 14:41:28 +01:00
|
|
|
void DebuggerRunConfigurationAspect::setUseCppDebugger(bool value)
|
2012-02-17 19:05:11 +01:00
|
|
|
{
|
|
|
|
|
m_useCppDebugger = value;
|
|
|
|
|
emit debuggersChanged();
|
|
|
|
|
}
|
|
|
|
|
|
2012-02-23 14:41:28 +01:00
|
|
|
bool DebuggerRunConfigurationAspect::useCppDebugger() const
|
2012-02-17 19:05:11 +01:00
|
|
|
{
|
|
|
|
|
return m_useCppDebugger;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static bool isQtQuickAppProject(Project *project)
|
|
|
|
|
{
|
|
|
|
|
const QString filePath = project->projectDirectory()
|
|
|
|
|
+ QLatin1String("/qmlapplicationviewer/qmlapplicationviewer.pri");
|
|
|
|
|
return project->files(Project::ExcludeGeneratedFiles).contains(filePath);
|
|
|
|
|
}
|
|
|
|
|
|
2012-02-23 14:41:28 +01:00
|
|
|
bool DebuggerRunConfigurationAspect::useQmlDebugger() const
|
2012-02-17 19:05:11 +01:00
|
|
|
{
|
2012-02-23 14:41:28 +01:00
|
|
|
if (m_useQmlDebugger == DebuggerRunConfigurationAspect::AutoEnableQmlDebugger)
|
2012-02-23 13:36:09 +01:00
|
|
|
return isQtQuickAppProject(m_runConfiguration->target()->project());
|
2012-02-23 14:41:28 +01:00
|
|
|
return m_useQmlDebugger == DebuggerRunConfigurationAspect::EnableQmlDebugger;
|
2012-02-17 19:05:11 +01:00
|
|
|
}
|
|
|
|
|
|
2012-02-23 14:41:28 +01:00
|
|
|
uint DebuggerRunConfigurationAspect::qmlDebugServerPort() const
|
2012-02-17 19:05:11 +01:00
|
|
|
{
|
2012-02-23 13:36:09 +01:00
|
|
|
return m_qmlDebugServerPort;
|
2012-02-17 19:05:11 +01:00
|
|
|
}
|
|
|
|
|
|
2012-02-23 14:41:28 +01:00
|
|
|
void DebuggerRunConfigurationAspect::setQmllDebugServerPort(uint port)
|
2012-02-17 19:05:11 +01:00
|
|
|
{
|
2012-02-23 13:36:09 +01:00
|
|
|
m_qmlDebugServerPort = port;
|
2012-02-17 19:05:11 +01:00
|
|
|
}
|
|
|
|
|
|
2012-03-28 09:37:02 +02:00
|
|
|
bool DebuggerRunConfigurationAspect::useMultiProcess() const
|
|
|
|
|
{
|
|
|
|
|
return m_useMultiProcess;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void DebuggerRunConfigurationAspect::setUseMultiProcess(bool value)
|
|
|
|
|
{
|
|
|
|
|
m_useMultiProcess = value;
|
|
|
|
|
}
|
|
|
|
|
|
2012-02-24 16:03:08 +01:00
|
|
|
void DebuggerRunConfigurationAspect::suppressDisplay()
|
|
|
|
|
{
|
|
|
|
|
m_suppressDisplay = true;
|
|
|
|
|
}
|
|
|
|
|
|
2012-02-23 14:41:28 +01:00
|
|
|
void DebuggerRunConfigurationAspect::suppressQmlDebuggingOptions()
|
2012-02-17 19:05:11 +01:00
|
|
|
{
|
2012-02-22 15:16:56 +01:00
|
|
|
m_suppressQmlDebuggingOptions = true;
|
|
|
|
|
}
|
|
|
|
|
|
2012-02-24 16:03:08 +01:00
|
|
|
void DebuggerRunConfigurationAspect::suppressCppDebuggingOptions()
|
|
|
|
|
{
|
|
|
|
|
m_suppressCppDebuggingOptions = true;
|
|
|
|
|
}
|
|
|
|
|
|
2012-02-24 12:29:22 +01:00
|
|
|
void DebuggerRunConfigurationAspect::suppressQmlDebuggingSpinbox()
|
|
|
|
|
{
|
|
|
|
|
m_suppressQmlDebuggingSpinbox = true;
|
|
|
|
|
}
|
|
|
|
|
|
2012-02-24 16:03:08 +01:00
|
|
|
bool DebuggerRunConfigurationAspect::isDisplaySuppressed() const
|
|
|
|
|
{
|
|
|
|
|
return m_suppressDisplay;
|
|
|
|
|
}
|
|
|
|
|
|
2012-02-23 14:41:28 +01:00
|
|
|
bool DebuggerRunConfigurationAspect::areQmlDebuggingOptionsSuppressed() const
|
2012-02-22 15:16:56 +01:00
|
|
|
{
|
|
|
|
|
return m_suppressQmlDebuggingOptions;
|
2012-02-17 19:05:11 +01:00
|
|
|
}
|
|
|
|
|
|
2012-02-24 16:03:08 +01:00
|
|
|
bool DebuggerRunConfigurationAspect::areCppDebuggingOptionsSuppressed() const
|
|
|
|
|
{
|
|
|
|
|
return m_suppressCppDebuggingOptions;
|
|
|
|
|
}
|
|
|
|
|
|
2012-02-24 12:29:22 +01:00
|
|
|
bool DebuggerRunConfigurationAspect::isQmlDebuggingSpinboxSuppressed() const
|
|
|
|
|
{
|
|
|
|
|
return m_suppressQmlDebuggingSpinbox;
|
|
|
|
|
}
|
|
|
|
|
|
2012-02-23 14:41:28 +01:00
|
|
|
QString DebuggerRunConfigurationAspect::displayName() const
|
2012-02-17 19:05:11 +01:00
|
|
|
{
|
|
|
|
|
return tr("Debugger settings");
|
|
|
|
|
}
|
|
|
|
|
|
2012-02-23 14:41:28 +01:00
|
|
|
QVariantMap DebuggerRunConfigurationAspect::toMap() const
|
2012-02-17 19:05:11 +01:00
|
|
|
{
|
|
|
|
|
QVariantMap map;
|
|
|
|
|
map.insert(QLatin1String(USE_CPP_DEBUGGER_KEY), m_useCppDebugger);
|
|
|
|
|
map.insert(QLatin1String(USE_QML_DEBUGGER_KEY), m_useQmlDebugger == EnableQmlDebugger);
|
|
|
|
|
map.insert(QLatin1String(USE_QML_DEBUGGER_AUTO_KEY), m_useQmlDebugger == AutoEnableQmlDebugger);
|
|
|
|
|
map.insert(QLatin1String(QML_DEBUG_SERVER_PORT_KEY), m_qmlDebugServerPort);
|
2012-03-28 09:37:02 +02:00
|
|
|
map.insert(QLatin1String(USE_MULTIPROCESS_KEY), m_useMultiProcess);
|
2012-02-17 19:05:11 +01:00
|
|
|
return map;
|
|
|
|
|
}
|
|
|
|
|
|
2012-02-23 14:41:28 +01:00
|
|
|
void DebuggerRunConfigurationAspect::fromMap(const QVariantMap &map)
|
2012-02-17 19:05:11 +01:00
|
|
|
{
|
|
|
|
|
m_useCppDebugger = map.value(QLatin1String(USE_CPP_DEBUGGER_KEY), true).toBool();
|
|
|
|
|
if (map.value(QLatin1String(USE_QML_DEBUGGER_AUTO_KEY), false).toBool()) {
|
|
|
|
|
m_useQmlDebugger = AutoEnableQmlDebugger;
|
|
|
|
|
} else {
|
|
|
|
|
bool useQml = map.value(QLatin1String(USE_QML_DEBUGGER_KEY), false).toBool();
|
|
|
|
|
m_useQmlDebugger = useQml ? EnableQmlDebugger : DisableQmlDebugger;
|
|
|
|
|
}
|
2012-03-28 09:37:02 +02:00
|
|
|
m_useMultiProcess = map.value(QLatin1String(USE_MULTIPROCESS_KEY), false).toBool();
|
2012-02-17 19:05:11 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2011-04-14 12:58:14 +02:00
|
|
|
/*!
|
|
|
|
|
\class ProjectExplorer::RunConfiguration
|
|
|
|
|
\brief Base class for a run configuration. A run configuration specifies how a
|
|
|
|
|
target should be run, while the runner (see below) does the actual running.
|
|
|
|
|
|
|
|
|
|
Note that all RunControls and the target hold a shared pointer to the RunConfiguration.
|
|
|
|
|
That is the lifetime of the RunConfiguration might exceed the life of the target.
|
|
|
|
|
The user might still have a RunControl running (or output tab of that RunControl open)
|
|
|
|
|
and yet unloaded the target.
|
|
|
|
|
|
|
|
|
|
Also, a RunConfiguration might be already removed from the list of RunConfigurations
|
|
|
|
|
for a target, but still be runnable via the output tab.
|
|
|
|
|
*/
|
|
|
|
|
|
2012-03-15 17:17:40 +01:00
|
|
|
RunConfiguration::RunConfiguration(Target *target, const Core::Id id) :
|
2010-09-01 11:34:34 +02:00
|
|
|
ProjectConfiguration(target, id),
|
2012-02-23 14:41:28 +01:00
|
|
|
m_debuggerAspect(new DebuggerRunConfigurationAspect(this))
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2010-07-16 14:00:41 +02:00
|
|
|
Q_ASSERT(target);
|
2011-02-28 12:23:12 +01:00
|
|
|
addExtraAspects();
|
2010-01-19 13:41:02 +01:00
|
|
|
}
|
|
|
|
|
|
2010-02-08 15:50:06 +01:00
|
|
|
RunConfiguration::RunConfiguration(Target *target, RunConfiguration *source) :
|
2010-09-08 11:20:56 +02:00
|
|
|
ProjectConfiguration(target, source),
|
2012-02-23 14:41:28 +01:00
|
|
|
m_debuggerAspect(new DebuggerRunConfigurationAspect(source->debuggerAspect()))
|
2010-01-19 13:41:02 +01:00
|
|
|
{
|
2010-07-16 14:00:41 +02:00
|
|
|
Q_ASSERT(target);
|
2011-02-28 12:23:12 +01:00
|
|
|
addExtraAspects();
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
RunConfiguration::~RunConfiguration()
|
|
|
|
|
{
|
2012-02-17 19:05:11 +01:00
|
|
|
delete m_debuggerAspect;
|
2011-02-28 12:23:12 +01:00
|
|
|
qDeleteAll(m_aspects);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void RunConfiguration::addExtraAspects()
|
|
|
|
|
{
|
2012-06-18 11:34:15 +02:00
|
|
|
foreach (IRunControlFactory *factory, ExtensionSystem::PluginManager::getObjects<IRunControlFactory>())
|
2011-02-28 12:23:12 +01:00
|
|
|
if (IRunConfigurationAspect *aspect = factory->createRunConfigurationAspect())
|
|
|
|
|
m_aspects.append(aspect);
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
2011-04-14 12:58:14 +02:00
|
|
|
/*!
|
2011-05-26 15:33:24 +02:00
|
|
|
\brief Used to find out whether a runconfiguration is enabled
|
2011-04-14 12:58:14 +02:00
|
|
|
*/
|
|
|
|
|
|
2011-05-26 15:33:24 +02:00
|
|
|
bool RunConfiguration::isEnabled() const
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2010-01-19 13:41:02 +01:00
|
|
|
return true;
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
2011-05-26 16:30:35 +02:00
|
|
|
QString RunConfiguration::disabledReason() const
|
|
|
|
|
{
|
|
|
|
|
return QString();
|
|
|
|
|
}
|
|
|
|
|
|
2012-04-24 15:49:09 +02:00
|
|
|
bool RunConfiguration::isConfigured() const
|
|
|
|
|
{
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2011-04-14 12:58:14 +02:00
|
|
|
/*!
|
|
|
|
|
\fn virtual QWidget *ProjectExplorer::RunConfiguration::createConfigurationWidget()
|
|
|
|
|
|
|
|
|
|
\brief Returns the widget used to configure this run configuration. Ownership is transferred to the caller
|
|
|
|
|
*/
|
|
|
|
|
|
2010-01-19 13:41:02 +01:00
|
|
|
BuildConfiguration *RunConfiguration::activeBuildConfiguration() const
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2010-02-08 15:50:06 +01:00
|
|
|
if (!target())
|
2010-01-19 13:41:02 +01:00
|
|
|
return 0;
|
2010-02-08 15:50:06 +01:00
|
|
|
return target()->activeBuildConfiguration();
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
2010-02-08 15:50:06 +01:00
|
|
|
Target *RunConfiguration::target() const
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2010-07-16 14:00:41 +02:00
|
|
|
return static_cast<Target *>(parent());
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
2010-09-01 11:34:34 +02:00
|
|
|
QVariantMap RunConfiguration::toMap() const
|
|
|
|
|
{
|
2012-02-22 11:56:08 +01:00
|
|
|
QVariantMap map = ProjectConfiguration::toMap();
|
|
|
|
|
|
|
|
|
|
map.unite(m_debuggerAspect->toMap());
|
2012-02-17 19:05:11 +01:00
|
|
|
|
2011-02-28 12:23:12 +01:00
|
|
|
foreach (IRunConfigurationAspect *aspect, m_aspects)
|
|
|
|
|
map.unite(aspect->toMap());
|
|
|
|
|
|
2010-09-01 11:34:34 +02:00
|
|
|
return map;
|
|
|
|
|
}
|
|
|
|
|
|
2011-02-01 18:36:00 +01:00
|
|
|
ProjectExplorer::Abi RunConfiguration::abi() const
|
|
|
|
|
{
|
|
|
|
|
BuildConfiguration *bc = target()->activeBuildConfiguration();
|
|
|
|
|
if (!bc)
|
|
|
|
|
return Abi::hostAbi();
|
2012-04-24 15:49:09 +02:00
|
|
|
ToolChain *tc = ProjectExplorer::ToolChainProfileInformation::toolChain(target()->profile());
|
2011-02-01 18:36:00 +01:00
|
|
|
if (!tc)
|
|
|
|
|
return Abi::hostAbi();
|
|
|
|
|
return tc->targetAbi();
|
|
|
|
|
}
|
|
|
|
|
|
2010-09-01 11:34:34 +02:00
|
|
|
bool RunConfiguration::fromMap(const QVariantMap &map)
|
|
|
|
|
{
|
2012-02-22 12:36:39 +01:00
|
|
|
m_debuggerAspect->fromMap(map);
|
2010-09-09 17:00:26 +02:00
|
|
|
|
2011-02-28 12:23:12 +01:00
|
|
|
foreach (IRunConfigurationAspect *aspect, m_aspects)
|
2012-02-22 12:36:39 +01:00
|
|
|
aspect->fromMap(map);
|
2011-02-28 12:23:12 +01:00
|
|
|
|
2010-09-01 11:34:34 +02:00
|
|
|
return ProjectConfiguration::fromMap(map);
|
|
|
|
|
}
|
|
|
|
|
|
2011-04-14 12:58:14 +02:00
|
|
|
/*!
|
|
|
|
|
\class ProjectExplorer::IRunConfigurationAspect
|
|
|
|
|
|
|
|
|
|
\brief Extra configuration aspect.
|
|
|
|
|
|
|
|
|
|
Aspects are a mechanism to add RunControl-specific options to a RunConfiguration without
|
|
|
|
|
subclassing the RunConfiguration for every addition, preventing a combinatorical explosion
|
|
|
|
|
of subclasses or the need to add all options to the base class.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
|
\brief Return extra aspects.
|
|
|
|
|
|
|
|
|
|
\sa ProjectExplorer::IRunConfigurationAspect
|
|
|
|
|
*/
|
|
|
|
|
|
2011-02-28 12:23:12 +01:00
|
|
|
QList<IRunConfigurationAspect *> RunConfiguration::extraAspects() const
|
|
|
|
|
{
|
|
|
|
|
return m_aspects;
|
|
|
|
|
}
|
|
|
|
|
|
2011-04-15 12:59:44 +02:00
|
|
|
Utils::OutputFormatter *RunConfiguration::createOutputFormatter() const
|
2010-07-13 15:02:37 +02:00
|
|
|
{
|
2011-04-15 12:59:44 +02:00
|
|
|
return new Utils::OutputFormatter();
|
2010-07-13 15:02:37 +02:00
|
|
|
}
|
|
|
|
|
|
2011-05-31 09:48:00 +02:00
|
|
|
|
2011-04-14 12:58:14 +02:00
|
|
|
/*!
|
|
|
|
|
\class ProjectExplorer::IRunConfigurationFactory
|
|
|
|
|
|
|
|
|
|
\brief Restores RunConfigurations from settings.
|
|
|
|
|
|
|
|
|
|
The run configuration factory is used for restoring run configurations from
|
|
|
|
|
settings. And used to create new runconfigurations in the "Run Settings" Dialog.
|
|
|
|
|
For the first case, bool canRestore(Target *parent, const QString &id) and
|
|
|
|
|
RunConfiguration* create(Target *parent, const QString &id) are used.
|
|
|
|
|
For the second type, the functions QStringList availableCreationIds(Target *parent) and
|
|
|
|
|
QString displayNameForType(const QString&) are used to generate a list of creatable
|
|
|
|
|
RunConfigurations, and create(..) is used to create it.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
|
\fn QStringList ProjectExplorer::IRunConfigurationFactory::availableCreationIds(Target *parent) const
|
|
|
|
|
|
|
|
|
|
\brief Used to show the list of possible additons to a target, returns a list of types.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
|
\fn QString ProjectExplorer::IRunConfigurationFactory::displayNameForId(const QString &id) const
|
|
|
|
|
\brief Used to translate the types to names to display to the user.
|
|
|
|
|
*/
|
|
|
|
|
|
2010-01-19 13:41:02 +01:00
|
|
|
IRunConfigurationFactory::IRunConfigurationFactory(QObject *parent) :
|
|
|
|
|
QObject(parent)
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
IRunConfigurationFactory::~IRunConfigurationFactory()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2012-04-24 15:49:09 +02:00
|
|
|
IRunConfigurationFactory *IRunConfigurationFactory::find(Target *parent, const QVariantMap &map)
|
2010-02-08 15:50:06 +01:00
|
|
|
{
|
2012-04-24 15:49:09 +02:00
|
|
|
QList<IRunConfigurationFactory *> factories
|
|
|
|
|
= ExtensionSystem::PluginManager::instance()->getObjects<IRunConfigurationFactory>();
|
|
|
|
|
foreach (IRunConfigurationFactory *factory, factories) {
|
|
|
|
|
if (factory->canRestore(parent, map))
|
|
|
|
|
return factory;
|
|
|
|
|
}
|
|
|
|
|
return 0;
|
2010-02-08 15:50:06 +01:00
|
|
|
}
|
|
|
|
|
|
2012-04-24 15:49:09 +02:00
|
|
|
QList<IRunConfigurationFactory *> IRunConfigurationFactory::find(Target *parent)
|
2010-02-08 15:50:06 +01:00
|
|
|
{
|
2012-04-24 15:49:09 +02:00
|
|
|
QList<IRunConfigurationFactory *> factories
|
|
|
|
|
= ExtensionSystem::PluginManager::instance()->getObjects<IRunConfigurationFactory>();
|
|
|
|
|
QList<IRunConfigurationFactory *> result;
|
|
|
|
|
foreach (IRunConfigurationFactory *factory, factories) {
|
|
|
|
|
if (!factory->availableCreationIds(parent).isEmpty())
|
|
|
|
|
result << factory;
|
|
|
|
|
}
|
|
|
|
|
return result;
|
2010-02-08 15:50:06 +01:00
|
|
|
}
|
|
|
|
|
|
2011-04-14 12:58:14 +02:00
|
|
|
/*!
|
|
|
|
|
\class ProjectExplorer::IRunControlFactory
|
|
|
|
|
|
|
|
|
|
\brief Creates RunControl objects matching a RunConfiguration
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
|
\fn IRunConfigurationAspect *ProjectExplorer::IRunControlFactory::createRunConfigurationAspect()
|
|
|
|
|
\brief Return an IRunConfigurationAspect to carry options for RunControls this factory can create.
|
|
|
|
|
|
|
|
|
|
If no extra options are required it is allowed to return null like the default implementation does.
|
|
|
|
|
This is intended to be called from the RunConfiguration constructor, so passing a RunConfiguration
|
|
|
|
|
pointer makes no sense because that object is under construction at the time.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
|
\fn RunConfigWidget *ProjectExplorer::IRunControlFactory::createConfigurationWidget(RunConfiguration *runConfiguration)
|
|
|
|
|
|
|
|
|
|
\brief Return a widget used to configure this runner. Ownership is transferred to the caller.
|
|
|
|
|
|
|
|
|
|
Return 0 if @p runConfiguration is not suitable for RunControls from this factory, or no user-accessible
|
|
|
|
|
configuration is required.
|
|
|
|
|
*/
|
|
|
|
|
|
2009-09-25 11:35:44 +02:00
|
|
|
IRunControlFactory::IRunControlFactory(QObject *parent)
|
2009-06-16 15:11:47 +02:00
|
|
|
: QObject(parent)
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2009-09-25 11:35:44 +02:00
|
|
|
IRunControlFactory::~IRunControlFactory()
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2011-02-28 12:23:12 +01:00
|
|
|
IRunConfigurationAspect *IRunControlFactory::createRunConfigurationAspect()
|
|
|
|
|
{
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2012-06-13 14:50:00 +02:00
|
|
|
RunConfigWidget *IRunControlFactory::createConfigurationWidget(RunConfiguration *)
|
|
|
|
|
{
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2011-04-14 12:58:14 +02:00
|
|
|
/*!
|
|
|
|
|
\class ProjectExplorer::RunControl
|
|
|
|
|
\brief Each instance of this class represents one item that is run.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
|
\fn bool ProjectExplorer::RunControl::promptToStop(bool *optionalPrompt = 0) const
|
|
|
|
|
|
|
|
|
|
\brief Prompt to stop. If 'optionalPrompt' is passed, a "Do not ask again"-
|
|
|
|
|
checkbox will show and the result will be returned in '*optionalPrompt'.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
|
\fn QIcon ProjectExplorer::RunControl::icon() const
|
|
|
|
|
\brief Eeturns the icon to be shown in the Outputwindow.
|
|
|
|
|
|
|
|
|
|
TODO the icon differs currently only per "mode", so this is more flexible then it needs to be.
|
|
|
|
|
*/
|
|
|
|
|
|
2012-01-10 19:17:24 +01:00
|
|
|
RunControl::RunControl(RunConfiguration *runConfiguration, RunMode mode)
|
2010-07-15 10:46:01 +02:00
|
|
|
: m_runMode(mode), m_runConfiguration(runConfiguration), m_outputFormatter(0)
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2010-07-13 15:02:37 +02:00
|
|
|
if (runConfiguration) {
|
2010-01-07 18:17:24 +01:00
|
|
|
m_displayName = runConfiguration->displayName();
|
2010-07-13 15:02:37 +02:00
|
|
|
m_outputFormatter = runConfiguration->createOutputFormatter();
|
|
|
|
|
}
|
|
|
|
|
// We need to ensure that there's always a OutputFormatter
|
|
|
|
|
if (!m_outputFormatter)
|
2011-04-15 12:59:44 +02:00
|
|
|
m_outputFormatter = new Utils::OutputFormatter();
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
2009-10-08 18:37:18 +02:00
|
|
|
RunControl::~RunControl()
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2010-07-13 15:02:37 +02:00
|
|
|
delete m_outputFormatter;
|
|
|
|
|
}
|
2009-10-08 18:37:18 +02:00
|
|
|
|
2011-04-15 12:59:44 +02:00
|
|
|
Utils::OutputFormatter *RunControl::outputFormatter()
|
2010-07-13 15:02:37 +02:00
|
|
|
{
|
|
|
|
|
return m_outputFormatter;
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
2012-01-10 19:17:24 +01:00
|
|
|
RunMode RunControl::runMode() const
|
2010-04-30 13:19:31 +02:00
|
|
|
{
|
|
|
|
|
return m_runMode;
|
|
|
|
|
}
|
|
|
|
|
|
2009-10-08 18:37:18 +02:00
|
|
|
QString RunControl::displayName() const
|
|
|
|
|
{
|
|
|
|
|
return m_displayName;
|
|
|
|
|
}
|
|
|
|
|
|
2011-08-17 09:06:59 +02:00
|
|
|
Abi RunControl::abi() const
|
|
|
|
|
{
|
|
|
|
|
if (const RunConfiguration *rc = m_runConfiguration.data())
|
|
|
|
|
return rc->abi();
|
|
|
|
|
return Abi();
|
|
|
|
|
}
|
|
|
|
|
|
2012-08-31 15:06:07 +02:00
|
|
|
RunConfiguration *RunControl::runConfiguration() const
|
|
|
|
|
{
|
|
|
|
|
return m_runConfiguration.data();
|
|
|
|
|
}
|
|
|
|
|
|
2011-05-31 09:48:00 +02:00
|
|
|
ProcessHandle RunControl::applicationProcessHandle() const
|
|
|
|
|
{
|
|
|
|
|
return m_applicationProcessHandle;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void RunControl::setApplicationProcessHandle(const ProcessHandle &handle)
|
|
|
|
|
{
|
2011-07-06 10:25:18 +02:00
|
|
|
if (m_applicationProcessHandle != handle) {
|
|
|
|
|
m_applicationProcessHandle = handle;
|
|
|
|
|
emit applicationProcessHandleChanged();
|
|
|
|
|
}
|
2011-05-31 09:48:00 +02:00
|
|
|
}
|
|
|
|
|
|
2011-01-17 13:52:14 +01:00
|
|
|
bool RunControl::promptToStop(bool *optionalPrompt) const
|
2010-08-20 14:19:25 +02:00
|
|
|
{
|
2012-04-17 08:01:25 +02:00
|
|
|
QTC_ASSERT(isRunning(), return true);
|
2010-08-20 14:19:25 +02:00
|
|
|
|
2011-01-17 13:52:14 +01:00
|
|
|
if (optionalPrompt && !*optionalPrompt)
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
|
|
const QString msg = tr("<html><head/><body><center><i>%1</i> is still running.<center/>"
|
|
|
|
|
"<center>Force it to quit?</center></body></html>").arg(displayName());
|
|
|
|
|
return showPromptToStopDialog(tr("Application Still Running"), msg,
|
|
|
|
|
tr("Force Quit"), tr("Keep Running"),
|
|
|
|
|
optionalPrompt);
|
|
|
|
|
}
|
|
|
|
|
|
2011-04-14 12:58:14 +02:00
|
|
|
/*!
|
|
|
|
|
\brief Utility to prompt to terminate application with checkable box.
|
|
|
|
|
*/
|
|
|
|
|
|
2011-01-17 13:52:14 +01:00
|
|
|
bool RunControl::showPromptToStopDialog(const QString &title,
|
|
|
|
|
const QString &text,
|
|
|
|
|
const QString &stopButtonText,
|
|
|
|
|
const QString &cancelButtonText,
|
|
|
|
|
bool *prompt) const
|
|
|
|
|
{
|
2012-04-17 08:01:25 +02:00
|
|
|
QTC_ASSERT(isRunning(), return true);
|
2011-01-17 13:52:14 +01:00
|
|
|
// Show a question message box where user can uncheck this
|
|
|
|
|
// question for this class.
|
2012-01-24 15:36:40 +01:00
|
|
|
Utils::CheckableMessageBox messageBox(Core::ICore::mainWindow());
|
2011-01-17 13:52:14 +01:00
|
|
|
messageBox.setWindowTitle(title);
|
|
|
|
|
messageBox.setText(text);
|
|
|
|
|
messageBox.setStandardButtons(QDialogButtonBox::Yes|QDialogButtonBox::Cancel);
|
|
|
|
|
if (!stopButtonText.isEmpty())
|
|
|
|
|
messageBox.button(QDialogButtonBox::Yes)->setText(stopButtonText);
|
|
|
|
|
if (!cancelButtonText.isEmpty())
|
|
|
|
|
messageBox.button(QDialogButtonBox::Cancel)->setText(cancelButtonText);
|
|
|
|
|
messageBox.setDefaultButton(QDialogButtonBox::Yes);
|
|
|
|
|
if (prompt) {
|
|
|
|
|
messageBox.setCheckBoxText(tr("Do not ask again"));
|
|
|
|
|
messageBox.setChecked(false);
|
|
|
|
|
} else {
|
|
|
|
|
messageBox.setCheckBoxVisible(false);
|
|
|
|
|
}
|
|
|
|
|
messageBox.exec();
|
|
|
|
|
const bool close = messageBox.clickedStandardButton() == QDialogButtonBox::Yes;
|
|
|
|
|
if (close && prompt && messageBox.isChecked())
|
|
|
|
|
*prompt = false;
|
|
|
|
|
return close;
|
2010-08-20 14:19:25 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool RunControl::sameRunConfiguration(const RunControl *other) const
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2009-10-08 18:37:18 +02:00
|
|
|
return other->m_runConfiguration.data() == m_runConfiguration.data();
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void RunControl::bringApplicationToForeground(qint64 pid)
|
|
|
|
|
{
|
|
|
|
|
#ifdef Q_OS_MAC
|
|
|
|
|
m_internalPid = pid;
|
|
|
|
|
m_foregroundCount = 0;
|
|
|
|
|
bringApplicationToForegroundInternal();
|
2008-12-02 12:21:14 +01:00
|
|
|
#else
|
|
|
|
|
Q_UNUSED(pid)
|
2008-12-02 12:01:29 +01:00
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void RunControl::bringApplicationToForegroundInternal()
|
|
|
|
|
{
|
|
|
|
|
#ifdef Q_OS_MAC
|
|
|
|
|
ProcessSerialNumber psn;
|
|
|
|
|
GetProcessForPID(m_internalPid, &psn);
|
|
|
|
|
if (SetFrontProcess(&psn) == procNotFound && m_foregroundCount < 15) {
|
|
|
|
|
// somehow the mac/carbon api says
|
|
|
|
|
// "-600 no eligible process with specified process id"
|
|
|
|
|
// if we call SetFrontProcess too early
|
|
|
|
|
++m_foregroundCount;
|
|
|
|
|
QTimer::singleShot(200, this, SLOT(bringApplicationToForegroundInternal()));
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
}
|
2011-01-07 18:57:54 +01:00
|
|
|
|
2011-04-15 12:59:44 +02:00
|
|
|
void RunControl::appendMessage(const QString &msg, Utils::OutputFormat format)
|
2011-01-07 18:57:54 +01:00
|
|
|
{
|
|
|
|
|
emit appendMessage(this, msg, format);
|
|
|
|
|
}
|