r16814 by jghali - #10234: new table is not added to undo history...which leads to crash

scribus-commit scribus-commit at lists.scribus.net
Fri Sep 2 22:17:56 UTC 2011


Author: jghali
Date: Fri Sep  2 22:17:55 2011
New Revision: 16814

URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=16814
Log:
#10234: new table is not added to undo history...which leads to crash

Modified:
    trunk/Scribus/scribus/canvasmode_create.cpp
    trunk/Scribus/scribus/scribusdoc.cpp
    trunk/Scribus/scribus/ui/propertiespalette_shape.cpp

Modified: trunk/Scribus/scribus/canvasmode_create.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=16814&path=/trunk/Scribus/scribus/canvasmode_create.cpp
==============================================================================
--- trunk/Scribus/scribus/canvasmode_create.cpp (original)
+++ trunk/Scribus/scribus/canvasmode_create.cpp Fri Sep  2 22:17:55 2011
@@ -392,7 +392,16 @@
 
 	m_createTransaction = new UndoTransaction(Um::instance()->beginTransaction("creating"));
 	currItem = doCreateNewObject();
-	if (m_createTransaction && currItem)
+	if (m_createTransaction && currItem && currItem->isGroup())
+	{
+		// We created a table, just commit transaction
+		m_view->resetMousePressed();
+		m_createTransaction->commit();
+		m_doc->changed();
+		delete m_createTransaction;
+		m_createTransaction = NULL;	
+	}
+	else if (m_createTransaction && currItem)
 	{
 		m_view->resetMousePressed();
 		currItem->checkChanges(true);
@@ -758,7 +767,6 @@
 			canvasCurrCoord.setXY(qRound(Tw), qRound(Th));
 			Tw = Tw - Tx;
 			Th = Th - Ty;
-			int z;
 			int Cols, Rows;
 			double deltaX, deltaY, offX, offY;
 			if ((Th < 6) || (Tw < 6))
@@ -785,10 +793,10 @@
 			offY = 0.0;
 			m_doc->m_Selection->clear();
 			if (UndoManager::undoEnabled())
-				activeTransaction = new UndoTransaction(m_view->undoManager->beginTransaction(m_doc->currentPage()->getUName(),
-																						  Um::ITable, Um::CreateTable,
-																						  QString(Um::RowsCols).arg(Rows).arg(Cols),
-																						  Um::ICreate));
+				activeTransaction = new UndoTransaction(Um::instance()->beginTransaction(m_doc->currentPage()->getUName(),
+																						 Um::ITable, Um::CreateTable,
+																						 QString(Um::RowsCols).arg(Rows).arg(Cols),
+																						 Um::ICreate));
 			m_doc->m_Selection->delaySignalsOn();
 			for (int rc = 0; rc < Rows; ++rc)
 			{
@@ -828,6 +836,7 @@
 				}
 			}
 			m_doc->itemSelection_GroupObjects(false, false);
+			z = m_doc->Items->count() - 1;
 			if (activeTransaction)
 			{
 				activeTransaction->commit();

Modified: trunk/Scribus/scribus/scribusdoc.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=16814&path=/trunk/Scribus/scribus/scribusdoc.cpp
==============================================================================
--- trunk/Scribus/scribus/scribusdoc.cpp (original)
+++ trunk/Scribus/scribus/scribusdoc.cpp Fri Sep  2 22:17:55 2011
@@ -12472,7 +12472,6 @@
 	double gy = miny;
 	double gw = maxx - minx;
 	double gh = maxy - miny;
-	bool wasUndo = UndoManager::undoEnabled();
 	undoManager->setUndoEnabled(false);
 	int z = itemAdd(PageItem::Group, PageItem::Rectangle, gx, gy, gw, gh, 0, CommonStrings::None, CommonStrings::None, true);
 	PageItem *groupItem = Items->takeAt(z);
@@ -12482,7 +12481,7 @@
 	groupItem->groupWidth = gw;
 	groupItem->groupHeight = gh;
 	groupItem->LayerID = objectsLayer;
-	undoManager->setUndoEnabled(wasUndo);
+	undoManager->setUndoEnabled(true);
 	for (uint c = 0; c < selectedItemCount; ++c)
 	{
 		currItem = itemSelection->itemAt(c);
@@ -12493,14 +12492,15 @@
 	groupItem->asGroupFrame()->adjustXYPosition();
 	itemSelection->clear();
 	itemSelection->addItem(groupItem);
-	selectedItemCount = itemSelection->count();
+	selectedItemCount = groupItem->groupItemList.count();
 	SimpleState *ss = new SimpleState(Um::Group, tooltip);
 	ss->set("GROUP", "group");
-	ss->set("itemcount", selectedItemCount);
-	for (uint a=0; a<selectedItemCount; ++a)
-	{
-		currItem = itemSelection->itemAt(a);
-		ss->set(QString("item%1").arg(a), currItem->uniqueNr);
+	ss->set("itemcount", selectedItemCount + 1);
+	ss->set(QString("item%1").arg(0), groupItem->uniqueNr);
+	for (uint a = 0; a < groupItem->groupItemList.count(); ++a)
+	{
+		currItem = groupItem->groupItemList.at(a);
+		ss->set(QString("item%1").arg(a + 1), currItem->uniqueNr);
 	}
 	GroupCounter++;
 	regionsChanged()->update(QRectF(gx-5, gy-5, gw+10, gh+10));

Modified: trunk/Scribus/scribus/ui/propertiespalette_shape.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=16814&path=/trunk/Scribus/scribus/ui/propertiespalette_shape.cpp
==============================================================================
--- trunk/Scribus/scribus/ui/propertiespalette_shape.cpp (original)
+++ trunk/Scribus/scribus/ui/propertiespalette_shape.cpp Fri Sep  2 22:17:55 2011
@@ -298,10 +298,7 @@
 			break;
 		}
 	}
-	if (currItem)
-	{
-		setCurrentItem(currItem);
-	}
+	setCurrentItem(currItem);
 	updateGeometry();
 	repaint();
 }
@@ -325,11 +322,13 @@
 	//if (m_item == i)
 	//	return;
 
-	if (!m_doc)
+	if (item && !m_doc)
 		setDoc(item->doc());
 
 	m_haveItem = false;
 	m_item = item;
+
+	if (!m_item) return;
 
 	if (m_item->FrameType == 0)
 		customShape->setIcon(customShape->getIconPixmap(0));




More information about the scribus-commit mailing list