Commit cc924c42 authored by hjk's avatar hjk Committed by hjk
Browse files

debugger: codadevice: merge multiple cleanup paths

Change-Id: Ia75a833652d32e2f02ea7ed448561f619d4945cc
Reviewed-on: http://codereview.qt.nokia.com/338

Reviewed-by: default avatarQt Sanity Bot <qt_sanity_bot@ovi.com>
Reviewed-by: default avatarhjk <qthjk@ovi.com>
parent 12d2a1e8
......@@ -1297,6 +1297,7 @@ void CodaGdbAdapter::reportRegisters()
void CodaGdbAdapter::handleRegisterChildren(const CodaCommandResult &result)
{
QTC_ASSERT(m_codaDevice, return);
const QByteArray contextId = result.cookie.toByteArray();
if (!result) {
logMessage("Error retrieving register children of " + contextId
......
......@@ -668,12 +668,15 @@ int CodaDevice::parseCodaCommandReply(char type, const QVector<QByteArray> &toke
token, qPrintable(joinByteArrays(tokens)));
return 236;
}
CodaSendQueueEntry entry = it.value(); // FIXME: const?
d->m_writtenMessages.erase(it);
// No callback: remove entry from map, happy
const unsigned specialHandling = it.value().specialHandling;
if (!it.value().callback && specialHandling == 0u) {
d->m_writtenMessages.erase(it);
const unsigned specialHandling = entry.specialHandling;
if (!entry.callback && specialHandling == 0u)
return 0;
}
// Parse values into JSON
QVector<JsonValue> values;
values.reserve(tokenCount);
......@@ -685,18 +688,15 @@ int CodaDevice::parseCodaCommandReply(char type, const QVector<QByteArray> &toke
} else {
qWarning("JSON parse error for reply to command token %d: #%d '%s'",
token, i, tokens.at(i).constData());
d->m_writtenMessages.erase(it);
return -1;
}
}
}
// Construct result and invoke callback, remove entry from map.
CodaCommandResult result(type, it.value().service, it.value().data,
values, it.value().cookie);
CodaCommandResult result(type, entry.service, entry.data, values, entry.cookie);
if (entry.callback)
entry.callback(result);
if (it.value().callback)
it.value().callback(result);
d->m_writtenMessages.erase(it);
return 0;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment