]> sigrok.org Git - pulseview.git/blobdiff - pv/view/analogsignal.cpp
Fix #942 by making sure we always have at least one positive div
[pulseview.git] / pv / view / analogsignal.cpp
index 8f6027b7a52f990135fc54cbe0881b93fc4d1c0a..63e759f97ed7411922b70e2af4946dd2df643ad9 100644 (file)
@@ -737,6 +737,13 @@ void AnalogSignal::on_pos_vdivs_changed(int vdivs)
 
        pos_vdivs_ = vdivs;
 
+       // There has to be at least one div, positive or negative
+       if ((neg_vdivs_ == 0) && (pos_vdivs_ == 0)) {
+               pos_vdivs_ = 1;
+               if (pvdiv_sb_)
+                       pvdiv_sb_->setValue(pos_vdivs_);
+       }
+
        if (autoranging_) {
                perform_autoranging(true, true);
 
@@ -761,6 +768,13 @@ void AnalogSignal::on_neg_vdivs_changed(int vdivs)
 
        neg_vdivs_ = vdivs;
 
+       // There has to be at least one div, positive or negative
+       if ((neg_vdivs_ == 0) && (pos_vdivs_ == 0)) {
+               pos_vdivs_ = 1;
+               if (pvdiv_sb_)
+                       pvdiv_sb_->setValue(pos_vdivs_);
+       }
+
        if (autoranging_) {
                perform_autoranging(true, true);