[Kst] extragear/graphics/kst/kst
Andrew Walker
arwalker at sumusltd.com
Mon Aug 15 20:49:52 CEST 2005
SVN commit 449492 by arwalker:
BUG:110733 Properly purge by making a loop until no further objects are removed.
M +59 -48 kstdoc.cpp
--- trunk/extragear/graphics/kst/kst/kstdoc.cpp #449491:449492
@@ -835,64 +835,75 @@
void KstDoc::purge() {
QString purging = i18n("Purging unused objects");
bool modified = false;
+ bool again = true;
KstApp *app = KstApp::inst();
-
- KstVectorList vectorList = KST::vectorList;
- KstMatrixList matrixList = KST::matrixList;
-
- KST::dataObjectList.lock().writeLock();
- int cnt = matrixList.count() + vectorList.count() + KST::dataObjectList.count();
+ int cnt;
int prg = 0;
- app->slotUpdateProgress(cnt, prg, purging);
-
- // ASSUMPTION: this only gets called from the data manager!
- for (KstDataObjectList::Iterator it = KST::dataObjectList.begin(); it != KST::dataObjectList.end(); ++it) {
- //kdDebug() << "OBJECT: " << (*it)->tagName() << " USAGE: " << (*it)->getUsage() << endl;
- if ((*it)->getUsage() == 0) {
- //kdDebug() << " -> REMOVED" << endl;
- KstDataObjectList::Iterator byebye = it;
- --it;
- KST::dataObjectList.remove(byebye);
- modified = true;
- }
- prg++;
+ while (again) {
+ KstVectorList vectorList = KST::vectorList;
+ KstMatrixList matrixList = KST::matrixList;
+
+ KST::dataObjectList.lock().writeLock();
+ cnt = matrixList.count() + vectorList.count() + KST::dataObjectList.count();
+ KST::dataObjectList.lock().writeUnlock();
+
+ prg = 0;
app->slotUpdateProgress(cnt, prg, purging);
- }
- KST::dataObjectList.lock().writeUnlock();
-
- // clear unused vectors that are editable
- for (KstVectorList::Iterator it = vectorList.begin(); it != vectorList.end(); ++it) {
- //kdDebug() << "VECTOR: " << (*it)->tagName() << " USAGE: " << (*it)->getUsage() << endl;
- // 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());
- KST::vectorList.lock().writeUnlock();
- modified = true;
+ again = false;
+
+ // ASSUMPTION: this only gets called from the data manager!
+ KST::dataObjectList.lock().writeLock();
+ for (KstDataObjectList::Iterator it = KST::dataObjectList.begin(); it != KST::dataObjectList.end(); ++it) {
+ //kdDebug() << "OBJECT: " << (*it)->tagName() << " USAGE: " << (*it)->getUsage() << endl;
+ if ((*it)->getUsage() == 0) {
+ //kdDebug() << " -> REMOVED" << endl;
+ KstDataObjectList::Iterator byebye = it;
+ --it;
+ KST::dataObjectList.remove(byebye);
+ again = true;
+ modified = true;
+ }
+ prg++;
+ app->slotUpdateProgress(cnt, prg, purging);
}
- prg++;
- app->slotUpdateProgress(cnt, prg, purging);
- }
+ KST::dataObjectList.lock().writeUnlock();
- // 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;
+ // clear unused vectors that are editable
+ for (KstVectorList::Iterator it = vectorList.begin(); it != vectorList.end(); ++it) {
+ //kdDebug() << "VECTOR: " << (*it)->tagName() << " USAGE: " << (*it)->getUsage() << endl;
+ // 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());
+ KST::vectorList.lock().writeUnlock();
+ again = true;
+ modified = true;
+ }
+ prg++;
+ app->slotUpdateProgress(cnt, prg, purging);
}
- 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();
+ again = true;
+ modified = true;
+ }
+ prg++;
+ app->slotUpdateProgress(cnt, prg, purging);
+ }
}
-
- app->slotUpdateProgress(0, 0, QString::null);
-
+
setModified(modified);
emit updateDialogs();
+
+ app->slotUpdateProgress(0, 0, QString::null);
}
More information about the Kst
mailing list