debugger: Prevent updateWatchData from being called multiple times.

Each calls to fetchMore() was triggering an updateWatchData, and that
can happen several times per user interaction.
This commit is contained in:
hjk
2009-06-18 12:37:04 +02:00
parent 69d04bc069
commit 725d8dbfc6

View File

@@ -81,16 +81,16 @@ static int generationCounter = 0;
class WatchItem : public WatchData class WatchItem : public WatchData
{ {
public: public:
WatchItem() { parent = 0; fetched = 0; } WatchItem() { parent = 0; fetchedTriggered = 0; }
WatchItem(const WatchData &data) : WatchData(data) WatchItem(const WatchData &data) : WatchData(data)
{ parent = 0; fetched = 0; } { parent = 0; fetchedTriggered = 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 fetched; // children fetch has been triggered bool fetchedTriggered; // children fetch has been triggered
QList<WatchItem *> children; // fetched children QList<WatchItem *> children; // fetched children
}; };
@@ -309,7 +309,7 @@ WatchModel::WatchModel(WatchHandler *handler, WatchType type)
item->childCount = 1; item->childCount = 1;
item->state = 0; item->state = 0;
item->parent = m_root; item->parent = m_root;
item->fetched = true; item->fetchedTriggered = true;
m_root->children.append(item); m_root->children.append(item);
} }
@@ -501,14 +501,15 @@ static QString niceType(QString type)
bool WatchModel::canFetchMore(const QModelIndex &index) const bool WatchModel::canFetchMore(const QModelIndex &index) const
{ {
return index.isValid() && !watchItem(index)->fetched; return index.isValid() && !watchItem(index)->fetchedTriggered;
} }
void WatchModel::fetchMore(const QModelIndex &index) void WatchModel::fetchMore(const QModelIndex &index)
{ {
QTC_ASSERT(index.isValid(), return); QTC_ASSERT(index.isValid(), return);
QTC_ASSERT(!watchItem(index)->fetched, return); QTC_ASSERT(!watchItem(index)->fetchedTriggered, return);
if (WatchItem *item = watchItem(index)) { if (WatchItem *item = watchItem(index)) {
item->fetchedTriggered = true;
WatchData data = *item; WatchData data = *item;
data.setChildrenNeeded(); data.setChildrenNeeded();
emit m_handler->watchDataUpdateNeeded(data); emit m_handler->watchDataUpdateNeeded(data);