X-Git-Url: https://sigrok.org/gitweb/?p=pulseview.git;a=blobdiff_plain;f=pv%2Ftoolbars%2Fmainbar.cpp;h=6d225369dda8516563160dec278167b63c6c3c9f;hp=1797e0a43e7de836b3695cfde24cf09647b6d150;hb=2d20774fe218b2b72169fbbc37f161b7b2b6f410;hpb=30677c1392b54604b01558cf29b44572731659fc diff --git a/pv/toolbars/mainbar.cpp b/pv/toolbars/mainbar.cpp index 1797e0a4..6d225369 100644 --- a/pv/toolbars/mainbar.cpp +++ b/pv/toolbars/mainbar.cpp @@ -302,6 +302,21 @@ void MainBar::update_sample_rate_selector() const shared_ptr sr_dev = device->device(); + sample_rate_.allow_user_entered_values(false); + if (sr_dev->config_check(ConfigKey::EXTERNAL_CLOCK, Capability::GET)) { + try { + auto gvar = sr_dev->config_get(ConfigKey::EXTERNAL_CLOCK); + if (gvar.gobj()) { + bool value = Glib::VariantBase::cast_dynamic>( + 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); @@ -494,8 +509,6 @@ void MainBar::commit_sample_rate() const shared_ptr sr_dev = device->device(); sample_rate = sample_rate_.value(); - if (sample_rate == 0) - return; try { sr_dev->config_set(ConfigKey::SAMPLERATE, @@ -540,13 +553,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); @@ -599,9 +605,9 @@ void MainBar::export_file(shared_ptr format, bool selection_only) const pv::util::Timestamp& end_time = trace_view->cursors()->second()->time(); const uint64_t start_sample = (uint64_t)max( - (double)0, start_time.convert_to() * samplerate); + 0.0, start_time.convert_to() * samplerate); const uint64_t end_sample = (uint64_t)max( - (double)0, end_time.convert_to() * samplerate); + 0.0, end_time.convert_to() * samplerate); if ((start_sample == 0) && (end_sample == 0)) { // Both cursors are negative and were clamped to 0 @@ -736,6 +742,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(); }