[Kst] branches/work/kst/portto4/kst

Barth Netterfield netterfield at astro.utoronto.ca
Mon Nov 2 17:46:53 CET 2009


SVN commit 1043903 by netterfield:

Remove some old cruft.
Delete unused data sources selected in the data wizard.



 M  +0 -3      devel-docs/Kst2Specs/Bugs  
 M  +14 -0     devel-docs/Kst2Specs/FixedBugs  
 M  +0 -9      devel-docs/Kst2Specs/Wishlist  
 M  +1 -0      src/datasources/ascii/ascii.cpp  
 M  +0 -1      src/datasources/dirfilesource/dirfilesource.cpp  
 M  +6 -48     src/libkst/objectstore.cpp  
 M  +3 -0      src/libkst/objectstore.h  
 M  +0 -1      src/libkst/vector.cpp  
 M  +6 -0      src/libkstapp/datawizard.cpp  


--- branches/work/kst/portto4/kst/devel-docs/Kst2Specs/Bugs #1043902:1043903
@@ -9,7 +9,4 @@
 
 Artifacts when resizing large arrowheads.
 
---------------------
 
-Datasources that are browsed are created, remembered, and saved/loaded.
-
--- branches/work/kst/portto4/kst/devel-docs/Kst2Specs/FixedBugs #1043902:1043903
@@ -1122,3 +1122,17 @@
 Multi-page printing:
 The code is in place and commented out, because it gets the size wrong for pages other than the current tab.
 This bug is also hit in the export widget.
+
+--------------------
+
+Need to be able to rebuild the datasource list:
+  Make a list of all dataprimitives and their file names
+  Erase all data sources from the object store.
+  for each dataprimitive {
+    find or create (filename)
+    changeFile(newDatasource) (adds to the store?)
+  }
+
+--------------------
+
+Datasources that are browsed are created, remembered, and saved/loaded.
--- branches/work/kst/portto4/kst/devel-docs/Kst2Specs/Wishlist #1043902:1043903
@@ -66,12 +66,3 @@
 
 Names in multipage graphics file export.  name_2.png, not name.png_2, etc
 
---------------------
-
-Need to be able to rebuild the datasource list:
-  Make a list of all dataprimitives and their file names
-  Erase all data sources from the object store.
-  for each dataprimitive {
-    find or create (filename)
-    changeFile(newDatasource) (adds to the store?)
-  }
--- branches/work/kst/portto4/kst/src/datasources/ascii/ascii.cpp #1043902:1043903
@@ -197,6 +197,7 @@
 
 
 AsciiSource::~AsciiSource() {
+  qDebug() << "xxx deleting an ascii source";
   if (_tmpBuf) {
     free(_tmpBuf);
     _tmpBuf = 0L;
--- branches/work/kst/portto4/kst/src/datasources/dirfilesource/dirfilesource.cpp #1043902:1043903
@@ -77,7 +77,6 @@
   _dirfile = 0L;
   delete _watcher;
   _watcher = 0L;
-  qDebug() << " xxx deleting a dirfilesource";
 }
 
 
--- branches/work/kst/portto4/kst/src/libkst/objectstore.cpp #1043902:1043903
@@ -111,43 +111,8 @@
   return NULL;
 }
 
-#if 0
 void ObjectStore::rebuildDataSourceList() {
 
-  DataSourceList newDataSourceList;
-  DataSourcePtr new_data_source;
-  DataPrimitive* object_P;
-
-  foreach(ObjectPtr object, _list) {
-    object_P = dynamic_cast<DataPrimitive *>(object.data());
-    if (object_P) {
-      QString filename = object_P->filename();
-      new_data_source = newDataSourceList.findReusableFileName(filename);
-      if (new_data_source == 0) {
-        new_data_source = DataSource::loadSource(this, filename);
-        newDataSourceList.append(new_data_source);
-      }
-      //object->writeLock();
-      object_P->changeFile(new_data_source);
-      object->update();
-      //object->unlock();
-    }
-  }
-
-  newDataSourceList.clear();
-
-  // clean up unused data sources
-  for (DataSourceList::Iterator it = _dataSourceList.begin(); it != _dataSourceList.end(); ++it) {
-    qDebug() << "Usage: " << (*it)->getUsage();
-    if ((*it)->getUsage() == 0) {
-      removeObject(*it);
-    }
-  }
-}
-#endif
-
-void ObjectStore::rebuildDataSourceList() {
-
   DataSourceList dataSourceList;
 
   for (int i=0; i<_list.count(); i++) {
@@ -170,9 +135,13 @@
   dataSourceList.clear();
   dataSourceList.append(_dataSourceList);
 
+  cleanUpDataSourceList();
+}
+
+void ObjectStore::cleanUpDataSourceList() {
   // clean up unused data sources
-  for (DataSourceList::Iterator it = dataSourceList.begin(); it != dataSourceList.end(); ++it) {
-    if ((*it)->getUsage() == 1) {
+  for (DataSourceList::Iterator it = _dataSourceList.begin(); it != _dataSourceList.end(); ++it) {
+    if ((*it)->getUsage() <= 1) {
       removeObject(*it);
     }
   }
@@ -201,17 +170,6 @@
 }
 
 
-#if 0
-void ObjectStore::setUpdateDisplayTags(bool u) {
-  if (u && !_updateDisplayTags) {
-    // turning on _updateDisplayTags, so do an update
-    updateAllDisplayTags();
-  }
-
-  _updateDisplayTags = u;
-}
-#endif
-
 DataSourceList ObjectStore::dataSourceList() const {
   KstReadLocker l(&_lock);
   return _dataSourceList;
--- branches/work/kst/portto4/kst/src/libkst/objectstore.h #1043902:1043903
@@ -59,6 +59,9 @@
     /** Close all data sources, and reopen ones that are needed */
     void rebuildDataSourceList();
 
+    /** remove unused data sources from the list */
+    void cleanUpDataSourceList();
+
     /** locking */
     KstRWLock& lock() const { return _lock; }
 
--- branches/work/kst/portto4/kst/src/libkst/vector.cpp #1043902:1043903
@@ -82,7 +82,6 @@
     free(_v);
     _v = 0;
   }
-  qDebug() << "destroying vector: rms scalar usage: " << _scalars["rms"]->getUsage();
 }
 
 
--- branches/work/kst/portto4/kst/src/libkstapp/datawizard.cpp #1043902:1043903
@@ -56,6 +56,7 @@
 
 
 DataSourcePtr DataWizardPageDataSource::dataSource() const {
+
   return _dataSource;
 }
 
@@ -84,6 +85,11 @@
   _configureSource->setEnabled(_dataSource->hasConfigWidget());
   _dataSource->unlock();
 
+  {
+    DataSourcePtr tmpds = _dataSource; // increase usage count
+    _store->cleanUpDataSourceList();
+  }
+
   emit completeChanged();
   emit dataSourceChanged();
 }


More information about the Kst mailing list