Commit d80d68b7 authored by hjk's avatar hjk

debugger: base individual formats on object addresses, not on inames

parent 7b49fdea
......@@ -1054,7 +1054,7 @@ class Dumper:
self.safePutItemHelper(item)
def itemFormat(self, item):
format = self.formats.get(item.iname)
format = self.formats.get(str(cleanAddress(item.value.address)))
if format is None:
format = self.typeformats.get(stripClassTag(str(item.value.type)))
return format
......
......@@ -230,9 +230,9 @@ void WatchData::setType(const QString &str, bool guessChildrenFromType)
}
}
void WatchData::setAddress(const QString &str)
void WatchData::setAddress(const QByteArray &a)
{
addr = str.toLatin1();
addr = a;
}
QString WatchData::toString() const
......@@ -783,7 +783,7 @@ QVariant WatchModel::data(const QModelIndex &idx, int role) const
return QVariant(QLatin1Char('*') + item->parent->name);
return data.name;
case 1: {
int format = m_handler->m_individualFormats.value(data.iname, -1);
int format = m_handler->m_individualFormats.value(data.addr, -1);
if (format == -1)
format = m_handler->m_typeFormats.value(data.type, -1);
return truncateValue(formattedValue(data, format));
......@@ -839,7 +839,7 @@ QVariant WatchModel::data(const QModelIndex &idx, int role) const
return m_handler->m_typeFormats.value(data.type, -1);
case IndividualFormatRole:
return m_handler->m_individualFormats.value(data.iname, -1);
return m_handler->m_individualFormats.value(data.addr, -1);
case AddressRole: {
if (!data.addr.isEmpty())
......@@ -874,9 +874,9 @@ bool WatchModel::setData(const QModelIndex &index, const QVariant &value, int ro
} else if (role == IndividualFormatRole) {
const int format = value.toInt();
if (format == -1) {
m_handler->m_individualFormats.remove(data.iname);
m_handler->m_individualFormats.remove(data.addr);
} else {
m_handler->m_individualFormats[data.iname] = format;
m_handler->m_individualFormats[data.addr] = format;
}
m_handler->m_manager->updateWatchData(data);
}
......@@ -1620,10 +1620,10 @@ QByteArray WatchHandler::formatRequests() const
ba.append("formats:");
if (!m_individualFormats.isEmpty()) {
QHashIterator<QString, int> it(m_individualFormats);
QHashIterator<QByteArray, int> it(m_individualFormats);
while (it.hasNext()) {
it.next();
ba.append(it.key().toLatin1());
ba.append(it.key());
ba.append('=');
ba.append(QByteArray::number(it.value()));
ba.append(',');
......
......@@ -79,7 +79,7 @@ public:
void setType(const QString &, bool guessChildrenFromType = true);
void setValueToolTip(const QString &);
void setError(const QString &);
void setAddress(const QString &address);
void setAddress(const QByteArray &);
bool isSomethingNeeded() const { return state & NeededMask; }
void setAllNeeded() { state = NeededMask; }
......@@ -289,7 +289,7 @@ private:
QHash<QByteArray, int> m_watcherNames;
QByteArray watcherName(const QByteArray &exp);
QHash<QString, int> m_typeFormats;
QHash<QString, int> m_individualFormats;
QHash<QByteArray, int> m_individualFormats;
// Items expanded in the Locals & Watchers view.
QSet<QByteArray> m_expandedINames;
......
......@@ -202,14 +202,15 @@ void WatchWindow::dropEvent(QDropEvent *ev)
void WatchWindow::contextMenuEvent(QContextMenuEvent *ev)
{
QModelIndex idx = indexAt(ev->pos());
QModelIndex mi0 = idx.sibling(idx.row(), 0);
QModelIndex mi1 = idx.sibling(idx.row(), 1);
QModelIndex mi2 = idx.sibling(idx.row(), 2);
QString exp = model()->data(mi0, ExpressionRole).toString();
QString type = model()->data(mi2).toString();
QStringList alternativeFormats =
const QModelIndex idx = indexAt(ev->pos());
const QModelIndex mi0 = idx.sibling(idx.row(), 0);
const QModelIndex mi1 = idx.sibling(idx.row(), 1);
const QModelIndex mi2 = idx.sibling(idx.row(), 2);
const QString addr = model()->data(mi0, AddressRole).toString();
const QString exp = model()->data(mi0, ExpressionRole).toString();
const QString type = model()->data(mi2).toString();
const QStringList alternativeFormats =
model()->data(mi0, TypeFormatListRole).toStringList();
const int typeFormat =
qMax(int(DecimalFormat), model()->data(mi0, TypeFormatRole).toInt());
......@@ -224,8 +225,10 @@ void WatchWindow::contextMenuEvent(QContextMenuEvent *ev)
QList<QAction *> individualFormatActions;
QAction *clearIndividualFormatAction = 0;
if (idx.isValid()) {
typeFormatMenu.setTitle(tr("Change Format for Type '%1'").arg(type));
individualFormatMenu.setTitle(tr("Change Format for Expression '%1'").arg(exp));
typeFormatMenu.setTitle(
tr("Change Format for Type '%1'").arg(type));
individualFormatMenu.setTitle(
tr("Change Format for Object at %1").arg(addr));
if (alternativeFormats.isEmpty()) {
typeFormatMenu.setEnabled(false);
individualFormatMenu.setEnabled(false);
......@@ -250,9 +253,9 @@ void WatchWindow::contextMenuEvent(QContextMenuEvent *ev)
}
}
} else {
typeFormatMenu.setTitle(tr("Change format for type"));
typeFormatMenu.setTitle(tr("Change Format for Type"));
typeFormatMenu.setEnabled(false);
individualFormatMenu.setTitle(tr("Change format for expression"));
individualFormatMenu.setTitle(tr("Change Format for Object"));
individualFormatMenu.setEnabled(false);
}
......
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