Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

At attempt to fix #398 #400

Merged
merged 3 commits into from
Nov 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -789,6 +789,8 @@ ListOfGlobalRenderInformation::getAllElements(ElementFilter* filter)
{
List* ret = new List();
List* sublist = ListOf::getAllElements(filter);
ret->transferFrom(sublist);
delete sublist;

ADD_FILTERED_POINTER(ret, sublist, mDefaultValues, filter);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -760,6 +760,8 @@ ListOfLocalRenderInformation::getAllElements(ElementFilter* filter)
{
List* ret = new List();
List* sublist = ListOf::getAllElements(filter);
ret->transferFrom(sublist);
delete sublist;

ADD_FILTERED_POINTER(ret, sublist, mDefaultValues, filter);

Expand Down
2 changes: 2 additions & 0 deletions src/sbml/packages/render/sbml/Style.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -601,6 +601,7 @@ Style::createGroup()

delete renderns;
this->setGroup(g);
delete g;

connectToChild();

Expand Down Expand Up @@ -1280,6 +1281,7 @@ Style::createObject(XMLInputStream& stream)
RenderGroup* g = new RenderGroup(renderns);
g->setElementName(name);
setGroup(g);
delete g;
obj = &mGroup;
}

Expand Down
117 changes: 62 additions & 55 deletions src/sbml/packages/render/sbml/Transformation2D.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -714,65 +714,72 @@ Transformation2D::addExpectedAttributes(ExpectedAttributes& attributes)
*/
void
Transformation2D::readAttributes(const XMLAttributes& attributes,
const ExpectedAttributes& expectedAttributes)
{
unsigned int level = getLevel();
unsigned int version = getVersion();
unsigned int pkgVersion = getPackageVersion();
unsigned int numErrs;
SBMLErrorLog* log = getErrorLog();

if (log && getParentSBMLObject() &&
static_cast<ListOfDrawables*>(getParentSBMLObject())->size() < 2)
{
numErrs = log->getNumErrors();
for (int n = numErrs-1; n >= 0; n--)
{
if (log->getError(n)->getErrorId() == UnknownPackageAttribute)
{
const std::string details = log->getError(n)->getMessage();
log->remove(UnknownPackageAttribute);
log->logPackageError("render", RenderUnknown, pkgVersion, level,
version, details, getLine(), getColumn());
}
else if (log->getError(n)->getErrorId() == UnknownCoreAttribute)
{
const std::string details = log->getError(n)->getMessage();
log->remove(UnknownCoreAttribute);
log->logPackageError("render", RenderUnknown, pkgVersion, level,
version, details, getLine(), getColumn());
}
const ExpectedAttributes& expectedAttributes)
{
unsigned int level = getLevel();
unsigned int version = getVersion();
unsigned int pkgVersion = getPackageVersion();
unsigned int numErrs;
SBMLErrorLog* log = getErrorLog();

if (log && getParentSBMLObject()) {
bool isSizeOne = false;
int type = getParentSBMLObject()->getTypeCode();
switch (type) {
case SBML_LIST_OF:
if (static_cast<ListOf*>(getParentSBMLObject())->size() < 2)
{
isSizeOne = true;
}
break;
case SBML_RENDER_LINEENDING:
case SBML_RENDER_STYLE_BASE:
case SBML_RENDER_LOCALSTYLE:
case SBML_RENDER_GLOBALSTYLE:
// These objects all have a single RenderGroup child, so the size can never be greater than 2.
isSizeOne = true;
break;
case SBML_RENDER_GROUP:
{
//A RenderGroup can have multiple Transformation2D children.
RenderGroup* rg = static_cast<RenderGroup*>(getParentSBMLObject());
if (rg->getNumElements() < 2)
{
isSizeOne = false;
}
break;
}
default:
assert(false); //Some situation we didn't think through; could be anything.
isSizeOne = true;
}
if (isSizeOne) {
numErrs = log->getNumErrors();
for (int n = numErrs - 1; n >= 0; n--)
{
if (log->getError(n)->getErrorId() == UnknownPackageAttribute)
{
const std::string details = log->getError(n)->getMessage();
log->remove(UnknownPackageAttribute);
log->logPackageError("render", RenderUnknown, pkgVersion, level,
version, details, getLine(), getColumn());
}
else if (log->getError(n)->getErrorId() == UnknownCoreAttribute)
{
const std::string details = log->getError(n)->getMessage();
log->remove(UnknownCoreAttribute);
log->logPackageError("render", RenderUnknown, pkgVersion, level,
version, details, getLine(), getColumn());
}
}
}
}
}

Transformation::readAttributes(attributes, expectedAttributes);

//if (log)
//{
// numErrs = log->getNumErrors();

// for (int n = numErrs-1; n >= 0; n--)
// {
// if (log->getError(n)->getErrorId() == UnknownPackageAttribute)
// {
// const std::string details = log->getError(n)->getMessage();
// log->remove(UnknownPackageAttribute);
// log->logPackageError("render", RenderUnknown, pkgVersion, level,
// version, details);
// }
// else if (log->getError(n)->getErrorId() == UnknownCoreAttribute)
// {
// const std::string details = log->getError(n)->getMessage();
// log->remove(UnknownCoreAttribute);
// log->logPackageError("render",
// RenderTransformation2DAllowedCoreAttributes, pkgVersion, level,
// version, details);
// }
// }
//}
Transformation::readAttributes(attributes, expectedAttributes);

std::string s;
attributes.readInto("transform", s);
if(!s.empty())
if (!s.empty())
{
this->parseTransformation(s);
}
Expand Down
Loading