r16083 by jghali - #9567: crash when creating duplicate layer

scribus-commit scribus-commit at lists.scribus.net
Fri Dec 10 22:29:12 CET 2010


Author: jghali
Date: Fri Dec 10 21:29:11 2010
New Revision: 16083

URL: http://scribus.info/websvn/listing.php?repname=Scribus&sc=1&rev=16083
Log:
#9567: crash when creating duplicate layer

Modified:
    branches/Version135/Scribus/scribus/scribusdoc.cpp
    branches/Version135/Scribus/scribus/serializer.cpp

Modified: branches/Version135/Scribus/scribus/scribusdoc.cpp
URL: http://scribus.info/websvn/diff.php?repname=Scribus&rev=16083&path=/branches/Version135/Scribus/scribus/scribusdoc.cpp
==============================================================================
--- branches/Version135/Scribus/scribus/scribusdoc.cpp (original)
+++ branches/Version135/Scribus/scribus/scribusdoc.cpp Fri Dec 10 21:29:11 2010
@@ -1923,10 +1923,13 @@
 			sourceSelection.addItem(itemToCopy);
 		}
 	}
-	Selection targetSelection(Serializer(*this).cloneObjects(sourceSelection));
-	for(int si(0); si < targetSelection.count(); ++si)
-	{
-		targetSelection.itemAt(si)->setLayer(whereToInsert);
+	if (sourceSelection.count() > 0)
+	{
+		Selection targetSelection(Serializer(*this).cloneObjects(sourceSelection));
+		for(int si(0); si < targetSelection.count(); ++si)
+		{
+			targetSelection.itemAt(si)->setLayer(whereToInsert);
+		}
 	}
 }
 

Modified: branches/Version135/Scribus/scribus/serializer.cpp
URL: http://scribus.info/websvn/diff.php?repname=Scribus&rev=16083&path=/branches/Version135/Scribus/scribus/serializer.cpp
==============================================================================
--- branches/Version135/Scribus/scribus/serializer.cpp (original)
+++ branches/Version135/Scribus/scribus/serializer.cpp Fri Dec 10 21:29:11 2010
@@ -185,8 +185,14 @@
 	UniqueID handler( & outputhandler );
 	handler.beginDoc();
 	handler.begin("SCRIBUSFRAGMENT", attr);
+
+	if (selection.count() == 0)
+	{
+		handler.end("SCRIBUSFRAGMENT");
+		handler.endDoc();
+		return;
+	}
 	ScribusDoc* doc = selection.itemAt(0)->doc();
-	
 	
 	QMap<QString,int>::Iterator itf;
 	for (itf = doc->UsedFonts.begin(); itf != doc->UsedFonts.end(); ++itf)




More information about the scribus-commit mailing list