From: <fbe...@us...> - 2019-06-21 08:44:03
|
Revision: 26064 http://sourceforge.net/p/sbml/code/26064 Author: fbergmann Date: 2019-06-21 08:43:54 +0000 (Fri, 21 Jun 2019) Log Message: ----------- - issue #166837864: when converting to local parameters delete old parameters so that meta id validator wont' complain (also fix use after delete crash in lv converter, requiring document to become a friend) Modified Paths: -------------- trunk/libsbml/src/sbml/SBMLConvert.cpp trunk/libsbml/src/sbml/SBMLDocument.h trunk/libsbml/src/sbml/conversion/SBMLLevelVersionConverter.cpp Modified: trunk/libsbml/src/sbml/SBMLConvert.cpp =================================================================== --- trunk/libsbml/src/sbml/SBMLConvert.cpp 2019-06-10 12:04:56 UTC (rev 26063) +++ trunk/libsbml/src/sbml/SBMLConvert.cpp 2019-06-21 08:43:54 UTC (rev 26064) @@ -820,6 +820,10 @@ kl->getListOfLocalParameters()->appendAndOwn(lp); // kl->addLocalParameter(lp); } + + // remove old parameters (while they would not be written out, + // (or used) the meta id validator would complain otherwise) + kl->getListOfParameters()->clear(true); } } } Modified: trunk/libsbml/src/sbml/SBMLDocument.h =================================================================== --- trunk/libsbml/src/sbml/SBMLDocument.h 2019-06-10 12:04:56 UTC (rev 26063) +++ trunk/libsbml/src/sbml/SBMLDocument.h 2019-06-21 08:43:54 UTC (rev 26064) @@ -317,6 +317,7 @@ class SBMLValidator; class SBMLInternalValidator; +class SBMLLevelVersionConverter; /** @cond doxygenLibsbmlInternal */ /* Internal constants for setting/unsetting particular consistency checks. */ @@ -1707,6 +1708,7 @@ friend class SBase; friend class SBMLReader; + friend class SBMLLevelVersionConverter; /** @endcond */ }; Modified: trunk/libsbml/src/sbml/conversion/SBMLLevelVersionConverter.cpp =================================================================== --- trunk/libsbml/src/sbml/conversion/SBMLLevelVersionConverter.cpp 2019-06-10 12:04:56 UTC (rev 26063) +++ trunk/libsbml/src/sbml/conversion/SBMLLevelVersionConverter.cpp 2019-06-21 08:43:54 UTC (rev 26064) @@ -409,13 +409,15 @@ validateConvertedDocument(); bool errors = has_fatal_errors(origLevel, origVersion); if (errors) - { /* error - we dont covert + { /* error - we don't covert * restore original values and return */ conversion = false; /* undo any changes */ - delete currentModel; + delete currentModel; //!! deletes mDocument->mModel!!!! currentModel = origModel.clone(); + mDocument->mModel = currentModel; // so we have to set it again + mDocument->updateSBMLNamespace("core", origLevel, origVersion); mDocument->setApplicableValidators(origValidators); } @@ -439,7 +441,7 @@ if (resetAnnotations) { // hack to force the model history to think it haschanged - this will - // change the vacrd if necessary + // change the vcard if necessary if (mDocument->isSetModel() && mDocument->getModel()->isSetModelHistory()) { ModelHistory * history = mDocument->getModel()->getModelHistory()->clone(); |