diff options
author | KosmX <kosmx.mc@gmail.com> | 2023-02-01 14:59:11 +0100 |
---|---|---|
committer | KosmX <kosmx.mc@gmail.com> | 2023-02-01 14:59:11 +0100 |
commit | ec5bb944b24413c1dee30a2a8429f484231c60c1 (patch) | |
tree | 84457c300ddd5dcd1809e22fa19cb1346d006e84 | |
parent | deed49574ac344f126eed5fd71f7151c72ff79ac (diff) | |
download | PrismLauncher-ec5bb944b24413c1dee30a2a8429f484231c60c1.tar.gz PrismLauncher-ec5bb944b24413c1dee30a2a8429f484231c60c1.tar.bz2 PrismLauncher-ec5bb944b24413c1dee30a2a8429f484231c60c1.zip |
thread-safe logger
Signed-off-by: KosmX <kosmx.mc@gmail.com>
-rw-r--r-- | launcher/Application.cpp | 2 | ||||
-rw-r--r-- | launcher/Application.h | 2 |
2 files changed, 4 insertions, 0 deletions
diff --git a/launcher/Application.cpp b/launcher/Application.cpp index 387f735c..ae7a69c6 100644 --- a/launcher/Application.cpp +++ b/launcher/Application.cpp @@ -150,6 +150,8 @@ namespace { /** This is used so that we can output to the log file in addition to the CLI. */ void appDebugOutput(QtMsgType type, const QMessageLogContext &context, const QString &msg) { + const std::lock_guard<std::mutex> lock(APPLICATION->loggerMutex); // synchronized, QFile logFile is not thread-safe + QString out = qFormatLogMessage(type, context, msg); out += QChar::LineFeed; diff --git a/launcher/Application.h b/launcher/Application.h index 1b3dc499..caee074d 100644 --- a/launcher/Application.h +++ b/launcher/Application.h @@ -45,6 +45,7 @@ #include <QUrl> #include <BaseInstance.h> +#include <mutex> #include "minecraft/launch/MinecraftServerTarget.h" @@ -310,4 +311,5 @@ public: QList<QUrl> m_zipsToImport; QString m_instanceIdToShowWindowOf; std::unique_ptr<QFile> logFile; + std::mutex loggerMutex; }; |