Version: 1.2.0_devel (using KDE KDE 3.4.0) OS: Linux You have to click on purge twice to get histograms to fully delete in the data manager. Steps to reproduce: 1. Plot a histogram in kst. You can plot other stuff too, if you want. 2. Delete the histogram from all windows. 3. Open the data manager. 4. Click on purge. Note that the 'curve' of the histogram is deleted, but the histogram is not. 5. Click on purge again. Now everything that should be purged is. Expected behavior: All of the unused histogram data manager items are deleted with one click of purge. Note: This may have to do with the fact that the histogram always seems to have a "used" checkmark.
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); }