diff options
author | Stanislaw Halik <sthalik@misaki.pl> | 2019-01-02 12:57:04 +0100 |
---|---|---|
committer | Stanislaw Halik <sthalik@misaki.pl> | 2019-01-16 07:48:19 +0100 |
commit | 03e2279c68bf784cd90d20a7556d8fdad492e8c0 (patch) | |
tree | 2a19fb3519a6ec9822a00200667008dee3a75ac5 /gui/init.cpp | |
parent | 3cf0d03a1955489dea2c66435c78912d66d4e435 (diff) |
gui: fix `if constexpr' misuse
Diffstat (limited to 'gui/init.cpp')
-rw-r--r-- | gui/init.cpp | 47 |
1 files changed, 21 insertions, 26 deletions
diff --git a/gui/init.cpp b/gui/init.cpp index 66fceb3f..3fe9813f 100644 --- a/gui/init.cpp +++ b/gui/init.cpp @@ -103,41 +103,36 @@ static void set_qt_style() static void qdebug_to_console(QtMsgType, const QMessageLogContext& ctx, const QString &msg) { static std::atomic_flag lock = ATOMIC_FLAG_INIT; - const auto bytes{msg.toUtf8()}; - constexpr bool is_win32 = #ifdef _WIN32 - true; -#else - false; -#endif + if (IsDebuggerPresent()) + { + spinlock_guard l(lock); + static_assert(sizeof(wchar_t) == sizeof(decltype(*msg.utf16()))); + const wchar_t* const bytes = (const wchar_t*)msg.utf16(); - if constexpr (is_win32) + OutputDebugStringW(bytes); + OutputDebugStringW(L"\n"); + } + else +#endif { - if (IsDebuggerPresent()) + QByteArray bytes{msg.toUtf8()}; + + std::fflush(stderr); + const char* const s = bytes.constData(); { spinlock_guard l(lock); - OutputDebugStringA(bytes.constData()); - OutputDebugStringA("\n"); - } - else - { - std::fflush(stderr); - const char* const s = bytes.constData(); - { - spinlock_guard l(lock); - - if (ctx.function) - std::fprintf(stderr, "[%s:%d] %s: %s\n", ctx.file, ctx.line, ctx.function, s); - else if (ctx.file) - std::fprintf(stderr, "[%s:%d]: %s\n", ctx.file, ctx.line, s); - else - std::fprintf(stderr, "%s\n", s); - } - std::fflush(stderr); + if (ctx.function) + std::fprintf(stderr, "[%s:%d] %s: %s\n", ctx.file, ctx.line, ctx.function, s); + else if (ctx.file) + std::fprintf(stderr, "[%s:%d]: %s\n", ctx.file, ctx.line, s); + else + std::fprintf(stderr, "%s\n", s); } + std::fflush(stderr); } } |