[Kst] kdeextragear-2/kst/kst/datasources/planck
George Staikos
staikos at kde.org
Wed Feb 4 15:31:39 CET 2004
CVS commit by staikos:
making piolib plugin more correct, less crashy
M +10 -10 planck.cpp 1.10
M +3 -0 plancktoi.cpp 1.8
--- kdeextragear-2/kst/kst/datasources/planck/planck.cpp #1.9:1.10
@@ -71,23 +71,24 @@ int PlanckSource::readField(double *v, c
QSize sz = _planckTOI->range(field);
+ long start = sz.width(), end = sz.height(), count = end - start + 1;
- if (s > sz.height() - sz.width()) {
+ if (s >= count) { // start past the end
return 0;
}
- if (s + n > sz.height() - sz.width()) {
- n = sz.height() - sz.width() - s;
+ if (s + n >= count) { // trying to read past the end
+ n = count - s - 1;
}
- if (n < 0) {
- n = 1;
+ if (n < 0) { // reading less than 0 -> read to the end!
+ n = end - start - s;
}
- if (s + sz.width() >= sz.height() - 1) {
- kdDebug() << "Nothing to read: (" << sz.width() << "," << sz.height() << ") " << s << endl;
+ if (s + start > end) {
+ kdDebug() << "Nothing to read: (" << start << "," << end << ") " << s << endl;
return 0;
}
- return _planckTOI->readObject(field, v, sz.width() + s, sz.width() + s + n - 1);
+ return _planckTOI->readObject(field, v, start + s, start + s + n);
}
@@ -111,6 +112,5 @@ int PlanckSource::frameCount() const {
// FIXME: can't use the last field!!
QSize sz = _planckTOI->range(_fieldList.last());
- // piolib seems to lie. it says the range is x..y but it's actually x..y-1
- return sz.height() - sz.width();
+ return sz.height() - sz.width() + 1;
}
--- kdeextragear-2/kst/kst/datasources/planck/plancktoi.cpp #1.7:1.8
@@ -195,4 +195,6 @@ int TOI::readObject(const QString& objec
PIOLONG(n));
+ PIODeleteLink(buf, g->_group);
+
assert(buf);
#ifdef TOIDEBUG
@@ -305,4 +307,5 @@ bool TOIGroup::open(const QString& group
kdDebug() << " -> object: " << objectNameList[i] << endl;
kdDebug() << " -> first index: " << (long) firstIndex[i] << endl;
+ lastIndex[i]--; // HACK: piolib lies
kdDebug() << " -> last index: " << (long) lastIndex[i] << endl;
}
More information about the Kst
mailing list