@@ -229,8 +229,8 @@ SignalGenerator::SignalGenerator(libm2k::context::M2k *m2k, QString uri, Filter
229229 fileAmplitude = new ScaleSpinButton ({{tr (" μVolts" ), 1e-6 }, {tr (" mVolts" ), 1e-3 }, {tr (" Volts" ), 1e0 }},
230230 tr (" Amplitude" ), 0.000001 , 10 , true , true , this );
231231
232- mathSampleRate = new ScaleSpinButton ({{" msps " , 1e-3 }, { " sps" , 1e0 }, {" ksps" , 1e3 }, {" Msps" , 1e6 }},
233- tr ( " SampleRate " ), 0.001 , 75000000.0 , true , false , this );
232+ mathSampleRate = new ScaleSpinButton ({{" sps" , 1e0 }, {" ksps" , 1e3 }, {" Msps" , 1e6 }}, tr ( " SampleRate " ), 0.001 ,
233+ 75000000.0 , true , false , this );
234234
235235 mathSampleRate->setIntegerDivider (75000000 );
236236
@@ -553,6 +553,19 @@ void SignalGenerator::readPreferences()
553553 ui->instrumentNotes ->setVisible (p->get (" m2k_instrument_notes_active" ).toBool ());
554554}
555555
556+ void SignalGenerator::checkRunEnabled ()
557+ {
558+ size_t size = (size_t )mathSampleRate->value () * mathRecordLength->value ();
559+ if (size <= 0 ) {
560+ ui->run_button ->setEnabled (false );
561+ if (m_running) {
562+ stop ();
563+ }
564+ } else {
565+ ui->run_button ->setEnabled (true );
566+ }
567+ }
568+
556569void SignalGenerator::resetZoom ()
557570{
558571
@@ -781,6 +794,8 @@ void SignalGenerator::mathRecordLengthChanged(double value)
781794 ptr->math_record_length = value;
782795 resetZoom ();
783796 }
797+
798+ checkRunEnabled ();
784799}
785800
786801void SignalGenerator::mathSampleRateChanged (double value)
@@ -790,6 +805,8 @@ void SignalGenerator::mathSampleRateChanged(double value)
790805 ptr->math_sr = value;
791806 resetZoom ();
792807 }
808+
809+ checkRunEnabled ();
793810}
794811
795812void SignalGenerator::noiseTypeChanged (int index)
@@ -1000,6 +1017,11 @@ void SignalGenerator::tabChanged(int index)
10001017 if (ptr->type == SIGNAL_TYPE_BUFFER) {
10011018 loadFileCurrentChannelData ();
10021019 }
1020+ if (ptr->type == SIGNAL_TYPE_MATH) {
1021+ checkRunEnabled ();
1022+ } else {
1023+ ui->run_button ->setEnabled (true );
1024+ }
10031025 resizeTabWidget (index); // causes small glitch on windows, to be investigated
10041026 resetZoom ();
10051027 }
@@ -2272,6 +2294,12 @@ size_t SignalGenerator::get_samples_count(unsigned int chnIdx, double rate, bool
22722294 }
22732295
22742296out_cleanup:
2297+
2298+ // for size 0 return 0 going further with this value will get stuck in an infinite loop
2299+ if (size == 0 ) {
2300+ return 0 ;
2301+ }
2302+
22752303 /* The buffer size must be a multiple of 4 */
22762304 if (ptr->type == SIGNAL_TYPE_BUFFER) {
22772305 size = size + size % 0x04 ;
0 commit comments