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