diff options
20 files changed, 52 insertions, 62 deletions
diff --git a/src/plugins/autotest/testrunconfiguration.h b/src/plugins/autotest/testrunconfiguration.h index 695ccfc962..f08d198f58 100644 --- a/src/plugins/autotest/testrunconfiguration.h +++ b/src/plugins/autotest/testrunconfiguration.h @@ -67,7 +67,6 @@ public: r.commandLineArguments = m_testConfig->argumentsForTestRunner().join(' '); r.workingDirectory = m_testConfig->workingDirectory(); r.environment = m_testConfig->environment(); - r.runMode = ProjectExplorer::ApplicationLauncher::Gui; r.device = ProjectExplorer::DeviceManager::instance()->defaultDevice( ProjectExplorer::Constants::DESKTOP_DEVICE_TYPE); return r; diff --git a/src/plugins/debugger/cdb/cdbengine.cpp b/src/plugins/debugger/cdb/cdbengine.cpp index 84d979b1d4..070afa81ac 100644 --- a/src/plugins/debugger/cdb/cdbengine.cpp +++ b/src/plugins/debugger/cdb/cdbengine.cpp @@ -413,7 +413,7 @@ void CdbEngine::setupEngine() sp.inferior.commandLineArguments.clear(); sp.attachPID = ProcessHandle(terminal()->applicationPid()); sp.startMode = AttachExternal; - sp.inferior.runMode = ApplicationLauncher::Gui; // Force no terminal. + sp.useTerminal = false; // Force no terminal. showMessage(QString("Attaching to %1...").arg(sp.attachPID.pid()), LogMisc); } else { m_effectiveStartMode = sp.startMode; @@ -462,7 +462,7 @@ void CdbEngine::setupEngine() // register idle (debuggee stop) notification << "-c" << ".idle_cmd " + m_extensionCommandPrefix + "idle"; - if (sp.inferior.runMode == ApplicationLauncher::Console) // Separate console + if (sp.useTerminal) // Separate console arguments << "-2"; if (boolSetting(IgnoreFirstChanceAccessViolation)) arguments << "-x"; @@ -530,8 +530,7 @@ void CdbEngine::setupEngine() // Make sure that QTestLib uses OutputDebugString for logging. const QString qtLoggingToConsoleKey = QStringLiteral("QT_LOGGING_TO_CONSOLE"); - if (sp.inferior.runMode != ApplicationLauncher::Console - && !inferiorEnvironment.hasKey(qtLoggingToConsoleKey)) + if (!sp.useTerminal && !inferiorEnvironment.hasKey(qtLoggingToConsoleKey)) inferiorEnvironment.set(qtLoggingToConsoleKey, QString(QLatin1Char('0'))); m_process.setEnvironment(mergeEnvironment(inferiorEnvironment.toStringList(), diff --git a/src/plugins/debugger/debuggerdialogs.cpp b/src/plugins/debugger/debuggerdialogs.cpp index c7934e6839..f911cfb905 100644 --- a/src/plugins/debugger/debuggerdialogs.cpp +++ b/src/plugins/debugger/debuggerdialogs.cpp @@ -148,6 +148,7 @@ public: QString serverAddress; Runnable runnable; bool breakAtMain = false; + bool runInTerminal = false; QString serverStartScript; QString debugInfoLocation; }; @@ -159,7 +160,7 @@ bool StartApplicationParameters::equals(const StartApplicationParameters &rhs) c && runnable.commandLineArguments == rhs.runnable.commandLineArguments && runnable.workingDirectory == rhs.runnable.workingDirectory && breakAtMain == rhs.breakAtMain - && runnable.runMode == rhs.runnable.runMode + && runInTerminal == rhs.runInTerminal && serverStartScript == rhs.serverStartScript && kitId == rhs.kitId && debugInfoLocation == rhs.debugInfoLocation @@ -195,7 +196,7 @@ void StartApplicationParameters::toSettings(QSettings *settings) const settings->setValue("LastExternalExecutableArguments", runnable.commandLineArguments); settings->setValue("LastExternalWorkingDirectory", runnable.workingDirectory); settings->setValue("LastExternalBreakAtMain", breakAtMain); - settings->setValue("LastExternalRunInTerminal", runnable.runMode == ApplicationLauncher::Console); + settings->setValue("LastExternalRunInTerminal", runInTerminal); settings->setValue("LastServerStartScript", serverStartScript); settings->setValue("LastDebugInfoLocation", debugInfoLocation); } @@ -209,8 +210,7 @@ void StartApplicationParameters::fromSettings(const QSettings *settings) runnable.commandLineArguments = settings->value("LastExternalExecutableArguments").toString(); runnable.workingDirectory = settings->value("LastExternalWorkingDirectory").toString(); breakAtMain = settings->value("LastExternalBreakAtMain").toBool(); - runnable.runMode = settings->value("LastExternalRunInTerminal").toBool() - ? ApplicationLauncher::Console : ApplicationLauncher::Gui; + runInTerminal = settings->value("LastExternalRunInTerminal").toBool(); serverStartScript = settings->value("LastServerStartScript").toString(); debugInfoLocation = settings->value("LastDebugInfoLocation").toString(); } @@ -469,8 +469,7 @@ StartApplicationParameters StartApplicationDialog::parameters() const result.runnable.commandLineArguments = d->arguments->text(); result.runnable.workingDirectory = d->workingDirectory->path(); result.breakAtMain = d->breakAtMainCheckBox->isChecked(); - result.runnable.runMode = d->runInTerminalCheckBox->isChecked() - ? ApplicationLauncher::Console : ApplicationLauncher::Gui; + result.runInTerminal = d->runInTerminalCheckBox->isChecked(); return result; } @@ -484,7 +483,7 @@ void StartApplicationDialog::setParameters(const StartApplicationParameters &p) d->debuginfoPathChooser->setPath(p.debugInfoLocation); d->arguments->setText(p.runnable.commandLineArguments); d->workingDirectory->setPath(p.runnable.workingDirectory); - d->runInTerminalCheckBox->setChecked(p.runnable.runMode == ApplicationLauncher::Console); + d->runInTerminalCheckBox->setChecked(p.runInTerminal); d->breakAtMainCheckBox->setChecked(p.breakAtMain); updateState(); } diff --git a/src/plugins/debugger/debuggerengine.h b/src/plugins/debugger/debuggerengine.h index aa4617087b..c02271ab2f 100644 --- a/src/plugins/debugger/debuggerengine.h +++ b/src/plugins/debugger/debuggerengine.h @@ -133,6 +133,7 @@ public: bool isQmlDebugging = false; bool breakOnMain = false; bool multiProcess = false; // Whether to set detach-on-fork off. + bool useTerminal = false; ProjectExplorer::Runnable debugger; QString overrideStartScript; // Used in attach to core and remote debugging diff --git a/src/plugins/debugger/debuggerruncontrol.cpp b/src/plugins/debugger/debuggerruncontrol.cpp index 2149d81189..cf7e0360c8 100644 --- a/src/plugins/debugger/debuggerruncontrol.cpp +++ b/src/plugins/debugger/debuggerruncontrol.cpp @@ -435,7 +435,6 @@ void DebuggerRunTool::setOverrideStartScript(const QString &script) void DebuggerRunTool::setInferior(const Runnable &runnable) { m_runParameters.inferior = runnable; - setUseTerminal(m_runParameters.inferior.runMode == ApplicationLauncher::Console); } void DebuggerRunTool::setInferiorExecutable(const QString &executable) @@ -839,6 +838,8 @@ DebuggerRunTool::DebuggerRunTool(RunControl *runControl, Kit *kit, bool allowTer m_runParameters.displayName = runConfig->displayName(); if (auto symbolsAspect = runConfig->extraAspect<SymbolFileAspect>()) m_runParameters.symbolFile = symbolsAspect->value(); + if (auto terminalAspect = runConfig->extraAspect<TerminalAspect>()) + m_runParameters.useTerminal = terminalAspect->useTerminal(); } if (runConfig && !kit) @@ -865,7 +866,7 @@ DebuggerRunTool::DebuggerRunTool(RunControl *runControl, Kit *kit, bool allowTer // Normalize to work around QTBUG-17529 (QtDeclarative fails with 'File name case mismatch'...) m_runParameters.inferior.workingDirectory = FileUtils::normalizePathName(m_runParameters.inferior.workingDirectory); - setUseTerminal(allowTerminal && m_runParameters.inferior.runMode == ApplicationLauncher::Console); + setUseTerminal(allowTerminal && m_runParameters.useTerminal); const QByteArray envBinary = qgetenv("QTC_DEBUGGER_PATH"); if (!envBinary.isEmpty()) diff --git a/src/plugins/nim/project/nimrunconfiguration.cpp b/src/plugins/nim/project/nimrunconfiguration.cpp index ac3c41287f..22bb972d5b 100644 --- a/src/plugins/nim/project/nimrunconfiguration.cpp +++ b/src/plugins/nim/project/nimrunconfiguration.cpp @@ -44,14 +44,11 @@ namespace Nim { NimRunConfiguration::NimRunConfiguration(Target *target, Core::Id id) : RunConfiguration(target, id) { - auto terminalAspect = new TerminalAspect(this, "Nim.NimRunConfiguration.TerminalAspect"); - terminalAspect->setRunMode(ApplicationLauncher::Gui); - addExtraAspect(terminalAspect); - addExtraAspect(new ExecutableAspect(this)); addExtraAspect(new ArgumentsAspect(this, "Nim.NimRunConfiguration.ArgumentAspect")); addExtraAspect(new WorkingDirectoryAspect(this, "Nim.NimRunConfiguration.WorkingDirectoryAspect")); addExtraAspect(new LocalEnvironmentAspect(this, LocalEnvironmentAspect::BaseEnvironmentModifier())); + addExtraAspect(new TerminalAspect(this, "Nim.NimRunConfiguration.TerminalAspect")); setDisplayName(tr("Current Build Target")); setDefaultDisplayName(tr("Current Build Target")); diff --git a/src/plugins/projectexplorer/applicationlauncher.cpp b/src/plugins/projectexplorer/applicationlauncher.cpp index d42109d2b4..ab9ce4b195 100644 --- a/src/plugins/projectexplorer/applicationlauncher.cpp +++ b/src/plugins/projectexplorer/applicationlauncher.cpp @@ -104,7 +104,7 @@ public: // Local QtcProcess m_guiProcess; ConsoleProcess m_consoleProcess; - ApplicationLauncher::Mode m_currentMode = ApplicationLauncher::Gui; + bool m_useTerminal = false; // Keep track whether we need to emit a finished signal bool m_processRunning = false; @@ -179,6 +179,11 @@ void ApplicationLauncher::setProcessChannelMode(QProcess::ProcessChannelMode mod d->m_guiProcess.setProcessChannelMode(mode); } +void ApplicationLauncher::setUseTerminal(bool on) +{ + d->m_useTerminal = on; +} + void ApplicationLauncher::stop() { d->stop(); @@ -189,15 +194,15 @@ void ApplicationLauncherPrivate::stop() if (m_isLocal) { if (!isRunning()) return; - if (m_currentMode == ApplicationLauncher::Gui) { + if (m_useTerminal) { + m_consoleProcess.stop(); + localProcessDone(0, QProcess::CrashExit); + } else { m_guiProcess.terminate(); if (!m_guiProcess.waitForFinished(1000) && m_guiProcess.state() == QProcess::Running) { // This is blocking, so be fast. m_guiProcess.kill(); m_guiProcess.waitForFinished(); } - } else { - m_consoleProcess.stop(); - localProcessDone(0, QProcess::CrashExit); } } else { if (m_stopRequested) @@ -227,9 +232,9 @@ bool ApplicationLauncher::isRemoteRunning() const bool ApplicationLauncherPrivate::isRunning() const { - if (m_currentMode == ApplicationLauncher::Gui) - return m_guiProcess.state() != QProcess::NotRunning; - return m_consoleProcess.isRunning(); + if (m_useTerminal) + return m_consoleProcess.isRunning(); + return m_guiProcess.state() != QProcess::NotRunning; } bool ApplicationLauncherPrivate::isRemoteRunning() const @@ -247,7 +252,7 @@ qint64 ApplicationLauncherPrivate::applicationPID() const if (!isRunning()) return 0; - if (m_currentMode == ApplicationLauncher::Console) + if (m_useTerminal) return m_consoleProcess.applicationPID(); return m_guiProcess.processId(); @@ -255,18 +260,18 @@ qint64 ApplicationLauncherPrivate::applicationPID() const QString ApplicationLauncher::errorString() const { - if (d->m_currentMode == Gui) - return d->m_guiProcess.errorString(); - else + if (d->m_useTerminal) return d->m_consoleProcess.errorString(); + else + return d->m_guiProcess.errorString(); } QProcess::ProcessError ApplicationLauncher::processError() const { - if (d->m_currentMode == Gui) - return d->m_guiProcess.error(); - else + if (d->m_useTerminal) return d->m_consoleProcess.error(); + else + return d->m_guiProcess.error(); } void ApplicationLauncherPrivate::localGuiProcessError() @@ -377,8 +382,7 @@ void ApplicationLauncherPrivate::start(const Runnable &runnable, const IDevice:: WinDebugInterface::instance()->start(); // Try to start listener again... #endif - m_currentMode = runnable.runMode; - if (m_currentMode == ApplicationLauncher::Gui) { + if (!m_useTerminal) { m_guiProcess.setCommand(runnable.executable, runnable.commandLineArguments); m_guiProcess.closeWriteChannel(); m_guiProcess.start(); diff --git a/src/plugins/projectexplorer/applicationlauncher.h b/src/plugins/projectexplorer/applicationlauncher.h index a321c2214d..29e8ef3961 100644 --- a/src/plugins/projectexplorer/applicationlauncher.h +++ b/src/plugins/projectexplorer/applicationlauncher.h @@ -47,15 +47,11 @@ class PROJECTEXPLORER_EXPORT ApplicationLauncher : public QObject Q_OBJECT public: - enum Mode { - Console, - Gui - }; - explicit ApplicationLauncher(QObject *parent = nullptr); ~ApplicationLauncher() override; void setProcessChannelMode(QProcess::ProcessChannelMode mode); + void setUseTerminal(bool on); void start(const Runnable &runnable); void start(const Runnable &runnable, const IDevice::ConstPtr &device); void stop(); diff --git a/src/plugins/projectexplorer/customexecutablerunconfiguration.cpp b/src/plugins/projectexplorer/customexecutablerunconfiguration.cpp index f841f865f6..454a010f59 100644 --- a/src/plugins/projectexplorer/customexecutablerunconfiguration.cpp +++ b/src/plugins/projectexplorer/customexecutablerunconfiguration.cpp @@ -254,7 +254,6 @@ Runnable CustomExecutableRunConfiguration::runnable() const r.executable = extraAspect<ExecutableAspect>()->executable().toString(); r.commandLineArguments = extraAspect<ArgumentsAspect>()->arguments(); r.environment = extraAspect<EnvironmentAspect>()->environment(); - r.runMode = extraAspect<TerminalAspect>()->runMode(); r.workingDirectory = workingDirectory.toString(); r.device = DeviceManager::instance()->defaultDevice(Constants::DESKTOP_DEVICE_TYPE); diff --git a/src/plugins/projectexplorer/runconfiguration.cpp b/src/plugins/projectexplorer/runconfiguration.cpp index fec46bded3..43f636e888 100644 --- a/src/plugins/projectexplorer/runconfiguration.cpp +++ b/src/plugins/projectexplorer/runconfiguration.cpp @@ -466,8 +466,6 @@ Runnable RunConfiguration::runnable() const r.workingDirectory = aspect->workingDirectory().toString(); if (auto aspect = extraAspect<EnvironmentAspect>()) r.environment = aspect->environment(); - if (auto aspect = extraAspect<TerminalAspect>()) - r.runMode = aspect->runMode(); return r; } @@ -1644,12 +1642,17 @@ SimpleTargetRunner::SimpleTargetRunner(RunControl *runControl) setDisplayName("SimpleTargetRunner"); m_runnable = runControl->runnable(); // Default value. Can be overridden using setRunnable. m_device = runControl->device(); // Default value. Can be overridden using setDevice. + if (auto runConfig = runControl->runConfiguration()) { + if (auto terminalAspect = runConfig->extraAspect<TerminalAspect>()) + m_useTerminal = terminalAspect->useTerminal(); + } } void SimpleTargetRunner::start() { m_stopReported = false; m_launcher.disconnect(this); + m_launcher.setUseTerminal(m_useTerminal); const bool isDesktop = m_device.isNull() || m_device->type() == ProjectExplorer::Constants::DESKTOP_DEVICE_TYPE; diff --git a/src/plugins/projectexplorer/runconfiguration.h b/src/plugins/projectexplorer/runconfiguration.h index e8c28b6c7f..506197603f 100644 --- a/src/plugins/projectexplorer/runconfiguration.h +++ b/src/plugins/projectexplorer/runconfiguration.h @@ -166,7 +166,6 @@ public: QString commandLineArguments; QString workingDirectory; Utils::Environment environment; - ApplicationLauncher::Mode runMode = ApplicationLauncher::Gui; IDevice::ConstPtr device; // Override the kit's device. Keep unset by default. // FIXME: Not necessarily a display name @@ -586,6 +585,7 @@ private: Runnable m_runnable; IDevice::ConstPtr m_device; bool m_stopReported = false; + bool m_useTerminal = false; }; } // namespace ProjectExplorer diff --git a/src/plugins/projectexplorer/runconfigurationaspects.cpp b/src/plugins/projectexplorer/runconfigurationaspects.cpp index f2f71a9ba6..6d9d51f48e 100644 --- a/src/plugins/projectexplorer/runconfigurationaspects.cpp +++ b/src/plugins/projectexplorer/runconfigurationaspects.cpp @@ -111,16 +111,6 @@ bool TerminalAspect::isUserSet() const return m_userSet; } -ApplicationLauncher::Mode TerminalAspect::runMode() const -{ - return m_useTerminal ? ApplicationLauncher::Console : ApplicationLauncher::Gui; -} - -void TerminalAspect::setRunMode(ApplicationLauncher::Mode runMode) -{ - setUseTerminal(runMode == ApplicationLauncher::Console); -} - /*! \class ProjectExplorer::WorkingDirectoryAspect */ diff --git a/src/plugins/projectexplorer/runconfigurationaspects.h b/src/plugins/projectexplorer/runconfigurationaspects.h index 8a393e4063..26d56b4080 100644 --- a/src/plugins/projectexplorer/runconfigurationaspects.h +++ b/src/plugins/projectexplorer/runconfigurationaspects.h @@ -55,9 +55,6 @@ public: bool useTerminal() const; void setUseTerminal(bool useTerminal); - ApplicationLauncher::Mode runMode() const; - void setRunMode(ApplicationLauncher::Mode runMode); - bool isUserSet() const; private: diff --git a/src/plugins/pythoneditor/pythoneditorplugin.cpp b/src/plugins/pythoneditor/pythoneditorplugin.cpp index 713416491f..ee20e088c9 100644 --- a/src/plugins/pythoneditor/pythoneditorplugin.cpp +++ b/src/plugins/pythoneditor/pythoneditorplugin.cpp @@ -299,7 +299,6 @@ Runnable PythonRunConfiguration::runnable() const QtcProcess::addArg(&r.commandLineArguments, mainScript()); QtcProcess::addArgs(&r.commandLineArguments, extraAspect<ArgumentsAspect>()->arguments()); r.executable = extraAspect<InterpreterAspect>()->value(); - r.runMode = extraAspect<TerminalAspect>()->runMode(); r.environment = extraAspect<EnvironmentAspect>()->environment(); return r; } diff --git a/src/plugins/qmlprofiler/qmlprofilerruncontrol.cpp b/src/plugins/qmlprofiler/qmlprofilerruncontrol.cpp index 18688ce367..d2ee9434d1 100644 --- a/src/plugins/qmlprofiler/qmlprofilerruncontrol.cpp +++ b/src/plugins/qmlprofiler/qmlprofilerruncontrol.cpp @@ -260,7 +260,6 @@ LocalQmlProfilerSupport::LocalQmlProfilerSupport(QmlProfilerTool *profilerTool, arguments += ' ' + debuggee.commandLineArguments; debuggee.commandLineArguments = arguments; - debuggee.runMode = ApplicationLauncher::Gui; setRunnable(debuggee); } diff --git a/src/plugins/qmlprojectmanager/qmlprojectrunconfiguration.cpp b/src/plugins/qmlprojectmanager/qmlprojectrunconfiguration.cpp index 13f4977f92..0fd9f17f95 100644 --- a/src/plugins/qmlprojectmanager/qmlprojectrunconfiguration.cpp +++ b/src/plugins/qmlprojectmanager/qmlprojectrunconfiguration.cpp @@ -77,7 +77,6 @@ Runnable QmlProjectRunConfiguration::runnable() const Runnable r; r.executable = executable(); r.commandLineArguments = commandLineArguments(); - r.runMode = ApplicationLauncher::Gui; r.environment = extraAspect<QmlProjectEnvironmentAspect>()->environment(); r.workingDirectory = static_cast<QmlProject *>(project())->targetDirectory(target()).toString(); return r; diff --git a/src/plugins/valgrind/callgrind/callgrindcontroller.cpp b/src/plugins/valgrind/callgrind/callgrindcontroller.cpp index 33b3797e97..d0633caa83 100644 --- a/src/plugins/valgrind/callgrind/callgrindcontroller.cpp +++ b/src/plugins/valgrind/callgrind/callgrindcontroller.cpp @@ -128,7 +128,6 @@ void CallgrindController::run(Option option) Runnable controller = m_valgrindRunnable; controller.executable = CALLGRIND_CONTROL_BINARY; - controller.runMode = ApplicationLauncher::Gui; controller.commandLineArguments = QString("%1 %2").arg(toOptionString(option)).arg(m_pid); if (!m_valgrindRunnable.device diff --git a/src/plugins/valgrind/valgrindengine.cpp b/src/plugins/valgrind/valgrindengine.cpp index 82ed9cc0f9..b286fd138d 100644 --- a/src/plugins/valgrind/valgrindengine.cpp +++ b/src/plugins/valgrind/valgrindengine.cpp @@ -38,6 +38,7 @@ #include <projectexplorer/projectexplorericons.h> #include <projectexplorer/runconfiguration.h> +#include <projectexplorer/runconfigurationaspects.h> #include <QApplication> @@ -85,6 +86,9 @@ void ValgrindToolRunner::start() m_runner.setDevice(device()); m_runner.setDebuggee(runnable()); + if (auto aspect = runControl()->runConfiguration()->extraAspect<TerminalAspect>()) + m_runner.setUseTerminal(aspect->useTerminal()); + connect(&m_runner, &ValgrindRunner::processOutputReceived, this, &ValgrindToolRunner::receiveProcessOutput); connect(&m_runner, &ValgrindRunner::valgrindExecuted, diff --git a/src/plugins/valgrind/valgrindrunner.cpp b/src/plugins/valgrind/valgrindrunner.cpp index 86f8c8b4e4..f37d641d39 100644 --- a/src/plugins/valgrind/valgrindrunner.cpp +++ b/src/plugins/valgrind/valgrindrunner.cpp @@ -110,7 +110,6 @@ void ValgrindRunner::Private::run() valgrind.executable = m_valgrindExecutable; valgrind.workingDirectory = m_debuggee.workingDirectory; valgrind.environment = m_debuggee.environment; - valgrind.runMode = m_debuggee.runMode; valgrind.device = m_device; valgrind.commandLineArguments = QtcProcess::joinArgs(fullArgs, m_device->osType()); Utils::QtcProcess::addArgs(&valgrind.commandLineArguments, m_debuggee.commandLineArguments); @@ -258,6 +257,11 @@ void ValgrindRunner::setDevice(const IDevice::ConstPtr &device) d->m_device = device; } +void ValgrindRunner::setUseTerminal(bool on) +{ + d->m_valgrindProcess.setUseTerminal(on); +} + void ValgrindRunner::waitForFinished() const { if (d->m_finished) diff --git a/src/plugins/valgrind/valgrindrunner.h b/src/plugins/valgrind/valgrindrunner.h index aaad50c008..faeafd3a6c 100644 --- a/src/plugins/valgrind/valgrindrunner.h +++ b/src/plugins/valgrind/valgrindrunner.h @@ -50,6 +50,7 @@ public: void setProcessChannelMode(QProcess::ProcessChannelMode mode); void setLocalServerAddress(const QHostAddress &localServerAddress); void setDevice(const ProjectExplorer::IDevice::ConstPtr &device); + void setUseTerminal(bool on); void waitForFinished() const; |