r16466 by fschmid - Fixed crash when loading the svg from bug 9078.

scribus-commit scribus-commit at lists.scribus.net
Sun Mar 20 22:53:52 CET 2011


Author: fschmid
Date: Sun Mar 20 21:53:52 2011
New Revision: 16466

URL: http://scribus.info/websvn/listing.php?repname=Scribus&sc=1&rev=16466
Log:
Fixed crash when loading the svg from bug 9078.

Modified:
    trunk/Scribus/scribus/plugins/import/svg/svgplugin.cpp

Modified: trunk/Scribus/scribus/plugins/import/svg/svgplugin.cpp
URL: http://scribus.info/websvn/diff.php?repname=Scribus&rev=16466&path=/trunk/Scribus/scribus/plugins/import/svg/svgplugin.cpp
==============================================================================
--- trunk/Scribus/scribus/plugins/import/svg/svgplugin.cpp (original)
+++ trunk/Scribus/scribus/plugins/import/svg/svgplugin.cpp Sun Mar 20 21:53:52 2011
@@ -1185,44 +1185,59 @@
 			double gy = miny;
 			double gw = maxx - minx;
 			double gh = maxy - miny;
-			neu->setXYPos(gx, gy);
-			neu->setWidthHeight(gw, gh);
-			if (clipPath.size() != 0)
-			{
-				QTransform mm = gc->matrix;
-				neu->PoLine = clipPath.copy();
-				neu->PoLine.map(mm);
-				neu->PoLine.translate(-gx + BaseX, -gy + BaseY);
-				clipPath.resize(0);
-
+			if (((gx > -9999999) && (gx < 9999999)) && ((gy > -9999999) && (gy < 9999999)) && ((gw > 0) && (gw < 9999999)) && ((gh > 0) && (gh < 9999999)))
+			{
+				neu->setXYPos(gx, gy);
+				neu->setWidthHeight(gw, gh);
+				if (clipPath.size() != 0)
+				{
+					QTransform mm = gc->matrix;
+					neu->PoLine = clipPath.copy();
+					neu->PoLine.map(mm);
+					neu->PoLine.translate(-gx + BaseX, -gy + BaseY);
+					clipPath.resize(0);
+					neu->Clip = FlattenPath(neu->PoLine, neu->Segments);
+				}
+				else
+					neu->SetRectFrame();
+				if( !e.attribute("id").isEmpty() )
+					neu->setItemName(e.attribute("id"));
+				else
+					neu->setItemName( tr("Group%1").arg(m_Doc->GroupCounter));
+				neu->AutoName = false;
+				neu->setFillTransparency(1 - gc->Opacity);
+				neu->gXpos = neu->xPos() - gx;
+				neu->gYpos = neu->yPos() - gy;
+				neu->groupWidth = gw;
+				neu->groupHeight = gh;
+				for (int gr = 0; gr < gElements.count(); ++gr)
+				{
+					PageItem* currItem = gElements.at(gr);
+					currItem->gXpos = currItem->xPos() - gx;
+					currItem->gYpos = currItem->yPos() - gy;
+					currItem->gWidth = gw;
+					currItem->gHeight = gh;
+					neu->groupItemList.append(currItem);
+					m_Doc->Items->removeAll(currItem);
+				}
+				neu->setRedrawBounding();
+				neu->setTextFlowMode(PageItem::TextFlowDisabled);
+				m_Doc->GroupCounter++;
+				m_Doc->renumberItemsInListOrder();
 			}
 			else
-				neu->SetRectFrame();
-			neu->Clip = FlattenPath(neu->PoLine, neu->Segments);
-			if( !e.attribute("id").isEmpty() )
-				neu->setItemName(e.attribute("id"));
-			else
-				neu->setItemName( tr("Group%1").arg(m_Doc->GroupCounter));
-			neu->AutoName = false;
-			neu->setFillTransparency(1 - gc->Opacity);
-			neu->gXpos = neu->xPos() - gx;
-			neu->gYpos = neu->yPos() - gy;
-			neu->groupWidth = gw;
-			neu->groupHeight = gh;
-			for (int gr = 0; gr < gElements.count(); ++gr)
-			{
-				PageItem* currItem = gElements.at(gr);
-				currItem->gXpos = currItem->xPos() - gx;
-				currItem->gYpos = currItem->yPos() - gy;
-				currItem->gWidth = gw;
-				currItem->gHeight = gh;
-				neu->groupItemList.append(currItem);
-				m_Doc->Items->removeAll(currItem);
-			}
-			neu->setRedrawBounding();
-			neu->setTextFlowMode(PageItem::TextFlowDisabled);
-			m_Doc->GroupCounter++;
-			m_Doc->renumberItemsInListOrder();
+			{
+				// Group is out of valid coordinates, remove it
+				GElements.removeAll(neu);
+				Selection tmpSelection(m_Doc, false);
+				tmpSelection.addItem(neu);
+				for (int gr = 0; gr < gElements.count(); ++gr)
+				{
+					tmpSelection.addItem(gElements.at(gr));
+				}
+				m_Doc->itemSelection_DeleteItem(&tmpSelection);
+				m_Doc->renumberItemsInListOrder();
+			}
 		}
 		delete( m_gc.pop() );
 	}




More information about the scribus-commit mailing list