forked from qt-creator/qt-creator
debugger: second attempty to workaround the locals view issue
Adding items to an empty container did not result in a [+] in front of the container in the locals view.
This commit is contained in:
@@ -83,16 +83,15 @@ static int generationCounter = 0;
|
|||||||
class WatchItem : public WatchData
|
class WatchItem : public WatchData
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
WatchItem() { parent = 0; fetchTriggered = false; }
|
WatchItem() { parent = 0; }
|
||||||
|
|
||||||
WatchItem(const WatchData &data) : WatchData(data)
|
WatchItem(const WatchData &data) : WatchData(data)
|
||||||
{ parent = 0; fetchTriggered = false; }
|
{ parent = 0; }
|
||||||
|
|
||||||
void setData(const WatchData &data)
|
void setData(const WatchData &data)
|
||||||
{ static_cast<WatchData &>(*this) = data; }
|
{ static_cast<WatchData &>(*this) = data; }
|
||||||
|
|
||||||
WatchItem *parent;
|
WatchItem *parent;
|
||||||
bool fetchTriggered; // children fetch has been triggered
|
|
||||||
QList<WatchItem *> children; // fetched children
|
QList<WatchItem *> children; // fetched children
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -340,12 +339,12 @@ QString WatchData::shadowedName(const QString &name, int seen)
|
|||||||
WatchModel::WatchModel(WatchHandler *handler, WatchType type)
|
WatchModel::WatchModel(WatchHandler *handler, WatchType type)
|
||||||
: QAbstractItemModel(handler), m_handler(handler), m_type(type)
|
: QAbstractItemModel(handler), m_handler(handler), m_type(type)
|
||||||
{
|
{
|
||||||
|
m_inExtraLayoutChanged = false;
|
||||||
m_root = new WatchItem;
|
m_root = new WatchItem;
|
||||||
m_root->hasChildren = 1;
|
m_root->hasChildren = 1;
|
||||||
m_root->state = 0;
|
m_root->state = 0;
|
||||||
m_root->name = WatchHandler::tr("Root");
|
m_root->name = WatchHandler::tr("Root");
|
||||||
m_root->parent = 0;
|
m_root->parent = 0;
|
||||||
m_root->fetchTriggered = true;
|
|
||||||
|
|
||||||
switch (m_type) {
|
switch (m_type) {
|
||||||
case LocalsWatch:
|
case LocalsWatch:
|
||||||
@@ -393,6 +392,7 @@ void WatchModel::emitAllChanged()
|
|||||||
|
|
||||||
void WatchModel::beginCycle()
|
void WatchModel::beginCycle()
|
||||||
{
|
{
|
||||||
|
m_fetchTriggered.clear();
|
||||||
emit enableUpdates(false);
|
emit enableUpdates(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -400,6 +400,15 @@ void WatchModel::endCycle()
|
|||||||
{
|
{
|
||||||
removeOutdated();
|
removeOutdated();
|
||||||
emit enableUpdates(true);
|
emit enableUpdates(true);
|
||||||
|
// Prevent 'fetchMore()' from being triggered
|
||||||
|
m_inExtraLayoutChanged = true;
|
||||||
|
emit layoutChanged();
|
||||||
|
QTimer::singleShot(0, this, SLOT(resetExtraLayoutChanged()));
|
||||||
|
}
|
||||||
|
|
||||||
|
void WatchModel::resetExtraLayoutChanged()
|
||||||
|
{
|
||||||
|
m_inExtraLayoutChanged = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void WatchModel::dump()
|
void WatchModel::dump()
|
||||||
@@ -436,7 +445,6 @@ void WatchModel::removeOutdatedHelper(WatchItem *item)
|
|||||||
} else {
|
} else {
|
||||||
foreach (WatchItem *child, item->children)
|
foreach (WatchItem *child, item->children)
|
||||||
removeOutdatedHelper(child);
|
removeOutdatedHelper(child);
|
||||||
item->fetchTriggered = false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -624,23 +632,25 @@ static QString formattedValue(const WatchData &data,
|
|||||||
|
|
||||||
bool WatchModel::canFetchMore(const QModelIndex &index) const
|
bool WatchModel::canFetchMore(const QModelIndex &index) const
|
||||||
{
|
{
|
||||||
return index.isValid() && !watchItem(index)->fetchTriggered;
|
return !m_inExtraLayoutChanged && index.isValid() && !m_fetchTriggered.contains(watchItem(index)->iname);
|
||||||
}
|
}
|
||||||
|
|
||||||
void WatchModel::fetchMore(const QModelIndex &index)
|
void WatchModel::fetchMore(const QModelIndex &index)
|
||||||
{
|
{
|
||||||
|
if (m_inExtraLayoutChanged)
|
||||||
|
return;
|
||||||
QTC_ASSERT(index.isValid(), return);
|
QTC_ASSERT(index.isValid(), return);
|
||||||
QTC_ASSERT(!watchItem(index)->fetchTriggered, return);
|
WatchItem *item = watchItem(index);
|
||||||
if (WatchItem *item = watchItem(index)) {
|
QTC_ASSERT(item, return);
|
||||||
|
QTC_ASSERT(!m_fetchTriggered.contains(item->iname), return);
|
||||||
m_handler->m_expandedINames.insert(item->iname);
|
m_handler->m_expandedINames.insert(item->iname);
|
||||||
item->fetchTriggered = true;
|
m_fetchTriggered.insert(item->iname);
|
||||||
if (item->children.isEmpty()) {
|
if (item->children.isEmpty()) {
|
||||||
WatchData data = *item;
|
WatchData data = *item;
|
||||||
data.setChildrenNeeded();
|
data.setChildrenNeeded();
|
||||||
m_handler->m_manager->updateWatchData(data);
|
m_handler->m_manager->updateWatchData(data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
QModelIndex WatchModel::index(int row, int column, const QModelIndex &parent) const
|
QModelIndex WatchModel::index(int row, int column, const QModelIndex &parent) const
|
||||||
{
|
{
|
||||||
@@ -943,7 +953,6 @@ void WatchModel::insertData(const WatchData &data)
|
|||||||
oldItem->generation = generationCounter;
|
oldItem->generation = generationCounter;
|
||||||
QModelIndex idx = watchIndex(oldItem);
|
QModelIndex idx = watchIndex(oldItem);
|
||||||
emit dataChanged(idx, idx.sibling(idx.row(), 2));
|
emit dataChanged(idx, idx.sibling(idx.row(), 2));
|
||||||
emit layoutChanged();
|
|
||||||
} else {
|
} else {
|
||||||
// add new entry
|
// add new entry
|
||||||
//MODEL_DEBUG("ADD : " << data.iname << data.value);
|
//MODEL_DEBUG("ADD : " << data.iname << data.value);
|
||||||
|
|||||||
@@ -222,6 +222,7 @@ private:
|
|||||||
void dump();
|
void dump();
|
||||||
void dumpHelper(WatchItem *item);
|
void dumpHelper(WatchItem *item);
|
||||||
void emitAllChanged();
|
void emitAllChanged();
|
||||||
|
Q_SLOT void resetExtraLayoutChanged();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void enableUpdates(bool);
|
void enableUpdates(bool);
|
||||||
@@ -232,6 +233,10 @@ private:
|
|||||||
WatchHandler *m_handler;
|
WatchHandler *m_handler;
|
||||||
WatchType m_type;
|
WatchType m_type;
|
||||||
WatchItem *m_root;
|
WatchItem *m_root;
|
||||||
|
QSet<QString> m_fetchTriggered;
|
||||||
|
// Part of the workaround to update the [+] marker when items
|
||||||
|
// are added to a container.
|
||||||
|
bool m_inExtraLayoutChanged;
|
||||||
};
|
};
|
||||||
|
|
||||||
class WatchHandler : public QObject
|
class WatchHandler : public QObject
|
||||||
|
|||||||
Reference in New Issue
Block a user