r14283 by jghali - #8576: Grouping/Ungrouping/deleting objects takes forever when outline palette is visible

scribus-commit scribus-commit at lists.scribus.net
Thu Nov 12 00:45:18 CET 2009


Revision: 14283
Author: jghali
Date: 2009-11-11T16:35:25.135130Z
Commit message: #8576: Grouping/Ungrouping/deleting objects takes forever when outline palette is visible 

Changeset: 
M  /trunk/Scribus/scribus/scribusdoc.cpp

Diffs:
Index: scribus/scribusdoc.cpp
===================================================================
--- scribus/scribusdoc.cpp	(revision 14282)
+++ scribus/scribusdoc.cpp	(revision 14283)
@@ -96,22 +96,54 @@
 class DocUpdater : public Observer<Page*>, public Observer<PageItem*> 
 {
 	ScribusDoc* doc;
+	int  m_updateEnabled;
+	bool m_docChangeNeeded;
 public:
-	DocUpdater(ScribusDoc* d) : doc(d) {}
+	DocUpdater(ScribusDoc* d) : doc(d), m_updateEnabled(0), m_docChangeNeeded(false) {}
+
+	void beginUpdate(void)
+	{ 
+		if (m_updateEnabled == 0)
+			m_docChangeNeeded = false;
+		++m_updateEnabled;
+	}
+
+	void endUpdate(void)
+	{
+		--m_updateEnabled;
+		if (m_updateEnabled <= 0)
+		{
+			if (m_docChangeNeeded)
+			{
+				doc->changed();
+				m_docChangeNeeded = false;
+			}
+		}
+	}
 	
 	void changed(Page* pg)
 	{
 		QRectF pagebox(pg->xOffset(), pg->yOffset(), pg->width(), pg->height());
 		doc->invalidateRegion(pagebox);
 		doc->regionsChanged()->update(pagebox);
-		doc->changed();
+		if (m_updateEnabled <= 0)
+		{
+			doc->changed();
+			return;
+		}
+		m_docChangeNeeded = true;
 	}
 	
 	void changed(PageItem* it)
 	{
 		it->invalidateLayout();
 		doc->regionsChanged()->update(it->getVisualBoundingRect());
-		doc->changed();
+		if (m_updateEnabled <= 0)
+		{
+			doc->changed();
+			return;
+		}
+		m_docChangeNeeded = true;
 	}
 };
 
@@ -3895,12 +3927,16 @@
 
 void ScribusDoc::renumberItemsInListOrder( )
 {
+	m_docUpdater->beginUpdate();
+	m_updateManager.setUpdatesEnabled(false);
 	int itemsCount=Items->count();
 	for (int i = 0; i < itemsCount; ++i)
 	{
 		Items->at(i)->ItemNr = i;
 		Items->at(i)->checkTextFlowInteractions(true);
 	}
+	m_updateManager.setUpdatesEnabled(true);
+	m_docUpdater->endUpdate();
 }
 
 




More information about the scribus-commit mailing list