forked from qt-creator/qt-creator
Utils: Fix Terminal.app script for macOS 14
The "where its tab 1 = newTab" fails on macOS 14.0. I've also added some logging to make investigating future potential problems quicker. I've filed feedback to apple here: https://feedbackassistant.apple.com/feedback/13341074 Fixes: QTCREATORBUG-29246 Change-Id: I79c6f75daa34a3c346934ee2c21a5dfc9daf3cff Reviewed-by: Eike Ziller <eike.ziller@qt.io> Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
This commit is contained in:
@@ -8,7 +8,11 @@
|
|||||||
#include "terminalcommand.h"
|
#include "terminalcommand.h"
|
||||||
#include "utilstr.h"
|
#include "utilstr.h"
|
||||||
|
|
||||||
|
#include <QLoggingCategory>
|
||||||
#include <QTemporaryFile>
|
#include <QTemporaryFile>
|
||||||
|
#include <QVersionNumber>
|
||||||
|
|
||||||
|
Q_LOGGING_CATEGORY(log, "terminal.externalprocess", QtWarningMsg)
|
||||||
|
|
||||||
namespace Utils {
|
namespace Utils {
|
||||||
|
|
||||||
@@ -33,6 +37,16 @@ static const QLatin1String TerminalAppScriptAttached{R"(
|
|||||||
end tell
|
end tell
|
||||||
)"};
|
)"};
|
||||||
|
|
||||||
|
static const QLatin1String TerminalAppScriptAttachedWithoutWindowClose{R"(
|
||||||
|
tell application "Terminal"
|
||||||
|
activate
|
||||||
|
set newTab to do script "%1 && exit"
|
||||||
|
repeat until ((count of processes of newTab) = 0)
|
||||||
|
delay 0.1
|
||||||
|
end repeat
|
||||||
|
end tell
|
||||||
|
)"};
|
||||||
|
|
||||||
static const QLatin1String TerminalAppScriptDetached{R"(
|
static const QLatin1String TerminalAppScriptDetached{R"(
|
||||||
tell application "Terminal"
|
tell application "Terminal"
|
||||||
activate
|
activate
|
||||||
@@ -52,8 +66,17 @@ expected_str<qint64> ProcessStubCreator::startStubProcess(const ProcessSetupData
|
|||||||
bool detached = setupData.m_terminalMode == TerminalMode::Detached;
|
bool detached = setupData.m_terminalMode == TerminalMode::Detached;
|
||||||
|
|
||||||
if (HostOsInfo::isMacHost()) {
|
if (HostOsInfo::isMacHost()) {
|
||||||
|
// There is a bug in macOS 14.0 where the script fails if it tries to find
|
||||||
|
// the window id. We will have to check in future versions of macOS if they fixed
|
||||||
|
// the issue.
|
||||||
|
static const QVersionNumber osVersionNumber = QVersionNumber::fromString(
|
||||||
|
QSysInfo::productVersion());
|
||||||
|
|
||||||
static const QMap<QString, AppScript> terminalMap = {
|
static const QMap<QString, AppScript> terminalMap = {
|
||||||
{"Terminal.app", {TerminalAppScriptAttached, TerminalAppScriptDetached}},
|
{"Terminal.app",
|
||||||
|
{osVersionNumber.majorVersion() >= 14 ? TerminalAppScriptAttachedWithoutWindowClose
|
||||||
|
: TerminalAppScriptAttached,
|
||||||
|
TerminalAppScriptDetached}},
|
||||||
};
|
};
|
||||||
|
|
||||||
if (terminalMap.contains(terminal.command.toString())) {
|
if (terminalMap.contains(terminal.command.toString())) {
|
||||||
@@ -101,6 +124,17 @@ expected_str<qint64> ProcessStubCreator::startStubProcess(const ProcessSetupData
|
|||||||
Tr::tr("Failed to start terminal process: \"%1\".").arg(process->errorString()));
|
Tr::tr("Failed to start terminal process: \"%1\".").arg(process->errorString()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QObject::connect(process, &Process::readyReadStandardOutput, process, [process] {
|
||||||
|
const QString output = process->readAllStandardOutput();
|
||||||
|
if (!output.isEmpty())
|
||||||
|
qCWarning(log).noquote() << output;
|
||||||
|
});
|
||||||
|
QObject::connect(process, &Process::readyReadStandardError, process, [process] {
|
||||||
|
const QString output = process->readAllStandardError();
|
||||||
|
if (!output.isEmpty())
|
||||||
|
qCCritical(log).noquote() << output;
|
||||||
|
});
|
||||||
|
|
||||||
QObject::connect(process, &Process::done, m_interface, &TerminalInterface::onStubExited);
|
QObject::connect(process, &Process::done, m_interface, &TerminalInterface::onStubExited);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
Reference in New Issue
Block a user