r24106 by jghali - Fix potential crash caused by deletion of item specified in undo action

scribus-commit scribus-commit at lists.scribus.net
Sun Oct 25 19:50:11 UTC 2020


Author: jghali
Date: Sun Oct 25 19:50:11 2020
New Revision: 24106

URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=24106
Log:
Fix potential crash caused by deletion of item specified in undo action

Modified:
    trunk/Scribus/scribus/scribusdoc.cpp

Modified: trunk/Scribus/scribus/scribusdoc.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=24106&path=/trunk/Scribus/scribus/scribusdoc.cpp
==============================================================================
--- trunk/Scribus/scribus/scribusdoc.cpp	(original)
+++ trunk/Scribus/scribus/scribusdoc.cpp	Sun Oct 25 19:50:11 2020
@@ -14969,20 +14969,25 @@
 	Selection* itemSelection = (customSelection != nullptr) ? customSelection : m_Selection;
 	if (itemSelection->isEmpty())
 		return;
-
+	
+	bool wasLoad = isLoading();
 	int docSelectionCount = itemSelection->count();
 	PageItem *currItem;
+
 	UndoTransaction activeTransaction;
 	if (UndoManager::undoEnabled())
 		activeTransaction = m_undoManager->beginTransaction(Um::Selection, Um::IGroup, Um::Ungroup, "", Um::IGroup);
+
 	QList<PageItem*> toDelete;
+	QRectF textInteractionRect;
 	for (int i = 0; i < docSelectionCount; ++i)
 	{
 		currItem = itemSelection->itemAt(i);
-		if (currItem->isGroup())
-			toDelete.append(currItem);
-	}
-	bool wasLoad = isLoading();
+		if (!currItem->isGroup())
+			continue;
+		toDelete.append(currItem);
+	}
+
 	// Remove group control objects
 	setLoading(true);
 	itemSelection->delaySignalsOn();
@@ -15033,7 +15038,8 @@
 		currItem = toDelete.at(i);
 		if (currItem->isWelded())
 			currItem->unWeld();
-		delete currItem;
+		if (!UndoManager::undoEnabled())
+			delete currItem;
 	}
 
 	if (activeTransaction)




More information about the scribus-commit mailing list