mupp add var: check if a variable for a given collection already exists, and if yes, replace it, otherwise add the new variable.

This commit is contained in:
suter_a 2020-05-17 16:07:52 +02:00
parent 39e427a0cd
commit 0314c1225b

View File

@ -1361,7 +1361,18 @@ void PmuppGui::add(QString varStr, QVector<int> idx)
parseErrMsgDlg();
return;
}
// check if variable name for the given collection already exists
int var_idx=-1;
for (int k=0; k<fVarHandler.size(); k++) {
if ((fVarHandler[k].getVarName() == var.getVarName()) &&
(fVarHandler[k].getCollName()) == var.getCollName()) {
var_idx = k;
}
}
if (var_idx == -1) // a new variable
fVarHandler.push_back(var); // collect all valid variables
else // replace an already existing variable
fVarHandler[var_idx] = var;
}
}