forked from qt-creator/qt-creator
Debugger: Simplify calls to parseChildrenData
Having access to the expanded inames doesn't make a difference. Change-Id: Ic833f647c2c135f213dd621e28a9be98809e0b04 Reviewed-by: Christian Stenger <christian.stenger@theqtcompany.com> Reviewed-by: David Schulz <david.schulz@theqtcompany.com>
This commit is contained in:
@@ -1933,7 +1933,7 @@ void CdbEngine::handleLocals(const CdbExtensionCommandPtr &reply)
|
||||
WatchData dummy;
|
||||
dummy.iname = child["iname"].data();
|
||||
dummy.name = QLatin1String(child["name"].data());
|
||||
parseWatchData(handler->expandedINames(), dummy, child, &watchData);
|
||||
parseWatchData(dummy, child, &watchData);
|
||||
}
|
||||
// Fix the names of watch data.
|
||||
for (int i =0; i < watchData.size(); ++i) {
|
||||
|
@@ -4968,7 +4968,7 @@ void GdbEngine::handleStackFramePython(const GdbResponse &response)
|
||||
name = _(child["name"].data());
|
||||
|
||||
WatchItem *item = new WatchItem(iname, name);
|
||||
item->parseWatchData(handler->expandedINames(), child);
|
||||
item->parseWatchData(child);
|
||||
|
||||
const TypeInfo ti = m_typeInfoCache.value(item->d.type);
|
||||
if (ti.size)
|
||||
|
@@ -1029,7 +1029,7 @@ void LldbEngine::refreshLocals(const GdbMi &vars)
|
||||
name = QString::fromLatin1(child["name"].data());
|
||||
|
||||
WatchItem *item = new WatchItem(iname, name);
|
||||
item->parseWatchData(handler->expandedINames(), child);
|
||||
item->parseWatchData(child);
|
||||
|
||||
if (wname.isValid())
|
||||
item->d.exp = name.toUtf8();
|
||||
|
@@ -808,7 +808,7 @@ void PdbEngine::handleListLocals(const PdbResponse &response)
|
||||
|
||||
foreach (const GdbMi &child, all.children()) {
|
||||
WatchItem *item = new WatchItem(child["iname"].data(), _(child["name"].data()));
|
||||
item->parseWatchData(handler->expandedINames(), child);
|
||||
item->parseWatchData(child);
|
||||
handler->insertItem(item);
|
||||
toDelete.remove(item->d.iname);
|
||||
}
|
||||
|
@@ -594,21 +594,16 @@ void decodeArrayData(std::function<void(const WatchData &)> itemHandler, const W
|
||||
}
|
||||
}
|
||||
|
||||
void parseChildrenData(const QSet<QByteArray> &expandedINames,
|
||||
const WatchData &data0, const GdbMi &item,
|
||||
void parseChildrenData(const WatchData &data0, const GdbMi &item,
|
||||
std::function<void(const WatchData &)> itemHandler,
|
||||
std::function<void(const QSet<QByteArray> &, const WatchData &, const GdbMi &)> childHandler,
|
||||
std::function<void(const WatchData &, const GdbMi &)> childHandler,
|
||||
std::function<void(const WatchData &childTemplate, const QByteArray &encodedData, int encoding)> arrayDecoder)
|
||||
{
|
||||
//qDebug() << "HANDLE CHILDREN: " << data0.toString() << item.toString();
|
||||
WatchData data = data0;
|
||||
bool isExpanded = expandedINames.contains(data.iname);
|
||||
if (!isExpanded)
|
||||
data.setChildrenUnneeded();
|
||||
|
||||
GdbMi children = item["children"];
|
||||
if (children.isValid() || !isExpanded)
|
||||
data.setChildrenUnneeded();
|
||||
|
||||
data.updateType(item["type"]);
|
||||
GdbMi mi = item["editvalue"];
|
||||
@@ -698,28 +693,26 @@ void parseChildrenData(const QSet<QByteArray> &expandedINames,
|
||||
int encoding = child["keyencoded"].toInt();
|
||||
data1.name = decodeData(key, encoding);
|
||||
}
|
||||
childHandler(expandedINames, data1, child);
|
||||
childHandler(data1, child);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void parseWatchData(const QSet<QByteArray> &expandedINames,
|
||||
const WatchData &data0, const GdbMi &input,
|
||||
void parseWatchData(const WatchData &data0, const GdbMi &input,
|
||||
QList<WatchData> *list)
|
||||
{
|
||||
auto itemHandler = [list](const WatchData &data) {
|
||||
list->append(data);
|
||||
};
|
||||
auto childHandler = [list](const QSet<QByteArray> &expandedINames,
|
||||
const WatchData &innerData, const GdbMi &innerInput) {
|
||||
parseWatchData(expandedINames, innerData, innerInput, list);
|
||||
auto childHandler = [list](const WatchData &innerData, const GdbMi &innerInput) {
|
||||
parseWatchData(innerData, innerInput, list);
|
||||
};
|
||||
auto arrayDecoder = [itemHandler](const WatchData &childTemplate,
|
||||
const QByteArray &encodedData, int encoding) {
|
||||
decodeArrayData(itemHandler, childTemplate, encodedData, encoding);
|
||||
};
|
||||
|
||||
parseChildrenData(expandedINames, data0, input, itemHandler, childHandler, arrayDecoder);
|
||||
parseChildrenData(data0, input, itemHandler, childHandler, arrayDecoder);
|
||||
}
|
||||
|
||||
} // namespace Internal
|
||||
|
@@ -159,18 +159,14 @@ void decodeArrayData(std::function<void(const WatchData &)> itemHandler,
|
||||
const QByteArray &rawData,
|
||||
int encoding);
|
||||
|
||||
void parseChildrenData(const QSet<QByteArray> &expandedINames,
|
||||
const WatchData &parent, const GdbMi &child,
|
||||
void parseChildrenData(const WatchData &parent, const GdbMi &child,
|
||||
std::function<void(const WatchData &)> itemHandler,
|
||||
std::function<void(const QSet<QByteArray> &,
|
||||
const WatchData &,
|
||||
const GdbMi &)> childHandler,
|
||||
std::function<void(const WatchData &, const GdbMi &)> childHandler,
|
||||
std::function<void(const WatchData &childTemplate,
|
||||
const QByteArray &encodedData,
|
||||
int encoding)> arrayDecoder);
|
||||
|
||||
void parseWatchData(const QSet<QByteArray> &expandedINames,
|
||||
const WatchData &parent, const GdbMi &child,
|
||||
void parseWatchData(const WatchData &parent, const GdbMi &child,
|
||||
QList<WatchData> *insertions);
|
||||
|
||||
} // namespace Internal
|
||||
|
@@ -1928,15 +1928,14 @@ WatchModel *WatchItem::watchModel()
|
||||
return static_cast<WatchModel *>(model());
|
||||
}
|
||||
|
||||
void WatchItem::parseWatchData(const QSet<QByteArray> &expandedINames, const GdbMi &input)
|
||||
void WatchItem::parseWatchData(const GdbMi &input)
|
||||
{
|
||||
auto itemHandler = [this](const WatchData &data) {
|
||||
d = data;
|
||||
};
|
||||
auto childHandler = [this](const QSet<QByteArray> &expandedINames,
|
||||
const WatchData &innerData, const GdbMi &innerInput) {
|
||||
auto childHandler = [this](const WatchData &innerData, const GdbMi &innerInput) {
|
||||
WatchItem *item = new WatchItem(innerData);
|
||||
item->parseWatchData(expandedINames, innerInput);
|
||||
item->parseWatchData(innerInput);
|
||||
appendChild(item);
|
||||
};
|
||||
|
||||
@@ -1949,7 +1948,7 @@ void WatchItem::parseWatchData(const QSet<QByteArray> &expandedINames, const Gdb
|
||||
decodeArrayData(itemAdder, childTemplate, encodedData, encoding);
|
||||
};
|
||||
|
||||
parseChildrenData(expandedINames, d, input, itemHandler, childHandler, arrayDecoder);
|
||||
parseChildrenData(d, input, itemHandler, childHandler, arrayDecoder);
|
||||
}
|
||||
|
||||
} // namespace Internal
|
||||
|
@@ -75,7 +75,7 @@ public:
|
||||
void formatRequests(QByteArray *out) const;
|
||||
void showInEditorHelper(QString *contents, int depth) const;
|
||||
WatchItem *findItem(const QByteArray &iname);
|
||||
void parseWatchData(const QSet<QByteArray> &expandedINames, const GdbMi &input);
|
||||
void parseWatchData(const GdbMi &input);
|
||||
|
||||
public:
|
||||
WatchData d;
|
||||
|
Reference in New Issue
Block a user