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

scribus-commit scribus-commit at lists.scribus.net
Fri Dec 10 22:31:45 CET 2010


Author: jghali
Date: Fri Dec 10 21:31:45 2010
New Revision: 16084

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

Modified:
    trunk/Scribus/scribus/scribusdoc.cpp
    trunk/Scribus/scribus/serializer.cpp

Modified: trunk/Scribus/scribus/scribusdoc.cpp
URL: http://scribus.info/websvn/diff.php?repname=Scribus&rev=16084&path=/trunk/Scribus/scribus/scribusdoc.cpp
==============================================================================
--- trunk/Scribus/scribus/scribusdoc.cpp (original)
+++ trunk/Scribus/scribus/scribusdoc.cpp Fri Dec 10 21:31:45 2010
@@ -1955,10 +1955,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: trunk/Scribus/scribus/serializer.cpp
URL: http://scribus.info/websvn/diff.php?repname=Scribus&rev=16084&path=/trunk/Scribus/scribus/serializer.cpp
==============================================================================
--- trunk/Scribus/scribus/serializer.cpp (original)
+++ trunk/Scribus/scribus/serializer.cpp Fri Dec 10 21:31:45 2010
@@ -183,8 +183,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