r22159 by jghali -

scribus-commit scribus-commit at lists.scribus.net
Wed Sep 20 21:31:36 UTC 2017


Author: jghali
Date: Wed Sep 20 21:31:36 2017
New Revision: 22159

URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=22159
Log:
fix some cases of potential use of invalid pattern

Modified:
    trunk/Scribus/scribus/pageitem_line.cpp
    trunk/Scribus/scribus/scpageoutput.cpp

Modified: trunk/Scribus/scribus/pageitem_line.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=22159&path=/trunk/Scribus/scribus/pageitem_line.cpp
==============================================================================
--- trunk/Scribus/scribus/pageitem_line.cpp	(original)
+++ trunk/Scribus/scribus/pageitem_line.cpp	Wed Sep 20 21:31:36 2017
@@ -62,7 +62,8 @@
 	{
 		if (NamedLStyle.isEmpty())
 		{
-			if ((!patternStrokeVal.isEmpty()) && (m_Doc->docPatterns.contains(patternStrokeVal)))
+			ScPattern *strokePattern = m_Doc->checkedPattern(patternStrokeVal);
+			if (strokePattern)
 			{
 				if (patternStrokePath)
 				{
@@ -73,7 +74,7 @@
 				}
 				else
 				{
-					p->setPattern(&m_Doc->docPatterns[patternStrokeVal], patternStrokeScaleX, patternStrokeScaleY, patternStrokeOffsetX, patternStrokeOffsetY, patternStrokeRotation, patternStrokeSkewX, patternStrokeSkewY, patternStrokeMirrorX, patternStrokeMirrorY);
+					p->setPattern(strokePattern, patternStrokeScaleX, patternStrokeScaleY, patternStrokeOffsetX, patternStrokeOffsetY, patternStrokeRotation, patternStrokeSkewX, patternStrokeSkewY, patternStrokeMirrorX, patternStrokeMirrorY);
 					p->setStrokeMode(ScPainter::Pattern);
 					p->drawLine(FPoint(0, 0), FPoint(m_width, 0));
 				}

Modified: trunk/Scribus/scribus/scpageoutput.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=22159&path=/trunk/Scribus/scribus/scpageoutput.cpp
==============================================================================
--- trunk/Scribus/scribus/scpageoutput.cpp	(original)
+++ trunk/Scribus/scribus/scpageoutput.cpp	Wed Sep 20 21:31:36 2017
@@ -235,7 +235,8 @@
 	if (item->GrType == 8)
 	{
 		QString pat = item->pattern();
-		if ((pat.isEmpty()) || (!m_doc->docPatterns.contains(pat)))
+		ScPattern *pattern = m_doc->checkedPattern(pat);
+		if (!pattern)
 		{
 			painter->m_fillGradient = VGradientEx(VGradientEx::linear);
 			if (item->fillColor() != CommonStrings::None)
@@ -249,12 +250,11 @@
 		else
 		{
 			QTransform patternTransform;
-			ScPattern& pattern = m_doc->docPatterns[item->pattern()];
 			double patternScaleX, patternScaleY, patternOffsetX, patternOffsetY, patternRotation, patternSkewX, patternSkewY;
 			bool   patternMirrorX, patternMirrorY;
 			item->patternTransform(patternScaleX, patternScaleY, patternOffsetX, patternOffsetY, patternRotation, patternSkewX, patternSkewY);
 			item->patternFlip(patternMirrorX, patternMirrorY);
-			painter->setPattern(&pattern, patternScaleX, patternScaleY, patternOffsetX, patternOffsetY, patternRotation, patternSkewX, patternSkewY, patternMirrorX, patternMirrorY);
+			painter->setPattern(pattern, patternScaleX, patternScaleY, patternOffsetX, patternOffsetY, patternRotation, patternSkewX, patternSkewY, patternMirrorX, patternMirrorY);
 			painter->setFillMode(ScPainterExBase::Pattern);
 		}
 	}
@@ -376,11 +376,10 @@
 	else if ((item->GrMask == 3) || (item->GrMask == 6) || (item->GrMask == 7) || (item->GrMask == 8))
 	{
 		QString patternMaskVal = item->patternMaskVal;
-		if ((patternMaskVal.isEmpty()) || (!m_doc->docPatterns.contains(patternMaskVal)))
-			painter->setMaskMode(0);
-		else
-		{
-			painter->setPatternMask(&m_doc->docPatterns[patternMaskVal], item->patternMaskScaleX, item->patternMaskScaleY, item->patternMaskOffsetX, item->patternMaskOffsetY, 
+		ScPattern *patternMask = m_doc->checkedPattern(patternMaskVal);
+		if (patternMask)
+		{
+			painter->setPatternMask(patternMask, item->patternMaskScaleX, item->patternMaskScaleY, item->patternMaskOffsetX, item->patternMaskOffsetY,
 				                    item->patternMaskRotation, item->patternMaskSkewX, item->patternMaskSkewY, item->patternMaskMirrorX, item->patternMaskMirrorY);
 			if (item->GrMask == 3)
 				painter->setMaskMode(2);
@@ -391,6 +390,10 @@
 			else
 				painter->setMaskMode(6);
 		}
+		else
+		{
+			painter->setMaskMode(0);
+		}
 	}
 	else
 		painter->setMaskMode(0);
@@ -422,7 +425,8 @@
 			if (item->NamedLStyle.isEmpty())
 			{
 				QString patternStrokeVal = item->strokePattern();
-				if ((!patternStrokeVal.isEmpty()) && (m_doc->docPatterns.contains(patternStrokeVal)))
+				ScPattern *strokePattern = m_doc->checkedPattern(patternStrokeVal);
+				if (strokePattern)
 				{
 					if (item->patternStrokePath)
 					{
@@ -431,7 +435,7 @@
 					}
 					else
 					{
-						painter->setPattern(&m_doc->docPatterns[patternStrokeVal], item->patternStrokeScaleX, item->patternStrokeScaleY, item->patternStrokeOffsetX, item->patternStrokeOffsetY, item->patternStrokeRotation, item->patternStrokeSkewX, item->patternStrokeSkewY, item->patternStrokeMirrorX, item->patternStrokeMirrorY);
+						painter->setPattern(strokePattern, item->patternStrokeScaleX, item->patternStrokeScaleY, item->patternStrokeOffsetX, item->patternStrokeOffsetY, item->patternStrokeRotation, item->patternStrokeSkewX, item->patternStrokeSkewY, item->patternStrokeMirrorX, item->patternStrokeMirrorY);
 						painter->setStrokeMode(ScPainterExBase::Pattern);
 						painter->strokePath();
 					}
@@ -827,7 +831,8 @@
 	if (item->NamedLStyle.isEmpty())
 	{
 		QString patternStrokeVal = item->strokePattern();
-		if ((!patternStrokeVal.isEmpty()) && (m_doc->docPatterns.contains(patternStrokeVal)))
+		ScPattern *strokePattern = m_doc->checkedPattern(patternStrokeVal);
+		if (strokePattern)
 		{
 			if (item->patternStrokePath)
 			{
@@ -838,7 +843,7 @@
 			}
 			else
 			{
-				painter->setPattern(&m_doc->docPatterns[patternStrokeVal], item->patternStrokeScaleX, item->patternStrokeScaleY, item->patternStrokeOffsetX, item->patternStrokeOffsetY, item->patternStrokeRotation, item->patternStrokeSkewX, item->patternStrokeSkewY, item->patternStrokeMirrorX, item->patternStrokeMirrorY);
+				painter->setPattern(strokePattern, item->patternStrokeScaleX, item->patternStrokeScaleY, item->patternStrokeOffsetX, item->patternStrokeOffsetY, item->patternStrokeRotation, item->patternStrokeSkewX, item->patternStrokeSkewY, item->patternStrokeMirrorX, item->patternStrokeMirrorY);
 				painter->setStrokeMode(ScPainterExBase::Pattern);
 				painter->strokePath();
 			}
@@ -1162,7 +1167,8 @@
 	if (item->NamedLStyle.isEmpty())
 	{
 		QString patternStrokeVal = item->strokePattern();
-		if ((!patternStrokeVal.isEmpty()) && (m_doc->docPatterns.contains(patternStrokeVal)))
+		ScPattern *strokePattern = m_doc->checkedPattern(patternStrokeVal);
+		if (strokePattern)
 		{
 			if (item->patternStrokePath)
 			{
@@ -1173,7 +1179,7 @@
 			}
 			else
 			{
-				painter->setPattern(&m_doc->docPatterns[patternStrokeVal], item->patternStrokeScaleX, item->patternStrokeScaleY, item->patternStrokeOffsetX, item->patternStrokeOffsetY, item->patternStrokeRotation, item->patternStrokeSkewX, item->patternStrokeSkewY, item->patternStrokeMirrorX, item->patternStrokeMirrorY);
+				painter->setPattern(strokePattern, item->patternStrokeScaleX, item->patternStrokeScaleY, item->patternStrokeOffsetX, item->patternStrokeOffsetY, item->patternStrokeRotation, item->patternStrokeSkewX, item->patternStrokeSkewY, item->patternStrokeMirrorX, item->patternStrokeMirrorY);
 				painter->setStrokeMode(ScPainterExBase::Pattern);
 				painter->strokePath();
 			}
@@ -1328,7 +1334,8 @@
 	if (item->NamedLStyle.isEmpty())
 	{
 		QString patternStrokeVal = item->strokePattern();
-		if ((!patternStrokeVal.isEmpty()) && (m_doc->docPatterns.contains(patternStrokeVal)))
+		ScPattern *strokePattern = m_doc->checkedPattern(patternStrokeVal);
+		if (strokePattern)
 		{
 			if (item->patternStrokePath)
 			{
@@ -1339,7 +1346,7 @@
 			}
 			else
 			{
-				painter->setPattern(&m_doc->docPatterns[patternStrokeVal], item->patternStrokeScaleX, item->patternStrokeScaleY, item->patternStrokeOffsetX, item->patternStrokeOffsetY, item->patternStrokeRotation, item->patternStrokeSkewX, item->patternStrokeSkewY, item->patternStrokeMirrorX, item->patternStrokeMirrorY);
+				painter->setPattern(strokePattern, item->patternStrokeScaleX, item->patternStrokeScaleY, item->patternStrokeOffsetX, item->patternStrokeOffsetY, item->patternStrokeRotation, item->patternStrokeSkewX, item->patternStrokeSkewY, item->patternStrokeMirrorX, item->patternStrokeMirrorY);
 				painter->setStrokeMode(ScPainterExBase::Pattern);
 				painter->strokePath();
 			}




More information about the scribus-commit mailing list