diff options
author | Sefa Eyeoglu <contact@scrumplex.net> | 2023-03-21 18:28:32 +0100 |
---|---|---|
committer | Sefa Eyeoglu <contact@scrumplex.net> | 2023-03-21 18:30:46 +0100 |
commit | 44bf32e729294d8ede069f9fd952b9104b34b695 (patch) | |
tree | 063e1e44f21cbaccd7d4a29ef103e2c145ea2abb | |
parent | 6dcf34acdc8ec3dcbb094e4981ef136cd6a99913 (diff) | |
download | PrismLauncher-44bf32e729294d8ede069f9fd952b9104b34b695.tar.gz PrismLauncher-44bf32e729294d8ede069f9fd952b9104b34b695.tar.bz2 PrismLauncher-44bf32e729294d8ede069f9fd952b9104b34b695.zip |
fix: handle partial lines in LoggedProcess
Fixes PrismLauncher/PrismLauncher#930
Co-authored-by: flow <flowlnlnln@gmail.com>
Signed-off-by: Sefa Eyeoglu <contact@scrumplex.net>
-rw-r--r-- | launcher/LoggedProcess.cpp | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/launcher/LoggedProcess.cpp b/launcher/LoggedProcess.cpp index 6447f5c6..43a9c4f6 100644 --- a/launcher/LoggedProcess.cpp +++ b/launcher/LoggedProcess.cpp @@ -1,7 +1,8 @@ // SPDX-License-Identifier: GPL-3.0-only /* - * PolyMC - Minecraft Launcher - * Copyright (C) 2022 Sefa Eyeoglu <contact@scrumplex.net> + * Prism Launcher - Minecraft Launcher + * Copyright (C) 2022,2023 Sefa Eyeoglu <contact@scrumplex.net> + * Copyright (c) 2023 flowln <flowlnlnln@gmail.com> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -60,14 +61,26 @@ LoggedProcess::~LoggedProcess() } } +static QString m_leftover_line; + QStringList reprocess(const QByteArray& data, QTextDecoder& decoder) { auto str = decoder.toUnicode(data); + + // FIXME: Flush this out when process exits + if (!m_leftover_line.isEmpty()) { + str.prepend(m_leftover_line); + m_leftover_line = ""; + } + #if QT_VERSION < QT_VERSION_CHECK(5, 14, 0) auto lines = str.remove(QChar::CarriageReturn).split(QChar::LineFeed, QString::SkipEmptyParts); #else auto lines = str.remove(QChar::CarriageReturn).split(QChar::LineFeed, Qt::SkipEmptyParts); #endif + + if (!str.endsWith(QChar::LineFeed)) + m_leftover_line = lines.takeLast(); return lines; } |