[Kst] kdeextragear-2/kst/kst

George Staikos staikos at kde.org
Sun Dec 21 07:20:58 CET 2003


CVS commit by staikos: 

rvectors should not crash if they cannot find the file they need.  It's not
pretty, but I would rather have null files than have files that are useless
in all ways except that they are not null.  Meanwhile we shouldn't return
null files for dirfiles that don't exist yet.  That will be fixed next.

CCMAIL: 70923-done at bugs.kde.org


  M +1 -0      kstdoc.cpp   1.46
  M +20 -7     kstrvector.cpp   1.37


--- kdeextragear-2/kst/kst/kstdoc.cpp  #1.45:1.46
@@ -74,4 +74,5 @@ KstDoc::~KstDoc() {
     // pointer to KstDoc::scalarList, also static, which gets used during
     // vector destruction.
+    KST::filterSetList.clear();
     KST::plotList.clear();
     KST::vectorList.clear();

--- kdeextragear-2/kst/kst/kstrvector.cpp  #1.36:1.37
@@ -95,6 +95,5 @@ KstRVector::KstRVector(QDomElement &e, c
   }
   /* Call the common constructor */
-  commonRVConstructor(in_file, in_field, in_f0, in_n, in_skip,
-                      in_DoSkip, in_DoAve);
+  commonRVConstructor(in_file, in_field, in_f0, in_n, in_skip, in_DoSkip, in_DoAve);
 }
 
@@ -130,5 +129,7 @@ void KstRVector::commonRVConstructor(Kst
   }
 
+  if (_file) {
   SPF = _file->samplesPerFrame(Field);
+  }
 
   _dirty = true;
@@ -246,4 +247,8 @@ int KstRVector::reqStartFrame() const {
 /** Save vector information */
 void KstRVector::save(QTextStream &ts) {
+  if (!_file) {
+    return;
+  }
+
   ts << "  <tag>" << _tag << "</tag>" << endl;
   ts << "  <filename>" << _file->fileName() << "</filename>" << endl;
@@ -261,5 +266,5 @@ void KstRVector::save(QTextStream &ts) {
 /** return the name of the file */
 QString KstRVector::filename() const {
-  return _file->fileName();
+  return _file ? _file->fileName() : QString::null;
 }
 
@@ -274,5 +279,5 @@ QString KstRVector::label() const {
 
   Field.toInt(&ok);
-  if (ok && _file->fileType() == "ASCII") {
+  if (ok && _file && _file->fileType() == "ASCII") {
     label = i18n("Column %1").arg(Field);
   } else {
@@ -284,5 +289,5 @@ QString KstRVector::label() const {
 
 void KstRVector::reset() {
-  SPF = _file->samplesPerFrame(Field);
+  SPF = _file ? _file->samplesPerFrame(Field) : SPF;
   F0 = NF = 0;
   resize(0);
@@ -302,5 +307,5 @@ void KstRVector::checkIntegrity() {
 
   /* if it looks like we have a new file, reset */
-  if (SPF != _file->samplesPerFrame(Field.latin1()) || _file->frameCount() < NF) {
+  if (_file && (SPF != _file->samplesPerFrame(Field.latin1()) || _file->frameCount() < NF)) {
     reset();
   }
@@ -336,4 +341,8 @@ KstObject::UpdateType KstRVector::doUpda
   checkIntegrity();
 
+  if (!_file) {
+    return NO_CHANGE;
+  }
+
   /*******************************/
   /**** Set new_nf and new_f0 ****/
@@ -487,4 +496,8 @@ int KstRVector::fileLength() const {
 
 void KstRVector::reload() {
+  if (!_file) {
+    return;
+  }
+
   // FIXME: inefficient
   KstDataSourcePtr newsrc = KstDataSource::loadSource(_file->fileName(), _file->fileType());





More information about the Kst mailing list