[Kst] extragear/graphics/kst/kst

Rick Chern rchern at interchange.ubc.ca
Fri Jul 15 23:49:40 CEST 2005


SVN commit 434972 by rchern:

Purge all editable vectors and matrices too

 M  +22 -6     kstdoc.cpp  


--- trunk/extragear/graphics/kst/kst/kstdoc.cpp #434971:434972
@@ -821,11 +821,13 @@
 void KstDoc::purge() {
   QString purging = i18n("Purging unused objects");
   bool modified = false;
-  KstRVectorList rvl = kstObjectSubList<KstVector,KstRVector>(KST::vectorList);
   KstApp *app = KstApp::inst();
-
+  
+  KstVectorList vectorList = KST::vectorList;
+  KstMatrixList matrixList = KST::matrixList;
+  
   KST::dataObjectList.lock().writeLock();
-  int cnt = rvl.count() + KST::dataObjectList.count();
+  int cnt = matrixList.count() + vectorList.count() + KST::dataObjectList.count();
   int prg = 0;
 
   app->slotUpdateProgress(cnt, prg, purging);
@@ -845,9 +847,11 @@
   }
   KST::dataObjectList.lock().writeUnlock();
 
-  for (KstRVectorList::Iterator it = rvl.begin(); it != rvl.end(); ++it) {
+  // clear unused vectors that are editable 
+  for (KstVectorList::Iterator it = vectorList.begin(); it != vectorList.end(); ++it) {
     //kdDebug() << "VECTOR: " << (*it)->tagName() << " USAGE: " << (*it)->getUsage() << endl;
-    if ((*it)->getUsage() == 1) {
+    // make sure it is used and it is editable (not a slave vector)
+    if ((*it)->getUsage() == 1 && (*it)->editable()) {
       //kdDebug() << "    -> REMOVED" << endl;
       KST::vectorList.lock().writeLock();
       KST::vectorList.remove((*it).data());
@@ -857,10 +861,22 @@
     prg++;
     app->slotUpdateProgress(cnt, prg, purging);
   }
+  
+  // clear unused matrices that are editable
+  for (KstMatrixList::Iterator it = matrixList.begin(); it != matrixList.end(); ++it) {
+    if ((*it)->getUsage() == 1 && (*it)->editable()) {
+      //kdDebug() << "    -> REMOVED" << endl;
+      KST::matrixList.lock().writeLock();
+      KST::matrixList.remove((*it).data());
+      KST::matrixList.lock().writeUnlock();
+      modified = true;
+    }
+    prg++;
+    app->slotUpdateProgress(cnt, prg, purging);
+  }
 
   app->slotUpdateProgress(0, 0, QString::null);
 
-  rvl.clear();
   setModified(modified);
   emit updateDialogs();
 }


More information about the Kst mailing list