Kaydet (Commit) 68c6af8d authored tarafından Fridrich Štrba's avatar Fridrich Štrba

Fix a memory leak with opacity gradients

üst 0faf9527
...@@ -1033,7 +1033,6 @@ void OdgGeneratorPrivate::_writeGraphicsStyle() ...@@ -1033,7 +1033,6 @@ void OdgGeneratorPrivate::_writeGraphicsStyle()
if(mxStyle["draw:fill"] && mxStyle["draw:fill"]->getStr() == "gradient") if(mxStyle["draw:fill"] && mxStyle["draw:fill"]->getStr() == "gradient")
{ {
bUseOpacityGradient = true;
TagOpenElement *pDrawGradientElement = new TagOpenElement("draw:gradient"); TagOpenElement *pDrawGradientElement = new TagOpenElement("draw:gradient");
TagOpenElement *pDrawOpacityElement = new TagOpenElement("draw:opacity"); TagOpenElement *pDrawOpacityElement = new TagOpenElement("draw:opacity");
if (mxStyle["draw:style"]) if (mxStyle["draw:style"])
...@@ -1127,14 +1126,10 @@ void OdgGeneratorPrivate::_writeGraphicsStyle() ...@@ -1127,14 +1126,10 @@ void OdgGeneratorPrivate::_writeGraphicsStyle()
// Work around a mess in LibreOffice where both opacities of 100% are interpreted as complete transparency // Work around a mess in LibreOffice where both opacities of 100% are interpreted as complete transparency
// Nevertheless, when one is different, immediately, they are interpreted correctly // Nevertheless, when one is different, immediately, they are interpreted correctly
if (!(mxStyle["libwpg:start-opacity"] && mxStyle["libwpg:end-opacity"]) if (mxStyle["libwpg:start-opacity"] && mxStyle["libwpg:end-opacity"]
|| (mxStyle["libwpg:start-opacity"]->getDouble() == 1.0 && mxStyle["libwpg:end-opacity"]->getDouble() == 1.0)) && (mxStyle["libwpg:start-opacity"]->getDouble() != 1.0 || mxStyle["libwpg:end-opacity"]->getDouble() != 1.0))
{
delete pDrawOpacityElement;
bUseOpacityGradient = false;
}
else
{ {
bUseOpacityGradient = true;
mGraphicsGradientStyles.push_back(pDrawOpacityElement); mGraphicsGradientStyles.push_back(pDrawOpacityElement);
mGraphicsGradientStyles.push_back(new TagCloseElement("draw:opacity")); mGraphicsGradientStyles.push_back(new TagCloseElement("draw:opacity"));
} }
...@@ -1162,6 +1157,9 @@ void OdgGeneratorPrivate::_writeGraphicsStyle() ...@@ -1162,6 +1157,9 @@ void OdgGeneratorPrivate::_writeGraphicsStyle()
mGraphicsGradientStyles.push_back(pDrawGradientElement); mGraphicsGradientStyles.push_back(pDrawGradientElement);
mGraphicsGradientStyles.push_back(new TagCloseElement("draw:gradient")); mGraphicsGradientStyles.push_back(new TagCloseElement("draw:gradient"));
} }
if(!bUseOpacityGradient)
delete pDrawOpacityElement;
} }
TagOpenElement *pStyleStyleElement = new TagOpenElement("style:style"); TagOpenElement *pStyleStyleElement = new TagOpenElement("style:style");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment