Fix: do not reset variable names for from math traces when opening trace edit dialog

This commit is contained in:
Jan Käberich 2025-05-12 16:56:38 +02:00
parent 69bb1e493e
commit 6b81b307b7
2 changed files with 15 additions and 1 deletions

View file

@ -551,6 +551,10 @@ void Trace::scheduleMathCalculation(unsigned int begin, unsigned int end)
void Trace::calculateMath()
{
lastMathUpdate = QTime::currentTime();
if(mathUpdateEnd <= mathUpdateBegin) {
// nothing to do
return;
}
if(mathUpdateBegin >= data.size() || mathUpdateEnd >= data.size() + 1) {
qWarning() << "Not calculating math trace, out of limits. Requested from" << mathUpdateBegin << "to" << mathUpdateEnd <<" but data is of size" << data.size();
return;
@ -660,6 +664,11 @@ bool Trace::canAddAsMathSource(Trace *t)
bool Trace::addMathSource(Trace *t, QString variableName)
{
if(mathSourceTraces.count(t)) {
// this trace is already used as a math source
mathSourceTraces[t] = variableName;
return true;
}
// qDebug() << "Adding trace" << t << "as a math source to" << this << "as variable" << variableName;
if(!canAddAsMathSource(t)) {
return false;

View file

@ -172,6 +172,7 @@ TraceEditDialog::TraceEditDialog(Trace &t, QWidget *parent) :
if(t.mathDependsOn(ts, true)) {
traceItem->setCheckState(Qt::Checked);
variableItem->setFlags(variableItem->flags() | Qt::ItemIsEnabled | Qt::ItemIsEditable);
ui->mathTraceTable->blockSignals(false);
} else {
traceItem->setCheckState(Qt::Unchecked);
}
@ -181,7 +182,7 @@ TraceEditDialog::TraceEditDialog(Trace &t, QWidget *parent) :
connect(ui->mathTraceTable, &QTableWidget::itemChanged, [&](QTableWidgetItem *item){
auto row = ui->mathTraceTable->row(item);
auto column = ui->mathTraceTable->column(item);
qDebug() << "Item changed at row"<<row<<"column"<<column;
// qDebug() << "Item changed at row"<<row<<"column"<<column;
ui->mathTraceTable->blockSignals(true);
auto trace = t.getModel()->trace(row);
if(column == 0) {
@ -408,6 +409,9 @@ bool TraceEditDialog::updateMathFormulaStatus()
void TraceEditDialog::updateMathFormulaSelectableRows()
{
// available trace selections may have changed, disable/enable other rows
// block signals, otherwise the trace names will be reset
ui->mathTraceTable->blockSignals(true);
for(unsigned int i=0;i<trace.getModel()->getTraces().size();i++) {
auto traceItem = ui->mathTraceTable->item(i, 0);
auto flags = traceItem->flags();
@ -418,6 +422,7 @@ void TraceEditDialog::updateMathFormulaSelectableRows()
traceItem->setFlags(flags & ~Qt::ItemIsEnabled);
}
}
ui->mathTraceTable->blockSignals(false);
}
MathModel::MathModel(Trace &t, QObject *parent)