From 9bcaf9ced9190e9f6db09daa936d449fa7ee39ac Mon Sep 17 00:00:00 2001 From: David Schulz Date: Tue, 9 Jan 2024 12:57:44 +0100 Subject: [PATCH] ProjectExplorer: do not concatenate win debug messages Individual debug messages got concatenated without a newline character if multiple messages were received by the windebug interface thread before they were handled in the main thread. The receiver of those messages had no chance of handling those messages individually. This gets fixed by using a list of messages instead of one concatenated string. Change-Id: Icfaf1b22db56829fcd143e574ee1033a63226c29 Reviewed-by: Christian Stenger Reviewed-by: --- src/plugins/projectexplorer/runcontrol.cpp | 14 +++++++---- .../projectexplorer/windebuginterface.cpp | 23 ++++++++++--------- .../projectexplorer/windebuginterface.h | 2 +- 3 files changed, 22 insertions(+), 17 deletions(-) diff --git a/src/plugins/projectexplorer/runcontrol.cpp b/src/plugins/projectexplorer/runcontrol.cpp index 5de202b946a..94093fe1507 100644 --- a/src/plugins/projectexplorer/runcontrol.cpp +++ b/src/plugins/projectexplorer/runcontrol.cpp @@ -1272,11 +1272,15 @@ SimpleTargetRunnerPrivate::SimpleTargetRunnerPrivate(SimpleTargetRunner *parent) + QLatin1Char('\n'), ErrorMessageFormat); }); - connect(WinDebugInterface::instance(), &WinDebugInterface::debugOutput, - this, [this](qint64 pid, const QString &message) { - if (privateApplicationPID() == pid) - q->appendMessage(message, DebugFormat); - }); + connect(WinDebugInterface::instance(), + &WinDebugInterface::debugOutput, + this, + [this](qint64 pid, const QList &messages) { + if (privateApplicationPID() != pid) + return; + for (const QString &message : messages) + q->appendMessage(message, DebugFormat); + }); } } diff --git a/src/plugins/projectexplorer/windebuginterface.cpp b/src/plugins/projectexplorer/windebuginterface.cpp index 25f525e9efc..75285669a40 100644 --- a/src/plugins/projectexplorer/windebuginterface.cpp +++ b/src/plugins/projectexplorer/windebuginterface.cpp @@ -150,22 +150,23 @@ void WinDebugInterface::dispatchDebugOutput() QTC_ASSERT(Utils::isMainThread(), return); static size_t maxMessagesToSend = 100; - std::vector> output; + std::map> output; bool hasMoreOutput = false; m_outputMutex.lock(); for (auto &entry : m_debugOutput) { - std::vector &src = entry.second; - if (src.empty()) - continue; - QString dst; - size_t n = std::min(maxMessagesToSend, src.size()); - for (size_t i = 0; i < n; ++i) - dst += src.at(i); - src.erase(src.begin(), std::next(src.begin(), n)); - if (!src.empty()) + auto it = entry.second.begin(); + for (; it != entry.second.end(); ++it) { + output[entry.first].push_back(*it); + if (output.size() >= maxMessagesToSend) + break; + } + if (it != entry.second.begin()) + it = entry.second.erase(entry.second.begin(), it); + if (it != entry.second.end()) { hasMoreOutput = true; - output.emplace_back(entry.first, std::move(dst)); + break; + } } if (!hasMoreOutput) m_readySignalEmitted = false; diff --git a/src/plugins/projectexplorer/windebuginterface.h b/src/plugins/projectexplorer/windebuginterface.h index a9d78fc1115..e759e2252c5 100644 --- a/src/plugins/projectexplorer/windebuginterface.h +++ b/src/plugins/projectexplorer/windebuginterface.h @@ -27,7 +27,7 @@ public: static void startIfNeeded(); signals: - void debugOutput(qint64 pid, const QString &message); + void debugOutput(qint64 pid, const QList &messages); void cannotRetrieveDebugOutput(); void _q_debugOutputReady();