[Kst] branches/work/kst/hierarchy/kst/src/libkstapp
Eli Fidler
eli at staikos.net
Fri Jan 5 23:42:54 CET 2007
SVN commit 620405 by fidler:
clean up unused data sources after changing file
M +26 -0 kstchangefiledialog_i.cpp
--- branches/work/kst/hierarchy/kst/src/libkstapp/kstchangefiledialog_i.cpp #620404:620405
@@ -174,6 +174,8 @@
KstDataObjectDataObjectMap duplicatedMap;
QMap<KstVectorPtr, KstVectorPtr> duplicatedVectors;
QMap<KstMatrixPtr, KstMatrixPtr> duplicatedMatrices;
+
+ KstDataSourceList oldSources;
// go through the vectors
for (int i = 0; i < (int)rvl.count(); i++) {
@@ -198,6 +200,9 @@
// create a new vector
KstRVectorPtr newVector = vector->makeDuplicate();
+ if (!oldSources.contains(newVector->dataSource())) {
+ oldSources << newVector->dataSource();
+ }
newVector->changeFile(file);
KST::vectorList.lock().unlock();
@@ -208,6 +213,9 @@
KST::duplicateDependents(KstVectorPtr(vector), duplicatedMap, duplicatedVectors);
}
} else {
+ if (!oldSources.contains(vector->dataSource())) {
+ oldSources << vector->dataSource();
+ }
vector->changeFile(file);
}
}
@@ -239,6 +247,9 @@
// create a new matrix
KstRMatrixPtr newMatrix = matrix->makeDuplicate();
+ if (!oldSources.contains(newMatrix->dataSource())) {
+ oldSources << newMatrix->dataSource();
+ }
newMatrix->changeFile(file);
KST::matrixList.lock().unlock();
@@ -249,6 +260,9 @@
KST::duplicateDependents(KstMatrixPtr(matrix), duplicatedMap, duplicatedMatrices);
}
} else {
+ if (!oldSources.contains(matrix->dataSource())) {
+ oldSources << matrix->dataSource();
+ }
matrix->changeFile(file);
}
}
@@ -286,6 +300,18 @@
}
app->deleteIterator(it);
}
+
+ // clean up unused data sources
+ kstdDebug() << "cleaning up data sources" << endl;
+ KST::dataSourceList.lock().writeLock();
+ for (KstDataSourceList::Iterator it = oldSources.begin(); it != oldSources.end(); ++it) {
+ kstdDebug() << "DATA SOURCE: " << (*it)->tag().displayString() << " (" << (void*)(*it) << ") USAGE: " << (*it)->getUsage() << endl;
+ if ((*it)->getUsage() == 1) {
+ kstdDebug() << " -> REMOVED" << endl;
+ KST::dataSourceList.remove((*it).data());
+ }
+ }
+ KST::dataSourceList.lock().unlock();
if (!invalidSources.isEmpty()) {
if (invalid == 1) {
More information about the Kst
mailing list