r21195 by fschmid -

scribus-commit scribus-commit at lists.scribus.net
Sat Apr 16 09:20:11 UTC 2016


Author: fschmid
Date: Sat Apr 16 09:20:10 2016
New Revision: 21195

URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=21195
Log:
Fixed Bug #12685: Scribus crashes with "unexpected end of file" opening a specific document

Modified:
    trunk/Scribus/scribus/canvas.cpp
    trunk/Scribus/scribus/pageitem_textframe.cpp
    trunk/Scribus/scribus/scribus.cpp
    trunk/Scribus/scribus/util.cpp

Modified: trunk/Scribus/scribus/canvas.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=21195&path=/trunk/Scribus/scribus/canvas.cpp
==============================================================================
--- trunk/Scribus/scribus/canvas.cpp	(original)
+++ trunk/Scribus/scribus/canvas.cpp	Sat Apr 16 09:20:10 2016
@@ -1469,9 +1469,9 @@
 	//then we must be sure that text frames are valid and all notes frames are created before we start drawing
 	if (!notesFramesPass && !m_doc->notesList().isEmpty())
 	{
-		for (int it = 0; it < m_doc->Items->count(); ++it)
-		{
-			currItem = m_doc->Items->at(it);
+		for (QList<PageItem*>::iterator it = m_doc->Items->begin(); it != m_doc->Items->end(); ++it)
+		{
+			PageItem* currItem = *it;
 			if ( !currItem->isTextFrame()
 				|| currItem->isNoteFrame()
 				|| !currItem->invalid

Modified: trunk/Scribus/scribus/pageitem_textframe.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=21195&path=/trunk/Scribus/scribus/pageitem_textframe.cpp
==============================================================================
--- trunk/Scribus/scribus/pageitem_textframe.cpp	(original)
+++ trunk/Scribus/scribus/pageitem_textframe.cpp	Sat Apr 16 09:20:10 2016
@@ -1338,6 +1338,9 @@
 			next->invalid = false;
 			next = next->nextInChain();
 		}
+		// TODO layout() shouldn't delete any frame here, as it breaks any loop
+		// over the doc->Items or doc->MasterItems lists when done with indexes
+		// see Bug #12685 for an example
 		if (!isNoteFrame() && m_Doc->notesChanged() && !m_notesFramesMap.isEmpty())
 		{ //if notes are used
 			UndoManager::instance()->setUndoEnabled(false);

Modified: trunk/Scribus/scribus/scribus.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=21195&path=/trunk/Scribus/scribus/scribus.cpp
==============================================================================
--- trunk/Scribus/scribus/scribus.cpp	(original)
+++ trunk/Scribus/scribus/scribus.cpp	Sat Apr 16 09:20:10 2016
@@ -3739,9 +3739,9 @@
 		doc->reformPages();
 		doc->refreshGuides();
 		doc->setLoading(false);
-		for (int i=0; i<doc->MasterItems.count(); ++i)
-		{
-			PageItem *ite = doc->MasterItems.at(i);
+		for (QList<PageItem*>::iterator itm = doc->MasterItems.begin(); itm != doc->MasterItems.end(); ++itm)
+		{
+			PageItem* ite = *itm;
 			// TODO fix that for Groups on Masterpages
 //			if (ite->Groups.count() != 0)
 //				view->GroupOnPage(ite);
@@ -3751,11 +3751,10 @@
 		doc->setMasterPageMode(false);
 		/*QTime t;
 		t.start();*/
-		int docItemsCount=doc->Items->count();
 		doc->flag_Renumber = false;
-		for (int i=0; i<docItemsCount; ++i)
-		{
-			PageItem *ite = doc->Items->at(i);
+		for (QList<PageItem*>::iterator iti = doc->Items->begin(); iti != doc->Items->end(); ++iti)
+		{
+			PageItem* ite = *iti;
 			if((ite->nextInChain() == NULL) && !ite->isNoteFrame())  //do not layout notes frames
 				ite->layout();
 		}

Modified: trunk/Scribus/scribus/util.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=21195&path=/trunk/Scribus/scribus/util.cpp
==============================================================================
--- trunk/Scribus/scribus/util.cpp	(original)
+++ trunk/Scribus/scribus/util.cpp	Sat Apr 16 09:20:10 2016
@@ -441,15 +441,15 @@
 	QImage pgPix(10, 10, QImage::Format_ARGB32_Premultiplied);
 	QRect rd; // = QRect(0,0,9,9);
 	ScPainter *painter = new ScPainter(&pgPix, pgPix.width(), pgPix.height());
-	for (int azz=0; azz<currentDoc->MasterItems.count(); ++azz)
-	{
-		PageItem *currItem = currentDoc->MasterItems.at(azz);
+	for (QList<PageItem*>::iterator it = currentDoc->MasterItems.begin(); it != currentDoc->MasterItems.end(); ++it)
+	{
+		PageItem* currItem = *it;
 		if (currItem->itemType() == PageItem::PathText)
 			currItem->DrawObj(painter, rd);
 	}
-	for (int azz=0; azz<currentDoc->Items->count(); ++azz)
-	{
-		PageItem *currItem = currentDoc->Items->at(azz);
+	for (QList<PageItem*>::iterator it = currentDoc->Items->begin(); it != currentDoc->Items->end(); ++it)
+	{
+		PageItem* currItem = *it;
 		currItem->layout();
 		if (currItem->itemType() == PageItem::PathText)
 			currItem->DrawObj(painter, rd); //FIXME: this should be replaced by code in layout()




More information about the scribus-commit mailing list