Accept user-entered sample rates when external clock is enabled
[pulseview.git] / pv / toolbars / mainbar.cpp
index 1797e0a43e7de836b3695cfde24cf09647b6d150..16888624bc2f124030005fc481ae6838f5adbba5 100644 (file)
@@ -302,6 +302,17 @@ void MainBar::update_sample_rate_selector()
 
        const shared_ptr<sigrok::Device> sr_dev = device->device();
 
+       try {
+               auto gvar = sr_dev->config_get(ConfigKey::EXTERNAL_CLOCK);
+               if (gvar.gobj()) {
+                       bool value = Glib::VariantBase::cast_dynamic<Glib::Variant<bool>>(
+                               gvar).get();
+                       sample_rate_.allow_user_entered_values(value);
+               }
+       } catch (Error& error) {
+               // Do nothing
+       }
+
        if (sr_dev->config_check(ConfigKey::SAMPLERATE, Capability::LIST)) {
                try {
                        gvar_dict = sr_dev->config_list(ConfigKey::SAMPLERATE);
@@ -540,13 +551,6 @@ void MainBar::commit_sample_count()
        update_sample_rate_selector();
 }
 
-void MainBar::session_error(const QString text, const QString info_text)
-{
-       QMetaObject::invokeMethod(this, "show_session_error",
-               Qt::QueuedConnection, Q_ARG(QString, text),
-               Q_ARG(QString, info_text));
-}
-
 void MainBar::show_session_error(const QString text, const QString info_text)
 {
        QMessageBox msg(this);
@@ -736,6 +740,10 @@ void MainBar::on_sample_rate_changed()
 
 void MainBar::on_config_changed()
 {
+       // We want to also call update_sample_rate_selector() here in case
+       // the user changed the SR_CONF_EXTERNAL_CLOCK option. However,
+       // commit_sample_rate() does this already, so we don't call it here
+
        commit_sample_count();
        commit_sample_rate();
 }