Commit aa8602e1 authored by hjk's avatar hjk

debugger: fix color for changed items in locals and expressions view

Change-Id: I93905f8e97e2738590fecf41ac7294c2f6872335
Reviewed-by: default avatarhjk <qthjk@ovi.com>
parent e511107d
...@@ -232,7 +232,6 @@ QDataStream &operator<<(QDataStream &stream, const WatchData &wd) ...@@ -232,7 +232,6 @@ QDataStream &operator<<(QDataStream &stream, const WatchData &wd)
stream << wd.valueEditable; stream << wd.valueEditable;
stream << wd.error; stream << wd.error;
stream << wd.state; stream << wd.state;
stream << wd.changed;
return stream; return stream;
} }
...@@ -257,7 +256,6 @@ QDataStream &operator>>(QDataStream &stream, WatchData &wd) ...@@ -257,7 +256,6 @@ QDataStream &operator>>(QDataStream &stream, WatchData &wd)
stream >> wd.valueEditable; stream >> wd.valueEditable;
stream >> wd.error; stream >> wd.error;
stream >> wd.state; stream >> wd.state;
stream >> wd.changed;
return stream; return stream;
} }
......
...@@ -4112,6 +4112,7 @@ void GdbEngine::handleDebuggingHelperSetup(const GdbResponse &response) ...@@ -4112,6 +4112,7 @@ void GdbEngine::handleDebuggingHelperSetup(const GdbResponse &response)
void GdbEngine::updateLocals() void GdbEngine::updateLocals()
{ {
watchHandler()->resetValueCache();
if (hasPython()) if (hasPython())
updateLocalsPython(UpdateParameters()); updateLocalsPython(UpdateParameters());
else else
......
...@@ -128,7 +128,6 @@ WatchData::WatchData() : ...@@ -128,7 +128,6 @@ WatchData::WatchData() :
valueEnabled(true), valueEnabled(true),
valueEditable(true), valueEditable(true),
error(false), error(false),
changed(false),
sortId(0), sortId(0),
source(0) source(0)
{ {
...@@ -428,11 +427,6 @@ QByteArray WatchData::hexReferencingAddress() const ...@@ -428,11 +427,6 @@ QByteArray WatchData::hexReferencingAddress() const
return QByteArray(); return QByteArray();
} }
bool WatchData::hasChanged(const WatchData &old) const
{
return !value.isEmpty() && value != old.value && value != msgNotInScope();
}
} // namespace Internal } // namespace Internal
} // namespace Debugger } // namespace Debugger
...@@ -113,7 +113,6 @@ public: ...@@ -113,7 +113,6 @@ public:
quint64 coreAddress() const; quint64 coreAddress() const;
QByteArray hexAddress() const; QByteArray hexAddress() const;
QByteArray hexReferencingAddress() const; QByteArray hexReferencingAddress() const;
bool hasChanged(const WatchData &old) const;
public: public:
quint64 id; // Token for the engine for internal mapping quint64 id; // Token for the engine for internal mapping
...@@ -137,7 +136,6 @@ public: ...@@ -137,7 +136,6 @@ public:
bool valueEnabled; // Value will be enabled or not bool valueEnabled; // Value will be enabled or not
bool valueEditable; // Value will be editable bool valueEditable; // Value will be editable
bool error; bool error;
bool changed;
qint32 sortId; qint32 sortId;
QByteArray dumperFlags; QByteArray dumperFlags;
......
...@@ -177,7 +177,7 @@ private: ...@@ -177,7 +177,7 @@ private:
void fetchMore(const QModelIndex &parent); void fetchMore(const QModelIndex &parent);
void invalidateAll(const QModelIndex &parentIndex = QModelIndex()); void invalidateAll(const QModelIndex &parentIndex = QModelIndex());
void setUnchangedRecursively(WatchItem *item); void resetValueCacheRecursively(WatchItem *item);
WatchItem *createItem(const QByteArray &iname, const QString &name, WatchItem *parent); WatchItem *createItem(const QByteArray &iname, const QString &name, WatchItem *parent);
...@@ -188,7 +188,7 @@ private: ...@@ -188,7 +188,7 @@ private:
QModelIndex watchIndexHelper(const WatchItem *needle, QModelIndex watchIndexHelper(const WatchItem *needle,
const WatchItem *parentItem, const QModelIndex &parentIndex) const; const WatchItem *parentItem, const QModelIndex &parentIndex) const;
void insertDataItem(const WatchData &data, bool destructive = true); void insertDataItem(const WatchData &data, bool destructive);
Q_SLOT void reinsertAllData(); Q_SLOT void reinsertAllData();
void reinsertAllDataHelper(WatchItem *item, QList<WatchData> *data); void reinsertAllDataHelper(WatchItem *item, QList<WatchData> *data);
bool ancestorChanged(const QSet<QByteArray> &parentINames, WatchItem *item) const; bool ancestorChanged(const QSet<QByteArray> &parentINames, WatchItem *item) const;
...@@ -246,6 +246,8 @@ private: ...@@ -246,6 +246,8 @@ private:
friend class WatchItem; friend class WatchItem;
typedef QHash<QByteArray, WatchItem *> Cache; typedef QHash<QByteArray, WatchItem *> Cache;
Cache m_cache; Cache m_cache;
typedef QHash<QByteArray, QString> ValueCache;
ValueCache m_valueCache;
#if USE_EXPENSIVE_CHECKS #if USE_EXPENSIVE_CHECKS
QHash<const WatchItem *, QByteArray> m_cache2; QHash<const WatchItem *, QByteArray> m_cache2;
...@@ -859,12 +861,12 @@ void WatchModel::invalidateAll(const QModelIndex &parentIndex) ...@@ -859,12 +861,12 @@ void WatchModel::invalidateAll(const QModelIndex &parentIndex)
emit dataChanged(idx1, idx2); emit dataChanged(idx1, idx2);
} }
void WatchModel::setUnchangedRecursively(WatchItem *item) void WatchModel::resetValueCacheRecursively(WatchItem *item)
{ {
item->changed = false; m_valueCache[item->iname] = item->value;
const WatchItems &items = item->children; const WatchItems &items = item->children;
for (int i = items.size(); --i >= 0; ) for (int i = items.size(); --i >= 0; )
setUnchangedRecursively(items.at(i)); resetValueCacheRecursively(items.at(i));
} }
// Truncate value for item view, maintaining quotes. // Truncate value for item view, maintaining quotes.
...@@ -1028,9 +1030,11 @@ QVariant WatchModel::data(const QModelIndex &idx, int role) const ...@@ -1028,9 +1030,11 @@ QVariant WatchModel::data(const QModelIndex &idx, int role) const
case Qt::ForegroundRole: { case Qt::ForegroundRole: {
static const QVariant red(QColor(200, 0, 0)); static const QVariant red(QColor(200, 0, 0));
static const QVariant gray(QColor(140, 140, 140)); static const QVariant gray(QColor(140, 140, 140));
switch (idx.column()) { if (idx.column() == 1) {
case 1: return (!data.valueEnabled || !contentIsValid()) ? gray if (!data.valueEnabled || !contentIsValid())
: data.changed ? red : QVariant(); return gray;
if (data.value != m_valueCache.value(data.iname))
return red;
} }
break; break;
} }
...@@ -1314,9 +1318,7 @@ void WatchModel::insertDataItem(const WatchData &data, bool destructive) ...@@ -1314,9 +1318,7 @@ void WatchModel::insertDataItem(const WatchData &data, bool destructive)
destroyChildren(item); destroyChildren(item);
// Overwrite old entry. // Overwrite old entry.
bool hasChanged = item->hasChanged(data);
assignData(item, data); assignData(item, data);
item->changed = hasChanged;
QModelIndex idx = watchIndex(item); QModelIndex idx = watchIndex(item);
emit dataChanged(idx, idx.sibling(idx.row(), 2)); emit dataChanged(idx, idx.sibling(idx.row(), 2));
} else { } else {
...@@ -1325,7 +1327,6 @@ void WatchModel::insertDataItem(const WatchData &data, bool destructive) ...@@ -1325,7 +1327,6 @@ void WatchModel::insertDataItem(const WatchData &data, bool destructive)
QTC_ASSERT(parent, return); QTC_ASSERT(parent, return);
WatchItem *newItem = createItem(data); WatchItem *newItem = createItem(data);
newItem->parent = parent; newItem->parent = parent;
newItem->changed = true;
const int row = findInsertPosition(parent->children, newItem); const int row = findInsertPosition(parent->children, newItem);
QModelIndex idx = watchIndex(parent); QModelIndex idx = watchIndex(parent);
beginInsertRows(idx, row, row); beginInsertRows(idx, row, row);
...@@ -1353,7 +1354,7 @@ void WatchModel::insertBulkData(const QList<WatchData> &list) ...@@ -1353,7 +1354,7 @@ void WatchModel::insertBulkData(const QList<WatchData> &list)
#if 1 #if 1
for (int i = 0, n = list.size(); i != n; ++i) { for (int i = 0, n = list.size(); i != n; ++i) {
const WatchData &data = list.at(i); const WatchData &data = list.at(i);
insertDataItem(data); insertDataItem(data, true);
m_handler->showEditValue(data); m_handler->showEditValue(data);
} }
#else #else
...@@ -1483,7 +1484,7 @@ void WatchHandler::insertIncompleteData(const WatchData &data) ...@@ -1483,7 +1484,7 @@ void WatchHandler::insertIncompleteData(const WatchData &data)
if (data.isSomethingNeeded() && data.iname.contains('.')) { if (data.isSomethingNeeded() && data.iname.contains('.')) {
MODEL_DEBUG("SOMETHING NEEDED: " << data.toString()); MODEL_DEBUG("SOMETHING NEEDED: " << data.toString());
if (!m_engine->isSynchronous() || data.isInspect()) { if (!m_engine->isSynchronous() || data.isInspect()) {
m_model->insertDataItem(data); m_model->insertDataItem(data, true);
m_engine->updateWatchData(data); m_engine->updateWatchData(data);
} else { } else {
m_engine->showMessage(QLatin1String("ENDLESS LOOP: SOMETHING NEEDED: ") m_engine->showMessage(QLatin1String("ENDLESS LOOP: SOMETHING NEEDED: ")
...@@ -1492,11 +1493,11 @@ void WatchHandler::insertIncompleteData(const WatchData &data) ...@@ -1492,11 +1493,11 @@ void WatchHandler::insertIncompleteData(const WatchData &data)
data1.setAllUnneeded(); data1.setAllUnneeded();
data1.setValue(QLatin1String("<unavailable synchronous data>")); data1.setValue(QLatin1String("<unavailable synchronous data>"));
data1.setHasChildren(false); data1.setHasChildren(false);
m_model->insertDataItem(data1); m_model->insertDataItem(data1, true);
} }
} else { } else {
MODEL_DEBUG("NOTHING NEEDED: " << data.toString()); MODEL_DEBUG("NOTHING NEEDED: " << data.toString());
m_model->insertDataItem(data); m_model->insertDataItem(data, true);
showEditValue(data); showEditValue(data);
} }
} }
...@@ -1522,9 +1523,10 @@ void WatchHandler::removeAllData() ...@@ -1522,9 +1523,10 @@ void WatchHandler::removeAllData()
updateWatchersWindow(); updateWatchersWindow();
} }
void WatchHandler::markAllUnchanged() void WatchHandler::resetValueCache()
{ {
m_model->setUnchangedRecursively(m_model->m_root); m_model->m_valueCache.clear();
m_model->resetValueCacheRecursively(m_model->m_root);
} }
void WatchHandler::removeData(const QByteArray &iname) void WatchHandler::removeData(const QByteArray &iname)
......
...@@ -132,7 +132,7 @@ public: ...@@ -132,7 +132,7 @@ public:
void removeData(const QByteArray &iname); void removeData(const QByteArray &iname);
void removeChildren(const QByteArray &iname); void removeChildren(const QByteArray &iname);
void removeAllData(); void removeAllData();
void markAllUnchanged(); void resetValueCache();
private: private:
friend class WatchModel; friend class WatchModel;
......
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