diff options
author | Sefa Eyeoglu <contact@scrumplex.net> | 2023-03-25 10:37:02 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-03-25 10:37:02 +0100 |
commit | 09d607f39c47a467de5dde260e90771ad0ac51df (patch) | |
tree | 4c85db95ddafed67b3e6f57c5896d9c68df18ab6 /launcher | |
parent | 6dcf34acdc8ec3dcbb094e4981ef136cd6a99913 (diff) | |
parent | 9418c62d95d8a9e829b087386cba2e2b6137daf1 (diff) | |
download | PrismLauncher-09d607f39c47a467de5dde260e90771ad0ac51df.tar.gz PrismLauncher-09d607f39c47a467de5dde260e90771ad0ac51df.tar.bz2 PrismLauncher-09d607f39c47a467de5dde260e90771ad0ac51df.zip |
Merge pull request #945 from Scrumplex/fix-logging-newlines
Diffstat (limited to 'launcher')
-rw-r--r-- | launcher/LoggedProcess.cpp | 16 | ||||
-rw-r--r-- | launcher/LoggedProcess.h | 7 |
2 files changed, 18 insertions, 5 deletions
diff --git a/launcher/LoggedProcess.cpp b/launcher/LoggedProcess.cpp index 6447f5c6..c8d5c34e 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,23 @@ LoggedProcess::~LoggedProcess() } } -QStringList reprocess(const QByteArray& data, QTextDecoder& decoder) +QStringList LoggedProcess::reprocess(const QByteArray& data, QTextDecoder& decoder) { auto str = decoder.toUnicode(data); + + 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; } diff --git a/launcher/LoggedProcess.h b/launcher/LoggedProcess.h index 2360d1ea..af3ed79f 100644 --- a/launcher/LoggedProcess.h +++ b/launcher/LoggedProcess.h @@ -1,7 +1,7 @@ // 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> * * 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 @@ -88,9 +88,12 @@ private slots: private: void changeState(LoggedProcess::State state); + QStringList reprocess(const QByteArray& data, QTextDecoder& decoder); + private: QTextDecoder m_err_decoder = QTextDecoder(QTextCodec::codecForLocale()); QTextDecoder m_out_decoder = QTextDecoder(QTextCodec::codecForLocale()); + QString m_leftover_line; bool m_killed = false; State m_state = NotRunning; int m_exit_code = 0; |