[Kst] branches/work/kst/portto4/kst/src
Barth Netterfield
netterfield at astro.utoronto.ca
Thu Dec 17 19:59:52 CET 2009
SVN commit 1063290 by netterfield:
Re-fix the update data source button...
Data source API changes, so you probably need a complete
rebuild.
BUG: 218820
M +2 -7 datasources/ascii/ascii.cpp
M +1 -1 datasources/ascii/ascii.h
M +2 -2 datasources/dirfilesource/dirfilesource.cpp
M +1 -1 datasources/dirfilesource/dirfilesource.h
M +2 -2 datasources/qimagesource/qimagesource.cpp
M +1 -1 datasources/qimagesource/qimagesource.h
M +2 -2 datasources/sampledatasource/sampledatasource.cpp
M +1 -1 datasources/sampledatasource/sampledatasource.h
M +2 -16 libkst/datamatrix.cpp
M +1 -2 libkst/datamatrix.h
M +2 -14 libkst/datascalar.cpp
M +1 -1 libkst/datascalar.h
M +2 -2 libkst/datasource.cpp
M +1 -1 libkst/datasource.h
M +2 -14 libkst/datastring.cpp
M +1 -1 libkst/datastring.h
M +4 -17 libkst/datavector.cpp
M +2 -2 libkst/datavector.h
M +3 -0 libkst/object.cpp
M +2 -0 libkst/object.h
M +15 -0 libkst/objectstore.cpp
M +0 -1 libkst/vector.cpp
M +1 -0 libkstapp/mainwindow.cpp
--- branches/work/kst/portto4/kst/src/datasources/ascii/ascii.cpp #1063289:1063290
@@ -239,7 +239,7 @@
}
-bool AsciiSource::reset() {
+void AsciiSource::reset() {
if (_tmpBuf) {
free(_tmpBuf);
_tmpBuf = 0L;
@@ -259,10 +259,7 @@
_matrixList.clear();
_stringList.clear();
- registerChange();
- internalDataSourceUpdate();
-
- return true;
+ Object::reset();
}
@@ -319,7 +316,6 @@
#define MAXBUFREADLEN 32768
Kst::Object::UpdateType AsciiSource::internalDataSourceUpdate() {
-
if (!_haveHeader) {
_haveHeader = initRowIndex();
if (!_haveHeader) {
@@ -401,7 +397,6 @@
} while ((bufread == MAXBUFREADLEN) && (!first_read));
file.close();
-
return (forceUpdate ? Updated : (new_data ? Updated : NoChange));
}
--- branches/work/kst/portto4/kst/src/datasources/ascii/ascii.h #1063289:1063290
@@ -61,7 +61,7 @@
int readString(QString &S, const QString& string);
- bool reset();
+ virtual void reset();
virtual const QString& typeString() const;
--- branches/work/kst/portto4/kst/src/datasources/dirfilesource/dirfilesource.cpp #1063289:1063290
@@ -83,7 +83,7 @@
}
-bool DirFileSource::reset() {
+void DirFileSource::reset() {
disconnect(_watcher, SIGNAL(fileChanged ( const QString & )), this, SLOT(checkUpdate()));
disconnect(_watcher, SIGNAL(directoryChanged ( const QString & )), this, SLOT(checkUpdate()));
if (_dirfile) {
@@ -94,7 +94,7 @@
_watcher = 0L;
init();
- return true;
+ Object::reset();
}
--- branches/work/kst/portto4/kst/src/datasources/dirfilesource/dirfilesource.h #1063289:1063290
@@ -52,7 +52,7 @@
bool isEmpty() const;
- bool reset();
+ virtual void reset();
class Config;
--- branches/work/kst/portto4/kst/src/datasources/qimagesource/qimagesource.cpp #1063289:1063290
@@ -74,9 +74,9 @@
}
-bool QImageSource::reset() {
+void QImageSource::reset() {
init();
- return true;
+ Object::reset();
}
--- branches/work/kst/portto4/kst/src/datasources/qimagesource/qimagesource.h #1063289:1063290
@@ -25,7 +25,7 @@
~QImageSource();
bool init();
- bool reset();
+ virtual void reset();
Kst::Object::UpdateType internalDataSourceUpdate();
--- branches/work/kst/portto4/kst/src/datasources/sampledatasource/sampledatasource.cpp #1063289:1063290
@@ -75,9 +75,9 @@
}
-bool SampleDatasourceSource::reset() {
+void SampleDatasourceSource::reset() {
init();
- return true;
+ Object::reset();
}
--- branches/work/kst/portto4/kst/src/datasources/sampledatasource/sampledatasource.h #1063289:1063290
@@ -25,7 +25,7 @@
~SampleDatasourceSource();
bool init();
- bool reset();
+ virtual void reset();
Kst::Object::UpdateType internalDataSourceUpdate();
--- branches/work/kst/portto4/kst/src/libkst/datamatrix.cpp #1063289:1063290
@@ -407,23 +407,9 @@
if (_file) {
_file->writeLock();
- if (_file->reset()) { // try the efficient way first
- reset();
- } else { // the inefficient way
- DataSourcePtr newsrc = DataSource::loadSource(store(), _file->fileName(), _file->fileType());
- assert(newsrc != _file);
- if (newsrc) {
- _file->unlock();
- // FIXME: need to writelock store?
- if (store()) {
- store()->removeObject(_file);
- }
- _file = newsrc;
- _file->writeLock();
- reset();
- }
- }
+ _file->reset();
_file->unlock();
+ reset();
}
}
--- branches/work/kst/portto4/kst/src/libkst/datamatrix.h #1063289:1063290
@@ -67,6 +67,7 @@
// reload contents of DataMatrix from file
void reload();
+ virtual void reset();
// change the datasource for this matrix
void changeFile(DataSourcePtr file);
@@ -99,8 +100,6 @@
void doUpdateSkip(int realXStart, int realYStart);
void doUpdateNoSkip(int realXStart, int realYStart);
- void reset();
-
// values requested; may be different from actual matrix range
int _reqXStart, _reqYStart, _reqNX, _reqNY;
--- branches/work/kst/portto4/kst/src/libkst/datascalar.cpp #1063289:1063290
@@ -158,21 +158,9 @@
if (_file) {
_file->writeLock();
- if (_file->reset()) { // try the efficient way first
- reset();
- } else { // the inefficient way
- DataSourcePtr newsrc = DataSource::loadSource(store(), _file->fileName(), _file->fileType());
- if (newsrc) {
- _file->unlock();
- if (store()) {
- store()->removeObject(_file);
- }
- _file = newsrc;
- _file->writeLock();
- reset();
- }
- }
+ _file->reset();
_file->unlock();
+ reset();
registerChange();
}
}
--- branches/work/kst/portto4/kst/src/libkst/datascalar.h #1063289:1063290
@@ -69,7 +69,7 @@
virtual QString propertyString() const;
bool isValid() const;
- void reset();
+ virtual void reset();
void reload();
};
--- branches/work/kst/portto4/kst/src/libkst/datasource.cpp #1063289:1063290
@@ -889,8 +889,8 @@
}
-bool DataSource::reset() {
- return false;
+void DataSource::reset() {
+ Object::reset();
}
--- branches/work/kst/portto4/kst/src/libkst/datasource.h #1063289:1063290
@@ -137,7 +137,7 @@
/** Reset to initial state of the source, just as though no data had been
* read and the file had just been opened. Return true on success.
*/
- virtual bool reset();
+ virtual void reset();
virtual void deleteDependents();
--- branches/work/kst/portto4/kst/src/libkst/datastring.cpp #1063289:1063290
@@ -161,21 +161,9 @@
if (_file) {
_file->writeLock();
- if (_file->reset()) { // try the efficient way first
- reset();
- } else { // the inefficient way
- DataSourcePtr newsrc = DataSource::loadSource(store(), _file->fileName(), _file->fileType());
- if (newsrc) {
- _file->unlock();
- if (store()) {
- store()->removeObject(_file);
- }
- _file = newsrc;
- _file->writeLock();
- reset();
- }
- }
+ _file->reset();
_file->unlock();
+ reset();
registerChange();
}
}
--- branches/work/kst/portto4/kst/src/libkst/datastring.h #1063289:1063290
@@ -51,7 +51,7 @@
void reload();
- void reset();
+ virtual void reset();
virtual const QString& typeString() const;
static const QString staticTypeString;
--- branches/work/kst/portto4/kst/src/libkst/datavector.cpp #1063289:1063290
@@ -317,6 +317,7 @@
_dirty = true;
_resetFieldMetadata();
+ Object::reset();
}
@@ -587,24 +588,10 @@
if (_file) {
_file->writeLock();
- if (_file->reset()) { // try the efficient way first
- reset();
- } else { // the inefficient way
- DataSourcePtr newsrc = DataSource::loadSource(store(), _file->fileName(), _file->fileType());
- assert(newsrc != _file);
- if (newsrc) {
- _file->unlock();
- if (store()) {
- store()->removeObject(_file);
- }
- _dontUseSkipAccel = false;
- _file = newsrc;
- _file->writeLock();
- reset();
- }
- }
- _resetFieldMetadata();
+ _file->reset();
_file->unlock();
+ reset();
+ _resetFieldMetadata();
registerChange();
}
}
--- branches/work/kst/portto4/kst/src/libkst/datavector.h #1063289:1063290
@@ -38,6 +38,8 @@
static const QString staticTypeString;
static const QString staticTypeTag;
+ virtual void reset(); // must be called with a lock
+
/** change the properties of a DataVector */
void change(DataSourcePtr file, const QString &field,
int f0, int n, int skip,
@@ -145,8 +147,6 @@
int N_AveReadBuf;
double *AveReadBuf;
- void reset(); // must be called with a lock
-
void checkIntegrity(); // must be called with a lock
bool _dontUseSkipAccel;
--- branches/work/kst/portto4/kst/src/libkst/object.cpp #1063289:1063290
@@ -39,6 +39,9 @@
return staticMetaObject.className();
}
+void Object::reset() {
+ _serial = _serialOfLastChange = Forced;
+}
const QString& Object::typeString() const {
return staticTypeString;
--- branches/work/kst/portto4/kst/src/libkst/object.h #1063289:1063290
@@ -52,6 +52,8 @@
virtual UpdateType objectUpdate(qint64 newSerial);
virtual void registerChange() {_serial = Forced;}
+ virtual void reset();
+
qint64 serial() const {return _serial;}
qint64 serialOfLastChange() const {return _serialOfLastChange;}
--- branches/work/kst/portto4/kst/src/libkst/objectstore.cpp #1063289:1063290
@@ -115,7 +115,21 @@
}
void ObjectStore::rebuildDataSourceList() {
+ cleanUpDataSourceList();
+ foreach (DataSourcePtr ds, _dataSourceList) {
+ ds->writeLock();
+ ds->reset();
+ ds->unlock();
+ }
+ foreach (ObjectPtr object, _list) {
+ object->writeLock();
+ object->reset();
+ object->unlock();
+ }
+}
+#if 0
+void ObjectStore::rebuildDataSourceList() {
DataSourceList dataSourceList;
for (int i=0; i<_list.count(); i++) {
@@ -174,6 +188,7 @@
cleanUpDataSourceList();
}
+#endif
void ObjectStore::cleanUpDataSourceList() {
DataSourceList currentSourceList;
--- branches/work/kst/portto4/kst/src/libkst/vector.cpp #1063289:1063290
@@ -356,7 +356,6 @@
bool Vector::resize(int sz, bool init) {
- //qDebug() << "resizing to: " << sz;
if (sz > 0) {
_v = static_cast<double*>(realloc(_v, sz*sizeof(double)));
if (!_v) {
--- branches/work/kst/portto4/kst/src/libkstapp/mainwindow.cpp #1063289:1063290
@@ -1064,6 +1064,7 @@
void MainWindow::reload() {
document()->objectStore()->rebuildDataSourceList();
+ UpdateManager::self()->doUpdates(true);
document()->setChanged(true);
}
More information about the Kst
mailing list