Skip to content

Commit ca4b950

Browse files
committed
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 <[email protected]> Tested-by: Petri Dish Buildbot Reviewed-by: Roland Knall <[email protected]>
1 parent 66e92e7 commit ca4b950

File tree

2 files changed

+9
-13
lines changed

2 files changed

+9
-13
lines changed

ui/qt/packet_list.cpp

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -96,16 +96,12 @@ packet_list_append(column_info *, frame_data *fdata)
9696
if (!gbl_cur_packet_list)
9797
return 0;
9898

99-
PacketListModel * model = qobject_cast<PacketListModel *>(gbl_cur_packet_list->model());
100-
if ( ! model )
101-
return 0;
102-
10399
/* fdata should be filled with the stuff we need
104100
* strings are built at display time.
105101
*/
106102
guint visible_pos;
107103

108-
visible_pos = model->appendPacket(fdata);
104+
visible_pos = gbl_cur_packet_list->packetListModel()->appendPacket(fdata);
109105
return visible_pos;
110106
}
111107

@@ -135,14 +131,10 @@ packet_list_select_row_from_data(frame_data *fdata_needle)
135131
if ( !gbl_cur_packet_list )
136132
return FALSE;
137133

138-
PacketListModel * model = qobject_cast<PacketListModel *>(gbl_cur_packet_list->model());
139-
if ( ! model )
140-
return FALSE;
141-
142-
model->flushVisibleRows();
143-
int row = model->visibleIndexOf(fdata_needle);
134+
gbl_cur_packet_list->packetListModel()->flushVisibleRows();
135+
int row = gbl_cur_packet_list->packetListModel()->visibleIndexOf(fdata_needle);
144136
if (row >= 0) {
145-
gbl_cur_packet_list->setCurrentIndex(model->index(row, 0));
137+
gbl_cur_packet_list->setCurrentIndex(gbl_cur_packet_list->packetListModel()->index(row, 0));
146138
return TRUE;
147139
}
148140

@@ -412,6 +404,10 @@ void PacketList::setProtoTree (ProtoTree *proto_tree) {
412404
&related_packet_delegate_, SLOT(addRelatedFrame(int,ft_framenum_type_t)));
413405
}
414406

407+
PacketListModel *PacketList::packetListModel() const {
408+
return packet_list_model_;
409+
}
410+
415411
void PacketList::selectionChanged (const QItemSelection & selected, const QItemSelection & deselected)
416412
{
417413
QTreeView::selectionChanged(selected, deselected);

ui/qt/packet_list.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ class PacketList : public QTreeView
3333
Q_OBJECT
3434
public:
3535
explicit PacketList(QWidget *parent = 0);
36-
36+
PacketListModel *packetListModel() const;
3737
QMenu *conversationMenu() { return &conv_menu_; }
3838
QMenu *colorizeMenu() { return &colorize_menu_; }
3939
void setProtoTree(ProtoTree *proto_tree);

0 commit comments

Comments
 (0)