diff --git a/ui/qt/main_window_slots.cpp b/ui/qt/main_window_slots.cpp index dfdc8ac433..79e8a25433 100644 --- a/ui/qt/main_window_slots.cpp +++ b/ui/qt/main_window_slots.cpp @@ -320,7 +320,6 @@ void MainWindow::layoutPanes() if (cur_layout_ == new_layout) return; QSplitter *parents[3]; - int current_row = capture_file_.currentRow(); // Reparent all widgets and add them back in the proper order below. // This hides each widget as well. @@ -397,8 +396,7 @@ void MainWindow::layoutPanes() proto_tree_->setVisible(ms_children.contains(proto_tree_) && recent.tree_view_show); byte_view_tab_->setVisible(ms_children.contains(byte_view_tab_) && recent.byte_view_show); - packet_list_->thaw(); - cf_select_packet(capture_file_.capFile(), current_row); // XXX Doesn't work for row 0? + packet_list_->thaw(true); cur_layout_ = new_layout; } diff --git a/ui/qt/packet_list.cpp b/ui/qt/packet_list.cpp index b5f5493a77..74049d084f 100644 --- a/ui/qt/packet_list.cpp +++ b/ui/qt/packet_list.cpp @@ -246,7 +246,8 @@ PacketList::PacketList(QWidget *parent) : tail_timer_id_(0), rows_inserted_(false), columns_changed_(false), - set_column_visibility_(false) + set_column_visibility_(false), + frozen_row_(-1) { QMenu *main_menu_item, *submenu; QAction *action; @@ -882,6 +883,11 @@ void PacketList::freeze() { setUpdatesEnabled(false); column_state_ = header()->saveState(); + if (currentIndex().isValid()) { + frozen_row_ = currentIndex().row(); + } else { + frozen_row_ = -1; + } selectionModel()->clear(); setModel(NULL); // It looks like GTK+ sends a cursor-changed signal at this point but Qt doesn't @@ -891,7 +897,7 @@ void PacketList::freeze() byte_view_tab_->clear(); } -void PacketList::thaw() +void PacketList::thaw(bool restore_selection) { setUpdatesEnabled(true); setModel(packet_list_model_); @@ -900,6 +906,13 @@ void PacketList::thaw() // We don't reapply the recent settings because the user could have // resized the columns manually since they were initially loaded. header()->restoreState(column_state_); + + if (restore_selection && frozen_row_ > -1) { + // This updates our selection, which redissects the current packet, + // which is needed when we're called from MainWindow::layoutPanes. + setCurrentIndex(packet_list_model_->index(frozen_row_, 0)); + } + frozen_row_ = -1; } void PacketList::clear() { @@ -1388,7 +1401,7 @@ void PacketList::sectionMoved(int, int, int) g_list_free(prefs.col_list); prefs.col_list = new_col_list; - thaw(); + thaw(true); for (int i = 0; i < saved_sizes.length(); i++) { if (saved_sizes[i] < 1) continue; diff --git a/ui/qt/packet_list.h b/ui/qt/packet_list.h index 446d13a6b5..4f3d072831 100644 --- a/ui/qt/packet_list.h +++ b/ui/qt/packet_list.h @@ -61,8 +61,20 @@ public: QMenu *colorizeMenu() { return &colorize_menu_; } void setProtoTree(ProtoTree *proto_tree); void setByteViewTab(ByteViewTab *byteViewTab); + /** Disable and clear the packet list. + * + * Disable packet list widget updates, clear the detail and byte views, + * and disconnect the model. + */ void freeze(); - void thaw(); + /** Enable and restore the packet list. + * + * Enable packet list widget updates and reconnect the model. + * + * @param restore_selection If true, redissect the previously selected + * packet. This includes filling in the detail and byte views. + */ + void thaw(bool restore_selection = false); void clear(); void writeRecent(FILE *rf); bool contextMenuActive(); @@ -120,6 +132,7 @@ private: bool rows_inserted_; bool columns_changed_; bool set_column_visibility_; + int frozen_row_; void setFrameReftime(gboolean set, frame_data *fdata); void setColumnVisibility();