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 <christian.stenger@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
This commit is contained in:
David Schulz
2024-01-09 12:57:44 +01:00
parent a6dea9091f
commit 9bcaf9ced9
3 changed files with 22 additions and 17 deletions

View File

@@ -1272,9 +1272,13 @@ SimpleTargetRunnerPrivate::SimpleTargetRunnerPrivate(SimpleTargetRunner *parent)
+ QLatin1Char('\n'), ErrorMessageFormat); + QLatin1Char('\n'), ErrorMessageFormat);
}); });
connect(WinDebugInterface::instance(), &WinDebugInterface::debugOutput, connect(WinDebugInterface::instance(),
this, [this](qint64 pid, const QString &message) { &WinDebugInterface::debugOutput,
if (privateApplicationPID() == pid) this,
[this](qint64 pid, const QList<QString> &messages) {
if (privateApplicationPID() != pid)
return;
for (const QString &message : messages)
q->appendMessage(message, DebugFormat); q->appendMessage(message, DebugFormat);
}); });
} }

View File

@@ -150,22 +150,23 @@ void WinDebugInterface::dispatchDebugOutput()
QTC_ASSERT(Utils::isMainThread(), return); QTC_ASSERT(Utils::isMainThread(), return);
static size_t maxMessagesToSend = 100; static size_t maxMessagesToSend = 100;
std::vector<std::pair<qint64, QString>> output; std::map<qint64, QList<QString>> output;
bool hasMoreOutput = false; bool hasMoreOutput = false;
m_outputMutex.lock(); m_outputMutex.lock();
for (auto &entry : m_debugOutput) { for (auto &entry : m_debugOutput) {
std::vector<QString> &src = entry.second; auto it = entry.second.begin();
if (src.empty()) for (; it != entry.second.end(); ++it) {
continue; output[entry.first].push_back(*it);
QString dst; if (output.size() >= maxMessagesToSend)
size_t n = std::min(maxMessagesToSend, src.size()); break;
for (size_t i = 0; i < n; ++i) }
dst += src.at(i); if (it != entry.second.begin())
src.erase(src.begin(), std::next(src.begin(), n)); it = entry.second.erase(entry.second.begin(), it);
if (!src.empty()) if (it != entry.second.end()) {
hasMoreOutput = true; hasMoreOutput = true;
output.emplace_back(entry.first, std::move(dst)); break;
}
} }
if (!hasMoreOutput) if (!hasMoreOutput)
m_readySignalEmitted = false; m_readySignalEmitted = false;

View File

@@ -27,7 +27,7 @@ public:
static void startIfNeeded(); static void startIfNeeded();
signals: signals:
void debugOutput(qint64 pid, const QString &message); void debugOutput(qint64 pid, const QList<QString> &messages);
void cannotRetrieveDebugOutput(); void cannotRetrieveDebugOutput();
void _q_debugOutputReady(); void _q_debugOutputReady();