r19760 by jghali - #12897: Fix wrongly re-enabled edit menu entries

scribus-commit scribus-commit at lists.scribus.net
Wed Jan 21 00:29:03 UTC 2015


Author: jghali
Date: Wed Jan 21 00:29:03 2015
New Revision: 19760

URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=19760
Log:
#12897: Fix wrongly re-enabled edit menu entries

Modified:
    trunk/Scribus/scribus/appmodehelper.cpp
    trunk/Scribus/scribus/scribusdoc.cpp
    trunk/Scribus/scribus/scribusdoc.h

Modified: trunk/Scribus/scribus/appmodehelper.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=19760&path=/trunk/Scribus/scribus/appmodehelper.cpp
==============================================================================
--- trunk/Scribus/scribus/appmodehelper.cpp (original)
+++ trunk/Scribus/scribus/appmodehelper.cpp Wed Jan 21 00:29:03 2015
@@ -126,6 +126,9 @@
 
 	switch (oldMode)
 	{
+		case modeDrawBezierLine:
+			setSpecialEditMode(false);
+			break;
 		case modeEdit:
 			{
 				if (newMode != modeEdit)
@@ -147,15 +150,15 @@
 				doc->view()->horizRuler->update();
 			}
 			break;
+		case modeEditArc:
+			setSpecialEditMode(false);
+			break;
 		case modeEditClip:
 			{
 				if (newMode != modeEditClip)
 					scmw->NoFrameEdit();
 			}
 			break;
-		case modeDrawBezierLine:
-			setSpecialEditMode(false);
-			break;
 		case modeEditGradientVectors:
 			setSpecialEditMode(false);
 			break;
@@ -163,6 +166,12 @@
 			setSpecialEditMode(false);
 			break;
 		case modeEditMeshPatch:
+			setSpecialEditMode(false);
+			break;
+		case modeEditPolygon:
+			setSpecialEditMode(false);
+			break;
+		case modeEditSpiral:
 			setSpecialEditMode(false);
 			break;
 		case modeEditTable:
@@ -175,13 +184,7 @@
 				a_actMgr->restoreActionShortcutsPostEditMode();
 			}
 			break;
-		case modeEditArc:
-			setSpecialEditMode(false);
-			break;
-		case modeEditSpiral:
-			setSpecialEditMode(false);
-			break;
-		case modeEditPolygon:
+		case modeEditWeldPoint:
 			setSpecialEditMode(false);
 			break;
 		case modeLinkFrames:
@@ -199,6 +202,38 @@
 				scmw->propertiesPalette->setGradientEditMode(false);
 				scmw->outlinePalette->setEnabled(true);
 			}
+			break;
+		case modeCopyProperties:
+			{
+				if (!doc->m_Selection->isEmpty())
+				{
+					doc->ElemToLink = doc->m_Selection->itemAt(0);
+					doc->view()->Deselect(true);
+					(*a_scrActions)["toolsCopyProperties"]->setEnabled(true);
+				}
+			}
+			break;
+		case modeDrawArc:
+			break;
+		case modeDrawBezierLine:
+			{
+				setSpecialEditMode(true);
+				if ((doc->m_Selection->count() != 0) && (!PrefsManager::instance()->appPrefs.uiPrefs.stickyTools))
+					doc->view()->Deselect(true);
+				doc->view()->FirstPoly = true;
+			}
+			break;
+		case modeDrawCalligraphicLine:
+			break;
+		case modeDrawFreehandLine:
+			break;
+		case modeDrawImage:
+			break;
+		case modeDrawLatex:
+			break;
+		case modeDrawLine:
+			break;
+		case modeDrawRegularPolygon:
 			break;
 		case modeDrawShapes:
 			{
@@ -208,17 +243,13 @@
 				scmw->emitUpdateRequest(reqCustomShapeUpdate);
 			}
 			break;
-		case modeStoryEditor:
-			{
-				scmw->slotStoryEditor(oldMode == modeEditTable);
-				scmw->slotSelect();
-			}
-			break;
-		case modeDrawImage:
+		case modeDrawSpiral:
+			break;
+		case modeDrawTable:
+			break;
+		case modeDrawTable2:
 			break;
 		case modeDrawText:
-			break;
-		case modeMagnifier:
 			break;
 		case modeEdit:
 			{
@@ -253,102 +284,29 @@
 				}
 			}
 			break;
+		case modeEditArc:
+			setSpecialEditMode(true);
+			break;
 		case modeEditClip:
 			{
 				if (oldMode != modeEditClip)
 					scmw->ToggleFrameEdit();
 			}
 			break;
-		case modeDrawLine:
-			break;
-		case modeRotation:
-			break;
-		case modeLinkFrames:
-			{
-				doc->regionsChanged()->update(QRect());
-				doc->ElemToLink = doc->m_Selection->itemAt(0);
-			}
-			break;
-		case modeImportImage:
-			break;
-		case modeUnlinkFrames:
-			doc->regionsChanged()->update(QRect());
-			break;
-		case modeDrawRegularPolygon:
-			break;
-		case modeDrawBezierLine:
-			{
-				setSpecialEditMode(true);
-				if ((doc->m_Selection->count() != 0) && (!PrefsManager::instance()->appPrefs.uiPrefs.stickyTools))
-					doc->view()->Deselect(true);
-				doc->view()->FirstPoly = true;
-			}
-			break;
-		case modeInsertPDFButton:
-			break;
-		case modeInsertPDFTextfield:
-			break;
-		case modeInsertPDFCheckbox:
-			break;
-		case modeInsertPDFCombobox:
-			break;
-		case modeInsertPDFListbox:
-			break;
-		case modeInsertPDFTextAnnotation:
-			break;
-		case modeInsertPDFLinkAnnotation:
-			break;
-		case modeDrawFreehandLine:
-			break;
-		case modeDrawTable:
-			break;
-		case modeDrawTable2:
-			break;
-		case modePanning:
-			break;
-		case modeMeasurementTool:
-			break;
-		case modeEyeDropper:
-			break;
-		case modeCopyProperties:
-			{
-				if (!doc->m_Selection->isEmpty())
-				{
-					doc->ElemToLink = doc->m_Selection->itemAt(0);
-					doc->view()->Deselect(true);
-					(*a_scrActions)["toolsCopyProperties"]->setEnabled(true);
-				}
-			}
-			break;
-		case modeDrawLatex:
-			break;
-		case modeImportObject:
-			break;
-		case modeInsertPDF3DAnnotation:
-			break;
 		case modeEditGradientVectors:
 			{
 				setSpecialEditMode(true);
 				scmw->propertiesPalette->setGradientEditMode(true);
 			}
-		break;
+			break;
 		case modeEditMeshGradient:
 			setSpecialEditMode(true);
 			break;
 		case modeEditMeshPatch:
 			setSpecialEditMode(true);
 			break;
-		case modeDrawCalligraphicLine:
-			break;
-		case modeDrawArc:
-			break;
-		case modeEditArc:
-			setSpecialEditMode(true);
-			break;
 		case modeEditPolygon:
 			setSpecialEditMode(true);
-			break;
-		case modeDrawSpiral:
 			break;
 		case modeEditSpiral:
 			setSpecialEditMode(true);
@@ -373,8 +331,54 @@
 			}
 			break;
 		case modeEditWeldPoint:
+			setSpecialEditMode(true);
+			break;
+		case modeEyeDropper:
+			break;
+		case modeImportImage:
+			break;
+		case modeImportObject:
+			break;
+		case modeInsertPDF3DAnnotation:
+			break;
+		case modeInsertPDFButton:
+			break;
+		case modeInsertPDFCheckbox:
+			break;
+		case modeInsertPDFCombobox:
+			break;
+		case modeInsertPDFLinkAnnotation:
+			break;
+		case modeInsertPDFListbox:
 			break;
 		case modeInsertPDFRadioButton:
+			break;
+		case modeInsertPDFTextAnnotation:
+			break;
+		case modeInsertPDFTextfield:
+			break;
+		case modeLinkFrames:
+			{
+				doc->regionsChanged()->update(QRect());
+				doc->ElemToLink = doc->m_Selection->itemAt(0);
+			}
+			break;
+		case modeMagnifier:
+			break;
+		case modeMeasurementTool:
+			break;
+		case modePanning:
+			break;
+		case modeRotation:
+			break;
+		case modeStoryEditor:
+			{
+				scmw->slotStoryEditor(oldMode == modeEditTable);
+				scmw->slotSelect();
+			}
+			break;
+		case modeUnlinkFrames:
+			doc->regionsChanged()->update(QRect());
 			break;
 		default:
 			//No doc open?
@@ -405,10 +409,13 @@
 	}
 	assert (docSelectionCount == 0 || currItem != NULL); // help coverity analysis
 
-	bool inAnEditMode=doc->inAnEditMode();
-
-	(*a_scrActions)["editSelectAllOnLayer"]->setEnabled(true);
-	(*a_scrActions)["editDeselectAll"]->setEnabled(SelectedType != -1);
+	bool inAnEditMode = doc->inAnEditMode();
+
+	if (!doc->inASpecialEditMode()) // #12897: Using Undo/Redo those actions are re-enabled causing crash
+	{
+		(*a_scrActions)["editSelectAllOnLayer"]->setEnabled(true);
+		(*a_scrActions)["editDeselectAll"]->setEnabled(SelectedType != -1);
+	}
 	(*a_scrActions)["itemDetachTextFromPath"]->setEnabled(false);
 	(*a_scrActions)["itemUpdateImage"]->setEnabled(SelectedType==PageItem::ImageFrame && (currItem->PictureIsAvailable || currItem->asLatexFrame()));
 	(*a_scrActions)["itemAdjustFrameToImage"]->setEnabled(SelectedType==PageItem::ImageFrame && currItem->PictureIsAvailable);

Modified: trunk/Scribus/scribus/scribusdoc.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=19760&path=/trunk/Scribus/scribus/scribusdoc.cpp
==============================================================================
--- trunk/Scribus/scribus/scribusdoc.cpp (original)
+++ trunk/Scribus/scribus/scribusdoc.cpp Wed Jan 21 00:29:03 2015
@@ -757,20 +757,35 @@
 
 bool ScribusDoc::inAnEditMode() const
 {
-	bool inEditMode = (appMode == modeEdit ||
+	bool inEditMode = (appMode == modeDrawBezierLine ||
+					   appMode == modeEdit ||
+					   appMode == modeEditArc ||
+					   appMode == modeEditClip ||
+					   appMode == modeEditGradientVectors ||
+					   appMode == modeEditMeshGradient ||
+					   appMode == modeEditMeshPatch ||
+					   appMode == modeEditPolygon ||
+					   appMode == modeEditSpiral ||
 					   appMode == modeEditTable ||
-					   appMode == modeEditSpiral ||
-					   appMode == modeEditGradientVectors ||
-					   appMode == modeEditClip ||
-					   appMode == modeEditMeshGradient ||
-					   appMode == modeEditArc ||
-					   appMode == modeEditMeshPatch ||
-					   appMode == modeEditWeldPoint ||
-					   appMode == modeEditPolygon ||
-					   appMode == modeDrawBezierLine
+					   appMode == modeEditWeldPoint
 					   ) ? true : false;
 
 	return inEditMode;
+}
+
+bool ScribusDoc::inASpecialEditMode() const
+{ // #12897, modes that use setSpecialEditMode() function in appmodehelper.cpp
+	bool inSpecialEditMode = (appMode == modeDrawBezierLine ||
+							  appMode == modeEditArc ||
+							  appMode == modeEditGradientVectors ||
+							  appMode == modeEditMeshGradient ||
+							  appMode == modeEditMeshPatch ||
+							  appMode == modeEditPolygon ||
+							  appMode == modeEditSpiral ||
+							  appMode == modeEditWeldPoint
+							  ) ? true : false;
+
+	return inSpecialEditMode;
 }
 
 QList<PageItem*> ScribusDoc::getAllItems(QList<PageItem*> &items)

Modified: trunk/Scribus/scribus/scribusdoc.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=19760&path=/trunk/Scribus/scribus/scribusdoc.h
==============================================================================
--- trunk/Scribus/scribus/scribusdoc.h (original)
+++ trunk/Scribus/scribus/scribusdoc.h Wed Jan 21 00:29:03 2015
@@ -129,6 +129,7 @@
 	~ScribusDoc();
 	void init();
 	bool inAnEditMode() const;
+	bool inASpecialEditMode() const;
 	QList<PageItem*> getAllItems(QList<PageItem*> &items);
 	QList<PageItem*> *parentGroup(PageItem* item, QList<PageItem*> *list);
 	void setup(const int, const int, const int, const int, const int, const QString&, const QString&);




More information about the scribus-commit mailing list