r19755 by jghali - #12890: Distribute tools corrupt undo stack

scribus-commit scribus-commit at lists.scribus.net
Thu Jan 15 19:39:01 UTC 2015


Author: jghali
Date: Thu Jan 15 19:39:01 2015
New Revision: 19755

URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=19755
Log:
#12890: Distribute tools corrupt undo stack

Modified:
    branches/Version14x/Scribus/scribus/scribusdoc.cpp
    branches/Version14x/Scribus/scribus/scribusdoc.h

Modified: branches/Version14x/Scribus/scribus/scribusdoc.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=19755&path=/branches/Version14x/Scribus/scribus/scribusdoc.cpp
==============================================================================
--- branches/Version14x/Scribus/scribus/scribusdoc.cpp (original)
+++ branches/Version14x/Scribus/scribus/scribusdoc.cpp Thu Jan 15 19:39:01 2015
@@ -8286,18 +8286,18 @@
 }
 
 
-bool ScribusDoc::startAlign()
+bool ScribusDoc::startAlign(uint minObjects)
 {
 	buildAlignItemList();
-	uint alignObjectsCount=AObjects.count();
-	if (alignObjectsCount==0)
+	uint alignObjectsCount = AObjects.count();
+	if (alignObjectsCount < minObjects)
 		return false;
 		
 	bool oneLocked=false;
 	for (uint i = 0; i < alignObjectsCount && !oneLocked; ++i)
 		for (int j = 0; j < AObjects[i].Objects.count() && !oneLocked; ++j)
 			if (AObjects[i].Objects.at(j)->locked())
-				oneLocked=true;
+				oneLocked = true;
 	int t = 2;
 	if (oneLocked)
 	{
@@ -8342,7 +8342,6 @@
 	return true;
 }
 
-
 void ScribusDoc::endAlign()
 {
 	changed();
@@ -8422,8 +8421,8 @@
 {
 	if (!startAlign())
 		return;
-	uint alignObjectsCount=AObjects.count();
-	int loopStart=0, loopEnd=alignObjectsCount-1;
+	uint alignObjectsCount = AObjects.count();
+	int loopStart = 0, loopEnd = alignObjectsCount - 1;
 	double newX = 99999.9;
 	switch ( currAlignTo )
 	{
@@ -8460,8 +8459,8 @@
 {
 	if (!startAlign())
 		return;
-	uint alignObjectsCount=AObjects.count();
-	int loopStart=0, loopEnd=alignObjectsCount-1;
+	uint alignObjectsCount = AObjects.count();
+	int loopStart = 0, loopEnd = alignObjectsCount - 1;
 	double newX = std::numeric_limits<double>::max();
 	switch ( currAlignTo ) 
 	{
@@ -8498,8 +8497,8 @@
 {
 	if (!startAlign())
 		return;
-	uint alignObjectsCount=AObjects.count();
-	int loopStart=0, loopEnd=alignObjectsCount-1;
+	uint alignObjectsCount = AObjects.count();
+	int loopStart = 0, loopEnd = alignObjectsCount - 1;
 	double newX = 0.0;
 	switch ( currAlignTo ) 
 	{
@@ -8552,8 +8551,8 @@
 {
 	if (!startAlign())
 		return;
-	uint alignObjectsCount=AObjects.count();
-	int loopStart=0, loopEnd=alignObjectsCount-1;
+	uint alignObjectsCount = AObjects.count();
+	int loopStart = 0, loopEnd = alignObjectsCount - 1;
 	double newX = -std::numeric_limits<double>::max();
 	switch ( currAlignTo ) 
 	{
@@ -8592,8 +8591,8 @@
 {
 	if (!startAlign())
 		return;
-	uint alignObjectsCount=AObjects.count();
-	int loopStart=0, loopEnd=alignObjectsCount-1;
+	uint alignObjectsCount = AObjects.count();
+	int loopStart = 0, loopEnd = alignObjectsCount - 1;
 	double newX = -std::numeric_limits<double>::max();
 	switch ( currAlignTo ) 
 	{
@@ -8632,8 +8631,8 @@
 {
 	if (!startAlign())
 		return;
-	uint alignObjectsCount=AObjects.count();
-	int loopStart=0, loopEnd=alignObjectsCount-1;
+	uint alignObjectsCount = AObjects.count();
+	int loopStart = 0, loopEnd = alignObjectsCount - 1;
 	double newY = std::numeric_limits<double>::max();
 	switch ( currAlignTo ) 
 	{
@@ -8670,8 +8669,8 @@
 {
 	if (!startAlign())
 		return;
-	uint alignObjectsCount=AObjects.count();
-	int loopStart=0, loopEnd=alignObjectsCount-1;
+	uint alignObjectsCount = AObjects.count();
+	int loopStart = 0, loopEnd = alignObjectsCount - 1;
 	double newY = std::numeric_limits<double>::max();
 	switch ( currAlignTo ) 
 	{
@@ -8708,8 +8707,8 @@
 {
 	if (!startAlign())
 		return;
-	uint alignObjectsCount=AObjects.count();
-	int loopStart=0, loopEnd=alignObjectsCount-1;
+	uint alignObjectsCount = AObjects.count();
+	int loopStart = 0, loopEnd = alignObjectsCount - 1;
 	double newY = 0.0;
 	switch ( currAlignTo ) 
 	{
@@ -8762,8 +8761,8 @@
 {
 	if (!startAlign())
 		return;
-	uint alignObjectsCount=AObjects.count();
-	int loopStart=0, loopEnd=alignObjectsCount-1;
+	uint alignObjectsCount = AObjects.count();
+	int loopStart = 0, loopEnd = alignObjectsCount - 1;
 	double newY = -std::numeric_limits<double>::max();
 	switch ( currAlignTo ) 
 	{
@@ -8802,8 +8801,8 @@
 {
 	if (!startAlign())
 		return;
-	uint alignObjectsCount=AObjects.count();
-	int loopStart=0, loopEnd=alignObjectsCount-1;
+	uint alignObjectsCount = AObjects.count();
+	int loopStart = 0, loopEnd = alignObjectsCount - 1;
 	double newY = -std::numeric_limits<double>::max();
 	switch ( currAlignTo )
 	{
@@ -8840,11 +8839,9 @@
 
 void ScribusDoc::itemSelection_DistributeLeft()
 {
-	if (!startAlign())
+	if (!startAlign(2))
 		return;
-	uint alignObjectsCount=AObjects.count();
-	if (alignObjectsCount<=1)
-		return;
+	uint alignObjectsCount = AObjects.count();
 	QMap<double,uint> Xsorted;
 	for (uint a = 0; a < alignObjectsCount; ++a)
 	{
@@ -8880,11 +8877,9 @@
 
 void ScribusDoc::itemSelection_DistributeCenterH()
 {
-	if (!startAlign())
+	if (!startAlign(2))
 		return;
-	uint alignObjectsCount=AObjects.count();
-	if (alignObjectsCount<=1)
-		return;
+	uint alignObjectsCount = AObjects.count();
 	QMap<double,uint> Xsorted;
 	for (uint a = 0; a < alignObjectsCount; ++a)
 	{
@@ -8920,11 +8915,9 @@
 
 void ScribusDoc::itemSelection_DistributeRight()
 {
-	if (!startAlign())
+	if (!startAlign(2))
 		return;
-	uint alignObjectsCount=AObjects.count();
-	if (alignObjectsCount<=1)
-		return;
+	uint alignObjectsCount = AObjects.count();
 	QMap<double,uint> Xsorted;
 	for (uint a = 0; a < alignObjectsCount; ++a)
 	{
@@ -8960,11 +8953,9 @@
 
 void ScribusDoc::itemSelection_DistributeDistH(bool usingDistance, double distance, bool reverseDistribute)
 {
-	if (!startAlign())
+	if (!startAlign(2))
 		return;
-	uint alignObjectsCount=AObjects.count();
-	if (alignObjectsCount<=1)
-		return;
+	uint alignObjectsCount = AObjects.count();
 	QMap<double,uint> X1sorted, X2sorted;
 	for (uint a = 0; a < alignObjectsCount; ++a)
 	{
@@ -9045,11 +9036,9 @@
 
 void ScribusDoc::itemSelection_DistributeBottom()
 {
-	if (!startAlign())
+	if (!startAlign(2))
 		return;
-	uint alignObjectsCount=AObjects.count();
-	if (alignObjectsCount<=1)
-		return;
+	uint alignObjectsCount = AObjects.count();
 	QMap<double,uint> Ysorted;
 	for (uint a = 0; a < alignObjectsCount; ++a)
 	{
@@ -9085,11 +9074,9 @@
 
 void ScribusDoc::itemSelection_DistributeCenterV()
 {
-	if (!startAlign())
+	if (!startAlign(2))
 		return;
-	uint alignObjectsCount=AObjects.count();
-	if (alignObjectsCount<=1)
-		return;
+	uint alignObjectsCount = AObjects.count();
 	QMap<double,uint> Ysorted;
 	for (uint a = 0; a < alignObjectsCount; ++a)
 	{
@@ -9125,11 +9112,9 @@
 
 void ScribusDoc::itemSelection_DistributeTop()
 {
-	if (!startAlign())
+	if (!startAlign(2))
 		return;
-	uint alignObjectsCount=AObjects.count();
-	if (alignObjectsCount<=1)
-		return;
+	uint alignObjectsCount = AObjects.count();
 	QMap<double,uint> Ysorted;
 	for (uint a = 0; a < alignObjectsCount; ++a)
 	{
@@ -9165,11 +9150,9 @@
 
 void ScribusDoc::itemSelection_DistributeDistV(bool usingDistance, double distance, bool reverseDistribute)
 {
-	if (!startAlign())
+	if (!startAlign(2))
 		return;
-	uint alignObjectsCount=AObjects.count();
-	if (alignObjectsCount<=1)
-		return;
+	uint alignObjectsCount = AObjects.count();
 	QMap<double,uint> Y1sorted, Y2sorted;
 	for (uint a = 0; a < alignObjectsCount; ++a)
 	{
@@ -9251,11 +9234,9 @@
 
 void ScribusDoc::itemSelection_DistributeAcrossPage(bool useMargins)
 {
-	if (!startAlign())
+	if (!startAlign(2))
 		return;
-	uint alignObjectsCount=AObjects.count();
-	if (alignObjectsCount<=1)
-		return;
+	uint alignObjectsCount = AObjects.count();
 	QMap<double,uint> X1sorted, X2sorted;
 	for (uint a = 0; a < alignObjectsCount; ++a)
 	{
@@ -9303,11 +9284,9 @@
 
 void ScribusDoc::itemSelection_DistributeDownPage(bool useMargins)
 {
-	if (!startAlign())
+	if (!startAlign(2))
 		return;
-	uint alignObjectsCount=AObjects.count();
-	if (alignObjectsCount<=1)
-		return;
+	uint alignObjectsCount = AObjects.count();
 	QMap<double,uint> Y1sorted, Y2sorted;
 	for (uint a = 0; a < alignObjectsCount; ++a)
 	{

Modified: branches/Version14x/Scribus/scribus/scribusdoc.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=19755&path=/branches/Version14x/Scribus/scribus/scribusdoc.h
==============================================================================
--- branches/Version14x/Scribus/scribus/scribusdoc.h (original)
+++ branches/Version14x/Scribus/scribus/scribusdoc.h Thu Jan 15 19:39:01 2015
@@ -791,7 +791,7 @@
 	typedef enum {alignFirst, alignLast, alignPage, alignMargins, alignGuide, alignSelection } AlignTo;
 	typedef enum {alignByMoving, alignByResizing } AlignMethod;
 	void buildAlignItemList(Selection* customSelection=0);
-	bool startAlign();
+	bool startAlign(uint minObjects = 1);
 	void endAlign();
 	/**
 	 * \brief Insert a color into the documents color list




More information about the scribus-commit mailing list