Use UTF-8 to decode logs on Java 18 or newer
Signed-off-by: TheKodeToad <TheKodeToad@proton.me>
This commit is contained in:
parent
909114bf2a
commit
98adcc60a3
@ -39,7 +39,8 @@
|
||||
#include <QTextDecoder>
|
||||
#include "MessageLevel.h"
|
||||
|
||||
LoggedProcess::LoggedProcess(QObject* parent) : QProcess(parent)
|
||||
LoggedProcess::LoggedProcess(const QTextCodec* output_codec, QObject* parent)
|
||||
: QProcess(parent), m_err_decoder(output_codec), m_out_decoder(output_codec)
|
||||
{
|
||||
// QProcess has a strange interface... let's map a lot of those into a few.
|
||||
connect(this, &QProcess::readyReadStandardOutput, this, &LoggedProcess::on_stdOut);
|
||||
|
@ -49,7 +49,7 @@ class LoggedProcess : public QProcess {
|
||||
enum State { NotRunning, Starting, FailedToStart, Running, Finished, Crashed, Aborted };
|
||||
|
||||
public:
|
||||
explicit LoggedProcess(QObject* parent = 0);
|
||||
explicit LoggedProcess(const QTextCodec* output_codec = QTextCodec::codecForLocale(), QObject* parent = 0);
|
||||
virtual ~LoggedProcess();
|
||||
|
||||
State state() const;
|
||||
@ -80,8 +80,8 @@ class LoggedProcess : public QProcess {
|
||||
QStringList reprocess(const QByteArray& data, QTextDecoder& decoder);
|
||||
|
||||
private:
|
||||
QTextDecoder m_err_decoder = QTextDecoder(QTextCodec::codecForLocale());
|
||||
QTextDecoder m_out_decoder = QTextDecoder(QTextCodec::codecForLocale());
|
||||
QTextDecoder m_err_decoder;
|
||||
QTextDecoder m_out_decoder;
|
||||
QString m_leftover_line;
|
||||
bool m_killed = false;
|
||||
State m_state = NotRunning;
|
||||
|
@ -48,6 +48,12 @@ bool JavaVersion::requiresPermGen() const
|
||||
return !m_parseable || m_major < 8;
|
||||
}
|
||||
|
||||
bool JavaVersion::defaultsToUtf8() const
|
||||
{
|
||||
// starting from Java 18, UTF-8 is the default charset: https://openjdk.org/jeps/400
|
||||
return m_parseable && m_major >= 18;
|
||||
}
|
||||
|
||||
bool JavaVersion::isModular() const
|
||||
{
|
||||
return m_parseable && m_major >= 9;
|
||||
|
@ -25,7 +25,7 @@ class JavaVersion {
|
||||
bool operator>(const JavaVersion& rhs);
|
||||
|
||||
bool requiresPermGen() const;
|
||||
|
||||
bool defaultsToUtf8() const;
|
||||
bool isModular() const;
|
||||
|
||||
QString toString() const;
|
||||
|
@ -48,7 +48,9 @@
|
||||
#include "gamemode_client.h"
|
||||
#endif
|
||||
|
||||
LauncherPartLaunch::LauncherPartLaunch(LaunchTask* parent) : LaunchStep(parent)
|
||||
LauncherPartLaunch::LauncherPartLaunch(LaunchTask* parent)
|
||||
: LaunchStep(parent)
|
||||
, m_process(parent->instance()->getJavaVersion().defaultsToUtf8() ? QTextCodec::codecForName("UTF-8") : QTextCodec::codecForLocale())
|
||||
{
|
||||
if (parent->instance()->settings()->get("CloseAfterLaunch").toBool()) {
|
||||
std::shared_ptr<QMetaObject::Connection> connection{ new QMetaObject::Connection };
|
||||
|
Loading…
Reference in New Issue
Block a user