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

Barth Netterfield netterfield at astro.utoronto.ca
Sat Oct 31 00:22:36 CET 2009


SVN commit 1042880 by netterfield:

Changing computers...
save what I have.



 M  +5 -0      datasources/dirfilesource/dirfilesource.cpp  
 M  +50 -27    libkst/objectstore.cpp  
 M  +1 -0      libkst/updatemanager.cpp  
 M  +1 -0      libkstapp/mainwindow.cpp  
 M  +0 -1      libkstapp/viewitem.cpp  


--- branches/work/kst/portto4/kst/src/datasources/dirfilesource/dirfilesource.cpp #1042879:1042880
@@ -78,12 +78,15 @@
 
 
 DirFileSource::~DirFileSource() {
+  disconnect(_watcher, SIGNAL(fileChanged ( const QString & )), this, SLOT(checkUpdate()));
+  disconnect(_watcher, SIGNAL(directoryChanged ( const QString & )), this, SLOT(checkUpdate()));
   delete _config;
   _config = 0L;
   delete _dirfile;
   _dirfile = 0L;
   delete _watcher;
   _watcher = 0L;
+  qDebug() << " xxx deleting a dirfilesource";
 }
 
 
@@ -137,6 +140,8 @@
   bool isnew = newNF != _frameCount;
   _frameCount = newNF;
 
+  //qDebug() << "xxx   frameCount: " << _frameCount << " is New: " << isnew;
+
   return (isnew ? Kst::Object::UPDATE : Kst::Object::NO_CHANGE);
 }
 
--- branches/work/kst/portto4/kst/src/libkst/objectstore.cpp #1042879:1042880
@@ -21,7 +21,7 @@
 
 #include "object.h"
 #include "objectstore.h"
-#include "dataprimitive.h"
+#include "datavector.h"
 
 // NAMEDEBUG: 0 for no debug, 1 for some debug, 2 for more debug, 3 for all debug
 #define NAMEDEBUG 0
@@ -111,45 +111,30 @@
   return NULL;
 }
 
-typedef struct {
-    ObjectPtr object;
-    QString filename;
-} ObjectFile;
-
+#if 0
 void ObjectStore::rebuildDataSourceList() {
 
-  QList<ObjectFile> dataPrimitives;
-  ObjectFile objectFile;
   DataSourceList newDataSourceList;
   DataSourcePtr new_data_source;
+  DataPrimitive* object_P;
 
-  DataPrimitive* P;
-
   foreach(ObjectPtr object, _list) {
-    P = dynamic_cast<DataPrimitive *>(object.data());
-    if (P) {
-      objectFile.object = object;
-      objectFile.filename = P->filename();
-      dataPrimitives.append(objectFile);
-    }
-  }
-
-  foreach(ObjectFile of, dataPrimitives) {
-    P = dynamic_cast<DataPrimitive *>(of.object.data());
-    if (P) {
-      new_data_source = newDataSourceList.findReusableFileName(of.filename);
+    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, of.filename);
+        new_data_source = DataSource::loadSource(this, filename);
         newDataSourceList.append(new_data_source);
       }
-      of.object->writeLock();
-      P->changeFile(new_data_source);
-      of.object->unlock();
+      //object->writeLock();
+      object_P->changeFile(new_data_source);
+      object->update();
+      //object->unlock();
     }
   }
 
   newDataSourceList.clear();
-  dataPrimitives.clear();
 
   // clean up unused data sources
   for (DataSourceList::Iterator it = _dataSourceList.begin(); it != _dataSourceList.end(); ++it) {
@@ -159,7 +144,45 @@
     }
   }
 }
+#endif
 
+void ObjectStore::rebuildDataSourceList() {
+
+  DataSourceList newDataSourceList;
+
+  foreach(ObjectPtr object, _list) {
+  DataSourcePtr new_data_source;
+    DataVectorPtr object_P = kst_cast<DataVector>(object);
+    if (object_P) {
+      object_P->readLock();
+      QString filename = object_P->filename();
+      object_P->unlock();
+      new_data_source = newDataSourceList.findReusableFileName(filename);
+      if (new_data_source == 0) {
+        new_data_source = DataSource::loadSource(this, filename);
+        new_data_source->readLock();
+        newDataSourceList.append(new_data_source);
+        new_data_source->unlock();
+      }
+      object_P->writeLock();
+      //object_P->changeFile(new_data_source);
+      object_P->update();
+      object_P->unlock();
+    }
+  }
+
+
+  // clean up unused data sources
+  for (DataSourceList::Iterator it = _dataSourceList.begin(); it != _dataSourceList.end(); ++it) {
+    qDebug() << "Usage: " << (*it)->getUsage() << " fileName: " << (*it)->fileName();
+    if ((*it)->getUsage() == 1) {
+      removeObject(*it);
+    }
+  }
+  qDebug() << "removed";
+  newDataSourceList.clear();
+}
+
 bool ObjectStore::isEmpty() const {
   KstReadLocker l(&_lock);
   return _list.isEmpty();
--- branches/work/kst/portto4/kst/src/libkst/updatemanager.cpp #1042879:1042880
@@ -58,6 +58,7 @@
 
 void UpdateManager::requestUpdate(ObjectPtr object) {
   if (!_updateRequests.contains(object)) {
+//    qDebug() << "xxx    appending object to update requests";
     _updateRequests.append(object);
   }
 #if DEBUG_UPDATE_CYCLE > 1
--- branches/work/kst/portto4/kst/src/libkstapp/mainwindow.cpp #1042879:1042880
@@ -1031,6 +1031,7 @@
 
 void MainWindow::reload() {
   document()->objectStore()->rebuildDataSourceList();
+  document()->setChanged(true);
 }
 
 void MainWindow::showDataManager() {
--- branches/work/kst/portto4/kst/src/libkstapp/viewitem.cpp #1042879:1042880
@@ -1659,7 +1659,6 @@
 
 
 void ViewItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) {
-
   if (parentView()->viewMode() == View::Data) {
     event->ignore();
     return;


More information about the Kst mailing list