mirror of
https://gitlab.com/kelteseth/ScreenPlay.git
synced 2024-11-25 12:13:00 +01:00
Fix crash on startup with fmt and unbuffered output
This commit is contained in:
parent
b8560d6e48
commit
e472260030
@ -107,3 +107,7 @@ if(WIN32)
|
|||||||
# Used for query windows monitor data
|
# Used for query windows monitor data
|
||||||
target_link_libraries(${PROJECT_NAME} PUBLIC shcore.lib)
|
target_link_libraries(${PROJECT_NAME} PUBLIC shcore.lib)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
# ##### USE CMAKE VARIABLES IN CODE #####
|
||||||
|
include(GenerateCMakeVariableHeader)
|
||||||
|
generate_cmake_variable_header(${PROJECT_NAME})
|
||||||
|
@ -8,6 +8,8 @@
|
|||||||
#include <QUrl>
|
#include <QUrl>
|
||||||
#include <fmt/color.h>
|
#include <fmt/color.h>
|
||||||
|
|
||||||
|
#include "ScreenPlayUtil/CMakeVariables.h"
|
||||||
|
|
||||||
#ifdef Q_OS_WINDOWS
|
#ifdef Q_OS_WINDOWS
|
||||||
#ifndef NOMINMAX
|
#ifndef NOMINMAX
|
||||||
#define NOMINMAX
|
#define NOMINMAX
|
||||||
@ -29,11 +31,14 @@ LoggingHandler::LoggingHandler(const QString& logFileName)
|
|||||||
#ifdef Q_OS_WINDOWS
|
#ifdef Q_OS_WINDOWS
|
||||||
// Enable UTF-8 support
|
// Enable UTF-8 support
|
||||||
SetConsoleOutputCP(CP_UTF8);
|
SetConsoleOutputCP(CP_UTF8);
|
||||||
|
// This is a QtCreator workaround and crashes std::fmt
|
||||||
// QtCreator has issues with fmt prints
|
// when running standalone.
|
||||||
// https://bugreports.qt.io/browse/QTCREATORBUG-3994
|
if (!SCREENPLAY_DEPLOY_VERSION) {
|
||||||
setbuf(stdout, NULL);
|
// QtCreator has issues with fmt prints
|
||||||
|
// https://bugreports.qt.io/browse/QTCREATORBUG-3994
|
||||||
|
setvbuf(stdout, NULL, _IONBF, 0);
|
||||||
|
qInfo() << "Setting setvbuf(stdout, NULL, _IONBF, 0); This unbuffered output causes crashes in release with threaded fmt!";
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
qSetMessagePattern("[%{time dd.MM.yyyy h:mm:ss.zzz} %{if-debug}Debug%{endif}%{if-info}Info%{endif}%{if-warning}Warning%{endif}%{if-critical}Critical%{endif}%{if-fatal}Fatal%{endif}] %{file}:%{line} - %{message}");
|
qSetMessagePattern("[%{time dd.MM.yyyy h:mm:ss.zzz} %{if-debug}Debug%{endif}%{if-info}Info%{endif}%{if-warning}Warning%{endif}%{if-critical}Critical%{endif}%{if-fatal}Fatal%{endif}] %{file}:%{line} - %{message}");
|
||||||
@ -227,7 +232,6 @@ void LoggingHandler::writeToConsole(QtMsgType type, const QMessageLogContext& co
|
|||||||
const auto filename = extractFileName(context);
|
const auto filename = extractFileName(context);
|
||||||
const auto function = extractFunction(context);
|
const auto function = extractFunction(context);
|
||||||
const auto line = context.line;
|
const auto line = context.line;
|
||||||
|
|
||||||
fmt::print(
|
fmt::print(
|
||||||
"[{}] {} {}:{} - {}\n",
|
"[{}] {} {}:{} - {}\n",
|
||||||
fmt::styled(now.toStdString(), fmt::emphasis::bold),
|
fmt::styled(now.toStdString(), fmt::emphasis::bold),
|
||||||
|
Loading…
Reference in New Issue
Block a user