From: Soeren Apel Date: Sat, 27 Aug 2016 20:23:28 +0000 (+0200) Subject: Session/MainBar: Fix device change handling X-Git-Tag: pulseview-0.4.0~262 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=91f8fe8c30131fb438dbdb1b58d69ede7ba9247b;p=pulseview.git Session/MainBar: Fix device change handling --- diff --git a/pv/session.cpp b/pv/session.cpp index b18d27ff..da9da126 100644 --- a/pv/session.cpp +++ b/pv/session.cpp @@ -270,7 +270,7 @@ void Session::set_device(shared_ptr device) device_->open(); } catch (const QString &e) { device_.reset(); - device_selected(); + device_changed(); throw; } @@ -280,7 +280,7 @@ void Session::set_device(shared_ptr device) }); update_signals(); - device_selected(); + device_changed(); } void Session::set_default_device() diff --git a/pv/session.hpp b/pv/session.hpp index 258addb9..e7a90ae9 100644 --- a/pv/session.hpp +++ b/pv/session.hpp @@ -204,7 +204,7 @@ private: Q_SIGNALS: void capture_state_changed(int state); - void device_selected(); + void device_changed(); void signals_changed(); diff --git a/pv/toolbars/mainbar.cpp b/pv/toolbars/mainbar.cpp index 6a5992bf..1875d3c4 100644 --- a/pv/toolbars/mainbar.cpp +++ b/pv/toolbars/mainbar.cpp @@ -236,6 +236,8 @@ MainBar::MainBar(Session &session, MainWindow &main_window) : // Device selector menu connect(&device_selector_, SIGNAL(device_selected()), this, SLOT(on_device_selected())); + connect(&session, SIGNAL(device_changed()), + this, SLOT(on_device_changed())); // Setup the decoder button #ifdef ENABLE_DECODE @@ -301,8 +303,6 @@ MainBar::MainBar(Session &session, MainWindow &main_window) : sample_count_.installEventFilter(this); sample_rate_.installEventFilter(this); - QMetaObject::connectSlotsByName(this); - // Setup session_ events connect(&session_, SIGNAL(capture_state_changed(int)), this, SLOT(capture_state_changed(int))); @@ -909,7 +909,11 @@ void MainBar::on_device_selected() } select_device(device); +} +void MainBar::on_device_changed() +{ + update_device_list(); update_device_config_widgets(); } diff --git a/pv/toolbars/mainbar.hpp b/pv/toolbars/mainbar.hpp index c05a146e..a50d1101 100644 --- a/pv/toolbars/mainbar.hpp +++ b/pv/toolbars/mainbar.hpp @@ -147,6 +147,7 @@ private Q_SLOTS: void import_file(std::shared_ptr format); void on_device_selected(); + void on_device_changed(); void on_sample_count_changed(); void on_sample_rate_changed(); void on_run_stop();