summaryrefslogtreecommitdiffstats
path: root/src/corelib/global/qlogging.cpp
diff options
context:
space:
mode:
authorQt Forward Merge Bot <qt_forward_merge_bot@qt-project.org>2020-02-04 01:00:59 +0100
committerEdward Welbourne <edward.welbourne@qt.io>2020-02-04 10:44:00 +0100
commit97417e8f2896bfbe1d9e9a703ddba980983d1442 (patch)
treeecee79f9b126bc695904e74000c0775d1ef34646 /src/corelib/global/qlogging.cpp
parent02eb9df851093f11872c828869226903c81f1b60 (diff)
parent056230cc9c3309823a93df0e34c92affb29df9e4 (diff)
Merge remote-tracking branch 'origin/5.14' into 5.15
Conflicts: .qmake.conf examples/widgets/widgets/imageviewer/imageviewer.cpp src/corelib/text/qchar.cpp src/corelib/time/qdatetime.cpp Change-Id: I9762f5c4ff650799219729d6aee79ac07ce9024a
Diffstat (limited to 'src/corelib/global/qlogging.cpp')
-rw-r--r--src/corelib/global/qlogging.cpp30
1 files changed, 25 insertions, 5 deletions
diff --git a/src/corelib/global/qlogging.cpp b/src/corelib/global/qlogging.cpp
index c1a45476f9..89f49324c0 100644
--- a/src/corelib/global/qlogging.cpp
+++ b/src/corelib/global/qlogging.cpp
@@ -1669,14 +1669,34 @@ static bool android_default_message_handler(QtMsgType type,
#endif //Q_OS_ANDROID
#ifdef Q_OS_WIN
+static void win_outputDebugString_helper(QStringView message)
+{
+ const int maxOutputStringLength = 32766;
+ static QBasicMutex m;
+ auto locker = qt_unique_lock(m);
+ // fast path: Avoid string copies if one output is enough
+ if (message.length() <= maxOutputStringLength) {
+ OutputDebugString(reinterpret_cast<const wchar_t *>(message.utf16()));
+ } else {
+ wchar_t *messagePart = new wchar_t[maxOutputStringLength + 1];
+ for (int i = 0; i < message.length(); i += maxOutputStringLength ) {
+ const int length = std::min(message.length() - i, maxOutputStringLength );
+ const int len = message.mid(i, length).toWCharArray(messagePart);
+ Q_ASSERT(len == length);
+ messagePart[len] = 0;
+ OutputDebugString(messagePart);
+ }
+ delete[] messagePart;
+ }
+}
+
static bool win_message_handler(QtMsgType type, const QMessageLogContext &context, const QString &message)
{
if (shouldLogToStderr())
return false; // Leave logging up to stderr handler
- QString formattedMessage = qFormatLogMessage(type, context, message);
- formattedMessage.append(QLatin1Char('\n'));
- OutputDebugString(reinterpret_cast<const wchar_t *>(formattedMessage.utf16()));
+ const QString formattedMessage = qFormatLogMessage(type, context, message).append('\n');
+ win_outputDebugString_helper(formattedMessage);
return true; // Prevent further output to stderr
}
@@ -1832,11 +1852,11 @@ static void qt_message_print(QtMsgType msgType, const QMessageLogContext &contex
static void qt_message_print(const QString &message)
{
#if defined(Q_OS_WINRT)
- OutputDebugString(reinterpret_cast<const wchar_t*>(message.utf16()));
+ win_outputDebugString_helper(message);
return;
#elif defined(Q_OS_WIN) && !defined(QT_BOOTSTRAPPED)
if (!shouldLogToStderr()) {
- OutputDebugString(reinterpret_cast<const wchar_t*>(message.utf16()));
+ win_outputDebugString_helper(message);
return;
}
#endif