Fix compilation for Qt < 6.9

readLineInto is not available in older Qt
This commit is contained in:
Waqar Ahmed
2025-09-10 11:36:06 +05:00
parent 578d7c0aa1
commit 8e9d7a70a4
3 changed files with 11 additions and 8 deletions

View File

@@ -845,8 +845,9 @@ public:
KSandbox::startHostProcess(proc, QProcess::ReadOnly);
if (proc.waitForStarted() && proc.waitForFinished()) {
proc.setReadChannel(QProcess::StandardOutput);
quint8 buffer[4096];
auto line = proc.readLineInto(buffer).trimmed();
char buffer[4096];
int readCount = proc.readLine(buffer, sizeof(buffer));
auto line = readCount > 0 ? QByteArrayView(buffer, readCount).trimmed() : QByteArrayView();
if (int colon = line.indexOf(": "); colon != -1) {
setCurrentDir(QString::fromUtf8(line.mid(colon + 2)));
return true;

View File

@@ -311,15 +311,16 @@ int Pty::foregroundProcessGroup() const
QStringLiteral("%p\t"),
QStringLiteral("-o"),
QStringLiteral("stat"),
QStringLiteral("-t"),
QStringLiteral("%1").arg(pty()->ttyName()),
QStringLiteral("--tty"),
QString::fromLatin1(pty()->ttyName()),
QStringLiteral("--no-headers")});
KSandbox::startHostProcess(proc, QProcess::ReadOnly);
if (proc.waitForStarted() && proc.waitForFinished()) {
while (proc.canReadLine()) {
quint8 buffer[256];
const QByteArrayView line = proc.readLineInto(buffer);
char buffer[256];
int readCount = proc.readLine(buffer, sizeof(buffer));
auto line = readCount > 0 ? QByteArrayView(buffer, readCount) : QByteArrayView();
int i = line.indexOf('\t');
if (i == -1) {
return 0;

View File

@@ -1239,8 +1239,9 @@ void Session::updateSessionProcessInfo()
KSandbox::startHostProcess(proc, QProcess::ReadOnly);
if (proc.waitForStarted() && proc.waitForFinished()) {
proc.setReadChannel(QProcess::StandardOutput);
quint8 buffer[256];
auto line = proc.readLineInto(buffer).trimmed();
char buffer[256];
int readCount = proc.readLine(buffer, sizeof(buffer));
auto line = readCount > 0 ? QByteArrayView(buffer, readCount).trimmed() : QByteArrayView();
bool ok;
auto pid = line.toInt(&ok);
if (ok) {