From: Soeren Apel Date: Mon, 13 Jul 2015 19:00:10 +0000 (+0200) Subject: MainBar: Fix #594 by changing calling order and flag usage X-Git-Tag: pulseview-0.3.0~179 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=0e0b6b3e3425f730c8ae0a36b5fb50c02ce0ba54;p=pulseview.git MainBar: Fix #594 by changing calling order and flag usage The reason that the sampling rate button disappears after a sampling rate was selected is that there's a flaw in the chain of events: on_sample_rate_changed() which calls commit_sample_rate() which sets updating_sample_rate_ and calls on_config_changed() which calls update_sample_rate_selector() which... ...clears the list and exits because updating_sample_rate_ is set. --- diff --git a/pv/toolbars/mainbar.cpp b/pv/toolbars/mainbar.cpp index 4bb39fac..529f25f4 100644 --- a/pv/toolbars/mainbar.cpp +++ b/pv/toolbars/mainbar.cpp @@ -507,9 +507,6 @@ void MainBar::commit_sample_rate() { uint64_t sample_rate = 0; - if (updating_sample_rate_) - return; - const shared_ptr device = device_selector_.selected_device(); if (!device) @@ -521,18 +518,14 @@ void MainBar::commit_sample_rate() if (sample_rate == 0) return; - // Set the samplerate - assert(!updating_sample_rate_); - updating_sample_rate_ = true; try { sr_dev->config_set(ConfigKey::SAMPLERATE, Glib::Variant::create(sample_rate)); - on_config_changed(); + update_sample_rate_selector(); } catch (Error error) { qDebug() << "Failed to configure samplerate."; return; } - updating_sample_rate_ = false; } void MainBar::on_device_selected() @@ -553,7 +546,8 @@ void MainBar::on_sample_count_changed() void MainBar::on_sample_rate_changed() { - commit_sample_rate(); + if (!updating_sample_rate_) + commit_sample_rate(); } void MainBar::on_run_stop() @@ -566,9 +560,8 @@ void MainBar::on_run_stop() void MainBar::on_config_changed() { commit_sample_count(); - update_sample_count_selector(); + update_sample_count_selector(); commit_sample_rate(); - update_sample_rate_selector(); } bool MainBar::eventFilter(QObject *watched, QEvent *event)