From 02d7e59a2e51e22026cee8eadd509e7508c008ec Mon Sep 17 00:00:00 2001 From: Marcus Tillmanns Date: Thu, 9 Jan 2025 07:06:09 +0100 Subject: [PATCH] Terminal: Fix Id m_commandLine is not useful to distinguish terminals as it may contain wrapper scripts with temporary arguments that make each invocation of a target spawn a new terminal window. Instead use the provided "shell name". Also make sure to use the actual target name as the shell name in runcontrol. Fixes: QTCREATORBUG-32197 Change-Id: I8c0760be375d559391dbd831080aa7153786f411 Reviewed-by: Cristian Adam --- src/plugins/projectexplorer/runcontrol.cpp | 3 ++- src/plugins/terminal/terminalprocessimpl.cpp | 15 ++++++++------- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/plugins/projectexplorer/runcontrol.cpp b/src/plugins/projectexplorer/runcontrol.cpp index a008fdf2fd7..31d05b14c14 100644 --- a/src/plugins/projectexplorer/runcontrol.cpp +++ b/src/plugins/projectexplorer/runcontrol.cpp @@ -1586,7 +1586,8 @@ void SimpleTargetRunnerPrivate::start() m_stopRequested = false; QVariantHash extraData = m_extraData; - extraData[TERMINAL_SHELL_NAME] = m_command.executable().fileName(); + extraData[TERMINAL_SHELL_NAME] + = q->runControl()->target()->activeRunConfiguration()->displayName(); m_process.setCommand(cmdLine); m_process.setEnvironment(env); diff --git a/src/plugins/terminal/terminalprocessimpl.cpp b/src/plugins/terminal/terminalprocessimpl.cpp index 3ae7d360928..33efbf49cc4 100644 --- a/src/plugins/terminal/terminalprocessimpl.cpp +++ b/src/plugins/terminal/terminalprocessimpl.cpp @@ -35,7 +35,12 @@ public: return m_fallbackStubCreator->startStubProcess(setup); } - const Id id = Id::fromString(setup.m_commandLine.toUserOutput()); + const QString shellName + = setup.m_extraData + .value(TERMINAL_SHELL_NAME, setup.m_commandLine.executable().fileName()) + .toString(); + + const Id id = Id::fromString(shellName); TerminalWidget *terminal = m_terminalPane->stoppedTerminalWithId(id); @@ -45,14 +50,10 @@ public: if (!terminal) { terminal = new TerminalWidget(nullptr, openParameters); - - terminal->setShellName( - setup.m_extraData - .value(TERMINAL_SHELL_NAME, setup.m_commandLine.executable().fileName()) - .toString()); - + terminal->setShellName(shellName); m_terminalPane->addTerminal(terminal, "App"); } else { + terminal->setShellName(shellName); terminal->restart(openParameters); }