]> sigrok.org Git - pulseview.git/commitdiff
MainBar: Fix #594 by changing calling order and flag usage
authorSoeren Apel <redacted>
Mon, 13 Jul 2015 19:00:10 +0000 (21:00 +0200)
committerUwe Hermann <redacted>
Wed, 15 Jul 2015 16:08:56 +0000 (18:08 +0200)
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.

pv/toolbars/mainbar.cpp

index 4bb39fac824795a56228baa32d90a476a43b4b41..529f25f46a1baf7bae3c4270d92c588ee052cd69 100644 (file)
@@ -507,9 +507,6 @@ void MainBar::commit_sample_rate()
 {
        uint64_t sample_rate = 0;
 
-       if (updating_sample_rate_)
-               return;
-
        const shared_ptr<devices::Device> 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<guint64>::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)