diff --git a/bin/gdbmacros/gdbmacros.cpp b/bin/gdbmacros/gdbmacros.cpp index 05488a85125da53628143b5fe3e23c7a7bd7d86f..199b783f45d137abf09d79d56ddcb25e43cf6bc0 100644 --- a/bin/gdbmacros/gdbmacros.cpp +++ b/bin/gdbmacros/gdbmacros.cpp @@ -1864,7 +1864,7 @@ static void qDumpQSet(QDumper &d) n = 100; d << ",children=["; int i = 0; - for (int bucket = 0; bucket != hd->numBuckets; ++bucket) { + for (int bucket = 0; bucket != hd->numBuckets && i <= 10000; ++bucket) { for (node = hd->buckets[bucket]; node->next; node = node->next) { d.beginHash(); P(d, "name", "[" << i << "]"); @@ -1875,6 +1875,14 @@ static void qDumpQSet(QDumper &d) ); d.endHash(); ++i; + if (i > 10000) { + d.beginHash(); + P(d, "name", "Warning:"); + P(d, "value", "<incomplete>"); + P(d, "type", ""); + d.endHash(); + break; + } } } d << "]"; diff --git a/src/plugins/debugger/watchhandler.cpp b/src/plugins/debugger/watchhandler.cpp index 3d99a84ad34edf93ba96a3a4a1f7f0d489d8f8d8..1792e4705d62cbad99c769d999ca01daab5498f9 100644 --- a/src/plugins/debugger/watchhandler.cpp +++ b/src/plugins/debugger/watchhandler.cpp @@ -320,6 +320,51 @@ static WatchData take(const QString &iname, QList<WatchData> *list) } +static QList<WatchData> initialSet() +{ + QList<WatchData> result; + + WatchData root; + root.state = 0; + root.level = 0; + root.row = 0; + root.name = "Root"; + root.parentIndex = -1; + root.childIndex.append(1); + root.childIndex.append(2); + root.childIndex.append(3); + result.append(root); + + WatchData local; + local.iname = "local"; + local.name = "Locals"; + local.state = 0; + local.level = 1; + local.row = 0; + local.parentIndex = 0; + result.append(local); + + WatchData tooltip; + tooltip.iname = "tooltip"; + tooltip.name = "Tooltip"; + tooltip.state = 0; + tooltip.level = 1; + tooltip.row = 1; + tooltip.parentIndex = 0; + result.append(tooltip); + + WatchData watch; + watch.iname = "watch"; + watch.name = "Watchers"; + watch.state = 0; + watch.level = 1; + watch.row = 2; + watch.parentIndex = 0; + result.append(watch); + + return result; +} + /////////////////////////////////////////////////////////////////////// // // WatchHandler @@ -332,7 +377,8 @@ WatchHandler::WatchHandler() m_inFetchMore = false; m_inChange = false; - cleanModel(); + m_completeSet = initialSet(); + m_incompleteSet.clear(); m_displaySet = m_completeSet; } @@ -380,6 +426,7 @@ QVariant WatchHandler::data(const QModelIndex &idx, int role) const int node = idx.internalId(); if (node < 0) return QVariant(); + QWB_ASSERT(node < m_displaySet.size(), return QVariant()); const WatchData &data = m_displaySet.at(node); @@ -558,10 +605,13 @@ void WatchHandler::rebuildModel() MODEL_DEBUG("RECREATE MODEL, CURRENT SET:\n" << toString()); #endif + QHash<QString, int> oldTopINames; QHash<QString, QString> oldValues; for (int i = 0, n = m_oldSet.size(); i != n; ++i) { WatchData &data = m_oldSet[i]; oldValues[data.iname] = data.value; + if (data.level == 2) + ++oldTopINames[data.iname]; } #ifdef DEBUG_PENDING MODEL_DEBUG("OLD VALUES: " << oldValues); @@ -575,6 +625,9 @@ void WatchHandler::rebuildModel() qSort(m_completeSet.begin(), m_completeSet.end(), &iNameSorter); + // This helps to decide whether the view has completely changed or not. + QHash<QString, int> topINames; + QHash<QString, int> iname2idx; for (int i = m_completeSet.size(); --i > 0; ) { @@ -582,7 +635,10 @@ void WatchHandler::rebuildModel() data.parentIndex = 0; data.childIndex.clear(); iname2idx[data.iname] = i; + if (data.level == 2) + ++topINames[data.iname]; } + //qDebug() << "TOPINAMES: " << topINames << "\nOLD: " << oldTopINames; for (int i = 1; i < m_completeSet.size(); ++i) { WatchData &data = m_completeSet[i]; @@ -603,7 +659,13 @@ void WatchHandler::rebuildModel() && data.value != strNotInScope; } - //emit layoutAboutToBeChanged(); + emit layoutAboutToBeChanged(); + + if (oldTopINames != topINames) { + m_displaySet = initialSet(); + m_expandedINames.clear(); + emit reset(); + } m_displaySet = m_completeSet; @@ -668,11 +730,6 @@ void WatchHandler::rebuildModel() emit reset(); //qDebug() << "WATCHHANDLER: RESET EMITTED"; m_inChange = false; - //emit layoutChanged(); - //QSet<QString> einames = m_expandedINames; - //einames.insert("local"); - //einames.insert("watch"); - //emit expandedItems(einames); #if DEBUG_MODEL #if USE_MODEL_TEST @@ -691,8 +748,11 @@ void WatchHandler::cleanup() m_oldSet.clear(); m_expandedINames.clear(); m_displayedINames.clear(); - cleanModel(); + + m_incompleteSet.clear(); + m_completeSet = initialSet(); m_displaySet = m_completeSet; + #if 0 for (EditWindows::ConstIterator it = m_editWindows.begin(); it != m_editWindows.end(); ++it) { @@ -707,7 +767,7 @@ void WatchHandler::cleanup() void WatchHandler::collapseChildren(const QModelIndex &idx) { if (m_inChange || m_completeSet.isEmpty()) { - //qDebug() << "WATCHHANDLER: COLLAPSE IGNORED" << idx; + qDebug() << "WATCHHANDLER: COLLAPSE IGNORED" << idx; return; } QWB_ASSERT(checkIndex(idx.internalId()), return); @@ -879,56 +939,10 @@ void WatchHandler::removeWatchExpression(const QString &iname) emit watchModelUpdateRequested(); } -void WatchHandler::cleanModel() -{ - // This uses data stored in m_oldSet to re-create a new set - // one-by-one - m_completeSet.clear(); - m_incompleteSet.clear(); - - WatchData root; - root.state = 0; - root.level = 0; - root.row = 0; - root.name = "Root"; - root.parentIndex = -1; - root.childIndex.append(1); - root.childIndex.append(2); - root.childIndex.append(3); - m_completeSet.append(root); - - WatchData local; - local.iname = "local"; - local.name = "Locals"; - local.state = 0; - local.level = 1; - local.row = 0; - local.parentIndex = 0; - m_completeSet.append(local); - - WatchData tooltip; - tooltip.iname = "tooltip"; - tooltip.name = "Tooltip"; - tooltip.state = 0; - tooltip.level = 1; - tooltip.row = 1; - tooltip.parentIndex = 0; - m_completeSet.append(tooltip); - - WatchData watch; - watch.iname = "watch"; - watch.name = "Watchers"; - watch.state = 0; - watch.level = 1; - watch.row = 2; - watch.parentIndex = 0; - m_completeSet.append(watch); -} - - void WatchHandler::reinitializeWatchers() { - cleanModel(); + m_completeSet = initialSet(); + m_incompleteSet.clear(); // copy over all watchers and mark all watchers as incomplete for (int i = 0, n = m_oldSet.size(); i < n; ++i) { diff --git a/src/plugins/debugger/watchhandler.h b/src/plugins/debugger/watchhandler.h index 3841d55d30019ce1ab7cc5a75e7b3ca9d492b10b..989b99b3d225685aba343f291ef21fca09c4cad9 100644 --- a/src/plugins/debugger/watchhandler.h +++ b/src/plugins/debugger/watchhandler.h @@ -192,7 +192,6 @@ signals: private: WatchData takeData(const QString &iname); QString toString() const; - void cleanModel(); bool m_expandPointers; bool m_inChange; diff --git a/src/plugins/debugger/watchwindow.cpp b/src/plugins/debugger/watchwindow.cpp index 78366198955d6379c7e7130b1501d9aef0122488..d528bf09242af9ca1c40557f191790efb319673d 100644 --- a/src/plugins/debugger/watchwindow.cpp +++ b/src/plugins/debugger/watchwindow.cpp @@ -57,7 +57,6 @@ enum { INameRole = Qt::UserRole, VisualRole }; WatchWindow::WatchWindow(Type type, QWidget *parent) : QTreeView(parent), m_type(type) { - m_blocked = false; setWindowTitle(tr("Locals and Watchers")); setAlternatingRowColors(true); setIndentation(indentation() * 9/10); @@ -76,12 +75,8 @@ void WatchWindow::expandNode(const QModelIndex &idx) //QModelIndex mi0 = idx.sibling(idx.row(), 0); //QString iname = model()->data(mi0, INameRole).toString(); //QString name = model()->data(mi0, Qt::DisplayRole).toString(); - //qDebug() << "\n\nEXPAND NODE " // << iname << name - // << idx << (m_blocked ? "blocked" : "passed"); //if (isExpanded(idx)) // return; - //if (m_blocked) - // return; emit requestExpandChildren(idx); } @@ -91,8 +86,6 @@ void WatchWindow::collapseNode(const QModelIndex &idx) //QString iname = model()->data(mi0, INameRole).toString(); //QString name = model()->data(mi0, Qt::DisplayRole).toString(); //qDebug() << "COLLAPSE NODE " << idx; - if (m_blocked) - return; emit requestCollapseChildren(idx); } @@ -201,7 +194,6 @@ void WatchWindow::setModel(QAbstractItemModel *model) void WatchWindow::modelAboutToBeReset() { - m_blocked = true; //qDebug() << "Model about to be reset"; m_expandedItems.clear(); m_expandedItems.insert("local"); @@ -225,10 +217,9 @@ void WatchWindow::modelAboutToBeResetHelper(const QModelIndex &idx) void WatchWindow::modelReset() { - //qDebug() << "Model reset"; + collapseAll(); expand(model()->index(0, 0)); modelResetHelper(model()->index(0, 0)); - m_blocked = false; } void WatchWindow::modelResetHelper(const QModelIndex &idx) @@ -242,6 +233,9 @@ void WatchWindow::modelResetHelper(const QModelIndex &idx) QModelIndex idx1 = model()->index(i, 0, idx); modelResetHelper(idx1); } + } else { + // if (!iname.isEmpty()) + // collapse(idx); } } diff --git a/src/plugins/debugger/watchwindow.h b/src/plugins/debugger/watchwindow.h index 9781f79fdb7b7099a36c36bf75daf675bf3ef073..8b9b5d13ae4c64efb3ab8fc3d5e24b7af17dd8e3 100644 --- a/src/plugins/debugger/watchwindow.h +++ b/src/plugins/debugger/watchwindow.h @@ -85,7 +85,6 @@ private: bool m_alwaysResizeColumnsToContents; Type m_type; - bool m_blocked; QSet<QString> m_expandedItems; };