diff options
author | Roland Knall <rknall@gmail.com> | 2019-07-04 12:43:11 +0200 |
---|---|---|
committer | Roland Knall <rknall@gmail.com> | 2019-07-04 11:12:54 +0000 |
commit | ca4b950bfa986b4f7b963a772be03ab2aff653e7 (patch) | |
tree | fa163a95caad606d71149d8e927b606728c38991 /ui/qt | |
parent | 66e92e7276e3d195917faa36fc9833d1fbe10693 (diff) |
Qt: Workaround for Qt model() bug
model() on the TreeView should return a value, but instead returns a null
pointer. Moving the methods to the model would be the next step, but until
then, this workaround regains functionality
Change-Id: Iaa0b6470af41b297a821c0dd6e3a238481752886
Reviewed-on: https://code.wireshark.org/review/33839
Petri-Dish: Roland Knall <rknall@gmail.com>
Tested-by: Petri Dish Buildbot
Reviewed-by: Roland Knall <rknall@gmail.com>
Diffstat (limited to 'ui/qt')
-rw-r--r-- | ui/qt/packet_list.cpp | 20 | ||||
-rw-r--r-- | ui/qt/packet_list.h | 2 |
2 files changed, 9 insertions, 13 deletions
diff --git a/ui/qt/packet_list.cpp b/ui/qt/packet_list.cpp index 6d3970bdb7..0d353187cb 100644 --- a/ui/qt/packet_list.cpp +++ b/ui/qt/packet_list.cpp @@ -96,16 +96,12 @@ packet_list_append(column_info *, frame_data *fdata) if (!gbl_cur_packet_list) return 0; - PacketListModel * model = qobject_cast<PacketListModel *>(gbl_cur_packet_list->model()); - if ( ! model ) - return 0; - /* fdata should be filled with the stuff we need * strings are built at display time. */ guint visible_pos; - visible_pos = model->appendPacket(fdata); + visible_pos = gbl_cur_packet_list->packetListModel()->appendPacket(fdata); return visible_pos; } @@ -135,14 +131,10 @@ packet_list_select_row_from_data(frame_data *fdata_needle) if ( !gbl_cur_packet_list ) return FALSE; - PacketListModel * model = qobject_cast<PacketListModel *>(gbl_cur_packet_list->model()); - if ( ! model ) - return FALSE; - - model->flushVisibleRows(); - int row = model->visibleIndexOf(fdata_needle); + gbl_cur_packet_list->packetListModel()->flushVisibleRows(); + int row = gbl_cur_packet_list->packetListModel()->visibleIndexOf(fdata_needle); if (row >= 0) { - gbl_cur_packet_list->setCurrentIndex(model->index(row, 0)); + gbl_cur_packet_list->setCurrentIndex(gbl_cur_packet_list->packetListModel()->index(row, 0)); return TRUE; } @@ -412,6 +404,10 @@ void PacketList::setProtoTree (ProtoTree *proto_tree) { &related_packet_delegate_, SLOT(addRelatedFrame(int,ft_framenum_type_t))); } +PacketListModel *PacketList::packetListModel() const { + return packet_list_model_; +} + void PacketList::selectionChanged (const QItemSelection & selected, const QItemSelection & deselected) { QTreeView::selectionChanged(selected, deselected); diff --git a/ui/qt/packet_list.h b/ui/qt/packet_list.h index 9adf27b69e..a29a3ccaeb 100644 --- a/ui/qt/packet_list.h +++ b/ui/qt/packet_list.h @@ -33,7 +33,7 @@ class PacketList : public QTreeView Q_OBJECT public: explicit PacketList(QWidget *parent = 0); - + PacketListModel *packetListModel() const; QMenu *conversationMenu() { return &conv_menu_; } QMenu *colorizeMenu() { return &colorize_menu_; } void setProtoTree(ProtoTree *proto_tree); |