From 259ebc5269ddc8d9d7c221abd79509372078a17f Mon Sep 17 00:00:00 2001 From: Evan Huus Date: Tue, 3 Sep 2013 16:06:20 +0000 Subject: [PATCH] Respect the other layout preference in qtshark: which pane goes in which spot. svn path=/trunk/; revision=51723 --- ui/qt/main_window.cpp | 16 ++++++++++++++++ ui/qt/main_window.h | 4 ++++ ui/qt/main_window_slots.cpp | 14 +++++++++++--- 3 files changed, 31 insertions(+), 3 deletions(-) diff --git a/ui/qt/main_window.cpp b/ui/qt/main_window.cpp index dae12e58d3..8e5e6502fc 100644 --- a/ui/qt/main_window.cpp +++ b/ui/qt/main_window.cpp @@ -168,6 +168,7 @@ MainWindow::MainWindow(QWidget *parent) : main_ui_->menuHelp->insertAction(update_sep, update_action); connect(update_action, SIGNAL(triggered()), this, SLOT(on_actionHelpCheckForUpdates_triggered())); #endif + empty_pane_ = new QWidget(main_ui_->mainStack); packet_list_ = new PacketList(main_ui_->mainStack); @@ -397,6 +398,21 @@ void MainWindow::closeEvent(QCloseEvent *event) { } +QWidget* MainWindow::getLayoutWidget(layout_pane_content_e type) { + switch (type) { + case layout_pane_content_none: + return empty_pane_; + case layout_pane_content_plist: + return packet_list_; + case layout_pane_content_pdetails: + return proto_tree_; + case layout_pane_content_pbytes: + return byte_view_tab_; + default: + g_assert_not_reached(); + return NULL; + } +} void MainWindow::mergeCaptureFile() { diff --git a/ui/qt/main_window.h b/ui/qt/main_window.h index c3cde88823..0f68a9b863 100644 --- a/ui/qt/main_window.h +++ b/ui/qt/main_window.h @@ -34,6 +34,8 @@ #include "ui/ui_util.h" +#include + #ifdef HAVE_LIBPCAP #include "capture_opts.h" #include "capture_session.h" @@ -105,6 +107,7 @@ private: FileSetDialog file_set_dialog_; SummaryDialog summary_dialog_; ByteViewTab *byte_view_tab_; + QWidget *empty_pane_; bool capture_stopping_; bool capture_filter_valid_; @@ -120,6 +123,7 @@ private: QSocketNotifier *pipe_notifier_; #endif + QWidget* getLayoutWidget(layout_pane_content_e type); void mergeCaptureFile(); void importCaptureFile(); void saveCaptureFile(capture_file *cf, bool stay_closed); diff --git a/ui/qt/main_window_slots.cpp b/ui/qt/main_window_slots.cpp index 94ab45947c..ef927e020a 100644 --- a/ui/qt/main_window_slots.cpp +++ b/ui/qt/main_window_slots.cpp @@ -262,18 +262,26 @@ void MainWindow::layoutPanes() g_assert_not_reached(); } + // We reparent all widgets immediately, because if one of them is left + // unused then it would be deleted when we delete oldMaster, which would + // lead to a crash next time we tried to use it. + packet_list_->setParent(main_ui_->mainStack); + proto_tree_->setParent(main_ui_->mainStack); + byte_view_tab_->setParent(main_ui_->mainStack); + empty_pane_->setParent(main_ui_->mainStack); + if (parents[0] == extra_split_) { master_split_->addWidget(extra_split_); } - parents[0]->addWidget(packet_list_); + parents[0]->addWidget(getLayoutWidget(prefs.gui_layout_content_1)); if (parents[2] == extra_split_) { master_split_->addWidget(extra_split_); } - parents[1]->addWidget(proto_tree_); - parents[2]->addWidget(byte_view_tab_); + parents[1]->addWidget(getLayoutWidget(prefs.gui_layout_content_2)); + parents[2]->addWidget(getLayoutWidget(prefs.gui_layout_content_3)); // We must do this near the end to avoid reparenting signals going to // already-deleted widgets.