r22791 by jghali - #15512: Moving control points when editing shape crashes Scribus

scribus-commit scribus-commit at lists.scribus.net
Sun Dec 16 19:38:25 UTC 2018


Author: jghali
Date: Sun Dec 16 19:38:24 2018
New Revision: 22791

URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=22791
Log:
#15512: Moving control points when editing shape crashes Scribus

Modified:
    trunk/Scribus/scribus/canvasmode_nodeedit.cpp
    trunk/Scribus/scribus/nodeeditcontext.cpp

Modified: trunk/Scribus/scribus/canvasmode_nodeedit.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=22791&path=/trunk/Scribus/scribus/canvasmode_nodeedit.cpp
==============================================================================
--- trunk/Scribus/scribus/canvasmode_nodeedit.cpp	(original)
+++ trunk/Scribus/scribus/canvasmode_nodeedit.cpp	Sun Dec 16 19:38:24 2018
@@ -465,9 +465,7 @@
 			currItem->ContourLine.translate(xposOrig - currItem->xPos(), yposOrig - currItem->yPos());
 		m_doc->regionsChanged()->update(QRectF());
 		if (state)
-		{
 			m_doc->nodeEdit.finishTransaction2(currItem, state);
-		}
 		return;
 	}
 

Modified: trunk/Scribus/scribus/nodeeditcontext.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=22791&path=/trunk/Scribus/scribus/nodeeditcontext.cpp
==============================================================================
--- trunk/Scribus/scribus/nodeeditcontext.cpp	(original)
+++ trunk/Scribus/scribus/nodeeditcontext.cpp	Sun Dec 16 19:38:24 2018
@@ -73,7 +73,14 @@
 		//					m_isContourLine = false;
 		uAction = Um::EditShape;
 	}
+
+	if (nodeTransaction)
+		return (oldClip ? FPointArray(*oldClip) : Clip);
+
+	if (oldClip)
+		delete oldClip;
 	oldClip = new FPointArray(Clip);
+
 	m_oldItemX = currItem->xPos();
 	m_oldItemY = currItem->yPos();
 	if (UndoManager::undoEnabled())
@@ -88,15 +95,15 @@
 {
 	ScribusDoc* Doc = currItem->doc();
 	UndoManager* undoManager = UndoManager::instance();
+	ScItemState<QPair<FPointArray, FPointArray> >* state = nullptr;
 	
 	if (nodeTransaction) // is there the old clip stored for the undo action
 	{
 		FPointArray newClip(Doc->nodeEdit.m_isContourLine ? currItem->ContourLine : currItem->PoLine);
-		if (*oldClip != newClip && UndoManager::undoEnabled())
+		if (UndoManager::undoEnabled() && oldClip && (*oldClip != newClip))
 		{
 			QString name = Doc->nodeEdit.m_isContourLine ? Um::EditContour : Um::EditShape;
-			ScItemState<QPair<FPointArray, FPointArray> > *state =
-				new ScItemState<QPair<FPointArray, FPointArray> >(name);
+			state = new ScItemState<QPair<FPointArray, FPointArray> >(name);
 			state->set("EDIT_SHAPE_OR_CONTOUR");
 			state->set("IS_CONTOUR", Doc->nodeEdit.m_isContourLine);
 			state->setItem(qMakePair(*oldClip, newClip));
@@ -129,7 +136,7 @@
 	if (nodeTransaction) // is there the old clip stored for the undo action
 	{
 		FPointArray newClip(Doc->nodeEdit.m_isContourLine ? currItem->ContourLine : currItem->PoLine);
-		if (*oldClip != newClip && UndoManager::undoEnabled())
+		if (UndoManager::undoEnabled() && oldClip && (*oldClip != newClip))
 		{
 			QString name = Doc->nodeEdit.m_isContourLine ? Um::EditContour : Um::EditShape;
 			state = new ScItemState<QPair<FPointArray, FPointArray> >(name);
@@ -143,6 +150,7 @@
 			delete oldClip;
 			oldClip = nullptr;
 			nodeTransaction.cancel();
+			nodeTransaction.reset();
 		}
 	}
 	return state;




More information about the scribus-commit mailing list