mirror of
https://github.com/jankae/LibreVNA.git
synced 2026-01-27 19:04:15 +01:00
Custom expression bugfixes
- Off-by-one error when number of input samples changes - race condition when closing custom expression edit dialog - adjust available variables when input data type changes
This commit is contained in:
parent
fde6707c9c
commit
d6020a6a26
|
|
@ -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()) {
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Reference in a new issue