diff --git a/Software/PC_Application/LibreVNA-GUI/Traces/Math/expression.cpp b/Software/PC_Application/LibreVNA-GUI/Traces/Math/expression.cpp index 806a674..50f5e2b 100644 --- a/Software/PC_Application/LibreVNA-GUI/Traces/Math/expression.cpp +++ b/Software/PC_Application/LibreVNA-GUI/Traces/Math/expression.cpp @@ -15,6 +15,7 @@ Math::Expression::Expression() { parser = new ParserX(pckCOMMON | pckUNIT | pckCOMPLEX); parser->DefineVar("x", Variable(&x)); + dataType = DataType::Invalid; expressionChanged(); } @@ -37,10 +38,8 @@ void Math::Expression::edit() { auto d = new QDialog(); auto ui = new Ui::ExpressionDialog; + d->setAttribute(Qt::WA_DeleteOnClose); ui->setupUi(d); - connect(d, &QDialog::finished, [=](){ - delete ui; - }); ui->expEdit->setText(exp); connect(ui->buttonBox, &QDialogButtonBox::accepted, [=](){ exp = ui->expEdit->text(); @@ -93,7 +92,7 @@ void Math::Expression::inputSamplesChanged(unsigned int begin, unsigned int end) data.resize(in.size()); // sanity check input values if(end > 0 && end > in.size()) { - end = in.size() - 1; + end = in.size(); } if(end <= begin) { dataMutex.unlock(); @@ -119,6 +118,14 @@ void Math::Expression::inputSamplesChanged(unsigned int begin, unsigned int end) emit outputSamplesChanged(begin, end); } +void Math::Expression::inputTypeChanged(DataType type) +{ + // call base class slot + TraceMath::inputTypeChanged(type); + // we need to evaluate the expression again to create the correct variables + expressionChanged(); +} + void Math::Expression::expressionChanged() { if(exp.isEmpty()) { diff --git a/Software/PC_Application/LibreVNA-GUI/Traces/Math/expression.h b/Software/PC_Application/LibreVNA-GUI/Traces/Math/expression.h index 39e8b2e..2c17698 100644 --- a/Software/PC_Application/LibreVNA-GUI/Traces/Math/expression.h +++ b/Software/PC_Application/LibreVNA-GUI/Traces/Math/expression.h @@ -24,6 +24,7 @@ public: public slots: void inputSamplesChanged(unsigned int begin, unsigned int end) override; + virtual void inputTypeChanged(DataType type) override; private slots: void expressionChanged(); diff --git a/Software/PC_Application/LibreVNA-GUI/Traces/Math/tracemath.h b/Software/PC_Application/LibreVNA-GUI/Traces/Math/tracemath.h index e99b4b1..e8a238e 100644 --- a/Software/PC_Application/LibreVNA-GUI/Traces/Math/tracemath.h +++ b/Software/PC_Application/LibreVNA-GUI/Traces/Math/tracemath.h @@ -130,7 +130,7 @@ public slots: // some values of the input data have changed, begin/end determine which sample(s) has changed virtual void inputSamplesChanged(unsigned int begin, unsigned int end){Q_UNUSED(begin) Q_UNUSED(end)} - void inputTypeChanged(DataType type); + virtual void inputTypeChanged(DataType type); signals: // emit this whenever a sample changed (alternatively, if all samples are about to change, emit outputDataChanged after they have changed)