Skip to content

Commit

Permalink
Reverted part of commit 0c9e02c.
Browse files Browse the repository at this point in the history
I did a bit too much cleaning up!
  • Loading branch information
agarny committed Feb 5, 2020
1 parent db573df commit fce9896
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions src/plugins/support/CellMLSupport/src/cellmlfileruntime.cpp
Expand Up @@ -317,6 +317,7 @@ void CellmlFileRuntime::update(CellmlFile *pCellmlFile, bool pAll)
// in a SED-ML file...

QMap<iface::cellml_api::CellMLVariable *, iface::cellml_api::CellMLVariable *> mainVariables;
QList<iface::cellml_api::CellMLVariable *> realMainVariables;
ObjRef<iface::cellml_api::CellMLComponentIterator> localComponentsIter = model->localComponents()->iterateComponents();

for (ObjRef<iface::cellml_api::CellMLComponent> component = localComponentsIter->nextComponent();
Expand All @@ -325,7 +326,20 @@ void CellmlFileRuntime::update(CellmlFile *pCellmlFile, bool pAll)

for (ObjRef<iface::cellml_api::CellMLVariable> variable = variablesIter->nextVariable();
variable != nullptr; variable = variablesIter->nextVariable()) {
mainVariables.insert(variable->sourceVariable(), variable);
ObjRef<iface::cellml_api::CellMLVariable> sourceVariable = variable->sourceVariable();

mainVariables.insert(sourceVariable, variable);

// In CellML 1.0 models / some CellML 1.1 models, the source
// variable is / may be defined in the main CellML file and may
// be used (and therefore referenced) in different places in
// that same main CellML file, in which case we need to keep
// track of the real main variable, which is the one which
// source variable is the same

if (variable == sourceVariable) {
realMainVariables << variable;
}
}
}

Expand All @@ -343,7 +357,9 @@ void CellmlFileRuntime::update(CellmlFile *pCellmlFile, bool pAll)
// our main CellML file, if it has imports

ObjRef<iface::cellml_api::CellMLVariable> variable = computationTarget->variable();
iface::cellml_api::CellMLVariable *mainVariable = mainVariables.value(variable);
iface::cellml_api::CellMLVariable *mainVariable = realMainVariables.contains(variable)?
variable.getPointer():
mainVariables.value(variable);
iface::cellml_api::CellMLVariable *realVariable = (mainVariable != nullptr)?
mainVariable:
variable.getPointer();
Expand Down

0 comments on commit fce9896

Please sign in to comment.