Bug 70923

Summary: Crash on startup if ?.kst file refers to non-existent data file
Product: [Applications] kst Reporter: Netterfield <netterfield>
Component: generalAssignee: George Staikos <staikos>
Status: RESOLVED FIXED    
Severity: crash    
Priority: NOR    
Version: 1.x   
Target Milestone: ---   
Platform: Mandrake RPMs   
OS: Linux   
Latest Commit: Version Fixed In:

Description Netterfield 2003-12-20 16:15:09 UTC
Version:           CVS (using KDE KDE 3.1.3)
Installed from:    Mandrake RPMs

Crash on startup if ?.kst file refers to non-existent data file... The file plugin loader return is undefined if no plugin provides the file - and this is never checked for later.
Comment 1 George Staikos 2003-12-21 07:21:29 UTC
Subject: kdeextragear-2/kst/kst

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@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());


Comment 2 George Staikos 2003-12-21 07:30:38 UTC
Subject: kdeextragear-2/kst/kst

CVS commit by staikos: 

store the file type
CCMAIL: 70923@bugs.kde.org


  M +1 -0      kstdatasource.cpp   1.14


--- kdeextragear-2/kst/kst/kstdatasource.cpp  #1.13:1.14
@@ -270,4 +270,5 @@ QString KstDataSource::fileType() const 
 void KstDataSource::save(QTextStream &ts) {
   ts << " <filename>" << QStyleSheet::escape(_filename) << "</filename>" << endl;
+  ts << " <type>" << QStyleSheet::escape(fileType()) << "</type>" << endl;
 }