summaryrefslogtreecommitdiffhomepage
path: root/gui
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2019-01-11 05:37:28 +0100
committerStanislaw Halik <sthalik@misaki.pl>2019-01-16 07:48:48 +0100
commitc0f76664c1035dabe999ca07522227e9a40a251d (patch)
treec9fe91a6f426fab0f0e4bd77ee4610b4fa3aea5c /gui
parent775ed92ab6fbbe89712f800f2f603054d7466ff0 (diff)
gui/init: disable spinlock in common case
Diffstat (limited to 'gui')
-rw-r--r--gui/init.cpp12
1 files changed, 4 insertions, 8 deletions
diff --git a/gui/init.cpp b/gui/init.cpp
index 04334782..5ed4ca00 100644
--- a/gui/init.cpp
+++ b/gui/init.cpp
@@ -113,14 +113,14 @@ 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;
-
#ifdef _WIN32
+ static_assert(sizeof(wchar_t) == sizeof(decltype(*msg.utf16())));
+
if (IsDebuggerPresent())
{
+ static std::atomic_flag lock = ATOMIC_FLAG_INIT;
spinlock_guard l(lock);
- static_assert(sizeof(wchar_t) == sizeof(decltype(*msg.utf16())));
const wchar_t* const bytes = (const wchar_t*)msg.utf16();
OutputDebugStringW(bytes);
@@ -138,11 +138,7 @@ static void qdebug_to_console(QtMsgType, const QMessageLogContext& ctx, const QS
(void)msg.toWCharArray(bytes);
#endif
{
- spinlock_guard l(lock);
-
- if (ctx.function)
- std::fprintf(stderr, "[%s:%d] %s: %ls\n", ctx.file, ctx.line, ctx.function, bytes);
- else if (ctx.file)
+ if (ctx.file)
std::fprintf(stderr, "[%s:%d]: %ls\n", ctx.file, ctx.line, bytes);
else
std::fprintf(stderr, "%ls\n", bytes);