[Kst] kdeextragear-2/kst/kst/datasources/indirect
George Staikos
staikos at kde.org
Mon Sep 13 21:37:05 CEST 2004
CVS commit by staikos:
allow indirect sources to hang around while what they point to isn't around,
but refresh pick it up later. This does not address the issue of opening
an indirect file that doesn't exist on disk. I'm not sure this is worth the
effort since it really doesn't make much sense. I consider that part of the
report "WONTFIX".
CCMAIL: 88425-done at bugs.kde.org
M +16 -14 indirect.cpp 1.6
--- kdeextragear-2/kst/kst/datasources/indirect/indirect.cpp #1.5:1.6
@@ -23,6 +23,10 @@
IndirectSource::IndirectSource(const QString& filename, KstDataSourcePtr child)
: KstDataSource(filename, QString::null), _child(child) {
+ if (child) {
_valid = true;
_fieldList = child->fieldList();
+ } else {
+ _valid = false;
+ }
}
@@ -38,9 +42,11 @@ KstObject::UpdateType IndirectSource::up
QString ifn;
if (0 < f.readLine(ifn, 1000)) {
- if (ifn.stripWhiteSpace() != _child->fileName()) {
+ if (!_child || ifn.stripWhiteSpace() != _child->fileName()) {
+ _child = 0L; // release
KstDataSourcePtr p = KstDataSource::loadSource(ifn.stripWhiteSpace());
if (p) {
_child = p;
_fieldList = p->fieldList();
+ _valid = true;
} else {
_valid = false;
@@ -50,25 +56,25 @@ KstObject::UpdateType IndirectSource::up
}
- return _child->update(u);
+ return _child ? _child->update(u) : KstObject::NO_CHANGE;
}
int IndirectSource::readField(double *v, const QString& field, int s, int n) {
- return _child->readField(v, field, s, n);
+ return _child ? _child->readField(v, field, s, n) : -1;
}
bool IndirectSource::isValidField(const QString& field) const {
- return _child->isValidField(field);
+ return _child ? _child->isValidField(field) : false;
}
int IndirectSource::samplesPerFrame(const QString &field) {
- return _child->samplesPerFrame(field);
+ return _child ? _child->samplesPerFrame(field) : 0;
}
int IndirectSource::frameCount(const QString& field) const {
- return _child->frameCount(field);
+ return _child ? _child->frameCount(field) : 0;
}
@@ -85,10 +91,10 @@ void IndirectSource::save(QTextStream &t
bool IndirectSource::isValid() const {
- return KstDataSource::isValid() && _child->isValid();
+ return KstDataSource::isValid() && _child && _child->isValid();
}
bool IndirectSource::isEmpty() const {
- return _child->isEmpty();
+ return _child ? _child->isEmpty() : true;
}
@@ -113,8 +119,4 @@ KstDataSource *create_indirect(const QSt
f.close();
- if (!p) {
- return 0L;
- }
-
return new IndirectSource(filename, p);
}
More information about the Kst
mailing list