diff options
author | Peter Wu <peter@lekensteyn.nl> | 2017-03-13 13:47:34 +0100 |
---|---|---|
committer | Anders Broman <a.broman58@gmail.com> | 2017-03-28 05:09:39 +0000 |
commit | 721182b09ba7212e6c4c2c182d67fb8762a5919d (patch) | |
tree | 1987ddcce03c6b3f1e7d123778b80cb5d1a04e90 /ui/qt/capture_interfaces_dialog.cpp | |
parent | e1b14fbcfe9252922b73f5c3087a9ae7a61e6ad3 (diff) | |
download | wireshark-721182b09ba7212e6c4c2c182d67fb8762a5919d.tar.gz |
Qt: fix closing editor in capture interfaces dialog
Whenever (every second) the points list is updated, a dataChanged signal
is emitted and Qt decides to close all editors. Workaround this issue by
disabling the dataChanged signal. (Alternatively, we could change the
list into a pointer-to-list again.)
Change-Id: Ie06d118d011a72f5be5608c2324ca2715a3f97c7
Fixes: v2.3.0rc0-2014-gf8dc2346df ("Qt: fix memleak of PointList in interface statistics")
Reviewed-on: https://code.wireshark.org/review/20530
Petri-Dish: Peter Wu <peter@lekensteyn.nl>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Stig Bjørlykke <stig@bjorlykke.org>
Reviewed-by: Anders Broman <a.broman58@gmail.com>
Diffstat (limited to 'ui/qt/capture_interfaces_dialog.cpp')
-rw-r--r-- | ui/qt/capture_interfaces_dialog.cpp | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/ui/qt/capture_interfaces_dialog.cpp b/ui/qt/capture_interfaces_dialog.cpp index cb1253868e..771dd40498 100644 --- a/ui/qt/capture_interfaces_dialog.cpp +++ b/ui/qt/capture_interfaces_dialog.cpp @@ -111,6 +111,8 @@ class InterfaceTreeWidgetItem : public QTreeWidgetItem public: InterfaceTreeWidgetItem(QTreeWidget *tree) : QTreeWidgetItem(tree) {} bool operator< (const QTreeWidgetItem &other) const; + QVariant data(int column, int role) const; + void setData(int column, int role, const QVariant &value); QList<int> points; void updateInterfaceColumns(interface_t *device) @@ -1116,6 +1118,29 @@ bool InterfaceTreeWidgetItem::operator< (const QTreeWidgetItem &other) const { return QTreeWidgetItem::operator<(other); } +QVariant InterfaceTreeWidgetItem::data(int column, int role) const +{ + // See setData for the special col_traffic_ treatment. + if (column == col_traffic_ && role == Qt::UserRole) { + return qVariantFromValue(points); + } + + return QTreeWidgetItem::data(column, role); +} + +void InterfaceTreeWidgetItem::setData(int column, int role, const QVariant &value) +{ + // Workaround for closing editors on updates to the points list: normally + // QTreeWidgetItem::setData emits dataChanged when the value (list) changes. + // We could store a pointer to the list, or just have this hack that does + // not emit dataChanged. + if (column == col_traffic_ && role == Qt::UserRole) { + points = value.value<QList<int> >(); + return; + } + + QTreeWidgetItem::setData(column, role, value); +} // // InterfaceTreeDelegate |