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

Peter Kümmel syntheticpp at gmx.net
Sat Aug 28 17:28:59 CEST 2010


SVN commit 1169175 by kuemmel:

Always poll on Linux with the help of QFileSystemWatcher for UpdateCheckType 'File',
could be fixed when we know if the file is local or not.
But maybe we remove the code because of all the Qt bugs, hacks and unimplemented Qt features.

CCBUG:248104

 M  +2 -5      datasources/dirfilesource/dirfilesource.cpp  
 M  +24 -3     libkst/datasource.cpp  
 M  +3 -3      libkst/datasource.h  


--- branches/work/kst/portto4/kst/src/datasources/dirfilesource/dirfilesource.cpp #1169174:1169175
@@ -138,7 +138,7 @@
   }
 
   _config = new DirFileSource::Config;
-  _config->read(cfg, filename);
+  _config->read(cfg, _filename);
   if (!e.isNull()) {
     _config->load(e);
   }
@@ -206,13 +206,10 @@
     _frameCount = _dirfile->NFrames();
   }
 
-  _watcher = new QFileSystemWatcher();
   if (_fieldList.count() > 1) {
     QString filePath = _dirfile->ReferenceFilename();
-    _watcher->addPath(filePath);
+    setUpdateType(File, filePath);
   }
-  connect(_watcher, SIGNAL(fileChanged ( const QString & )), this, SLOT(checkUpdate()));
-  connect(_watcher, SIGNAL(directoryChanged ( const QString & )), this, SLOT(checkUpdate()));
 
   registerChange();
   return true;
--- branches/work/kst/portto4/kst/src/libkst/datasource.cpp #1169174:1169175
@@ -31,6 +31,7 @@
 #include <QXmlStreamWriter>
 #include <QTimer>
 #include <QFileSystemWatcher>
+#include <QFSFileEngine>
 
 #include "kst_i18n.h"
 #include "datacollection.h"
@@ -133,7 +134,8 @@
   interf_scalar(new NotSupportedImp<DataScalar>),
   interf_string(new NotSupportedImp<DataString>),
   interf_vector(new NotSupportedImp<DataVector>),
-  interf_matrix(new NotSupportedImp<DataMatrix>)
+  interf_matrix(new NotSupportedImp<DataMatrix>),
+  _watcher(0)
 {
   Q_UNUSED(type)
   Q_UNUSED(store)
@@ -195,7 +197,7 @@
 
 
 
-void DataSource::setUpdateType(UpdateCheckType updateType)
+void DataSource::setUpdateType(UpdateCheckType updateType, const QString& file)
 {
   _updateCheckType = updateType;
   resetFileWatcher();
@@ -203,7 +205,26 @@
     QTimer::singleShot(UpdateManager::self()->minimumUpdatePeriod()-1, this, SLOT(checkUpdate()));
   } else if (_updateCheckType == File) {
     _watcher = new QFileSystemWatcher();
-    _watcher->addPath(_filename);
+    QString usedfile = (file.isEmpty() ? _filename : file);    
+    
+    bool isLocal;
+    // Qt bug: http://bugreports.qt.nokia.com/browse/QTBUG-13248
+    //islocal = QFSFileEngine(usedfile).fileFlags(QAbstractFileEngine::LocalDiskFlag) & QAbstractFileEngine::LocalDiskFlag;    
+#ifdef Q_OS_WIN
+    // TODO What if the directory is mounted?
+    isLocal = !usedfile.startsWith("//");
+#else
+    // TODO How could we detect if the file is not local.
+    //      Always poll on Linux
+    isLocal = false;
+#endif
+
+    if (!isLocal) {
+      // TODO undocumented Qt feature:
+      // http://bugreports.qt.nokia.com/browse/QTBUG-8351
+      _watcher->setObjectName(QLatin1String("_qt_autotest_force_engine_poller"));      
+    }
+    _watcher->addPath(usedfile);
     connect(_watcher, SIGNAL(fileChanged ( const QString & )), this, SLOT(checkUpdate()));
     connect(_watcher, SIGNAL(directoryChanged ( const QString & )), this, SLOT(checkUpdate()));
   } 
--- branches/work/kst/portto4/kst/src/libkst/datasource.h #1169174:1169175
@@ -102,7 +102,7 @@
     /************************************************************/
 
     enum UpdateCheckType { Timer, File, None };
-    void setUpdateType(UpdateCheckType updateType);
+    void setUpdateType(UpdateCheckType updateType, const QString& file = QString());
     virtual UpdateType objectUpdate(qint64 newSerial);
 
     void internalUpdate() {return;}
@@ -222,8 +222,6 @@
     virtual QString _automaticDescriptiveName() const;
     void _initializeShortName();
 
-    QFileSystemWatcher *_watcher;
-
     void setInterface(DataInterface<DataScalar>*);
     void setInterface(DataInterface<DataString>*);
     void setInterface(DataInterface<DataVector>*);
@@ -235,6 +233,8 @@
     DataInterface<DataVector>* interf_vector;
     DataInterface<DataMatrix>* interf_matrix;
 
+    QFileSystemWatcher *_watcher;
+
     // NOTE: You must bump the version key if you add new member variables
     //       or change or add virtual functions.
 };


More information about the Kst mailing list