r14282 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:40:20 CET 2009


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

Changeset: 
M  /branches/Version135/Scribus/scribus/scribusdoc.cpp

Diffs:
Index: scribus/scribusdoc.cpp
===================================================================
--- scribus/scribusdoc.cpp	(revision 14281)
+++ scribus/scribusdoc.cpp	(revision 14282)
@@ -93,22 +93,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->getBoundingRect());
-		doc->changed();
+		if (m_updateEnabled <= 0)
+		{
+			doc->changed();
+			return;
+		}
+		m_docChangeNeeded = true;
 	}
 };
 
@@ -3869,12 +3901,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