[Kst] kdeextragear-2/kst/kst

George Staikos staikos at kde.org
Wed Jul 30 02:58:25 CEST 2003


CVS commit by staikos: 

traced down a UMR, and a nasty bug that was resulting in complex crashes:
main() is far too complex.  It should do much less, or be refactored.  The
problem is that there are too many codepaths, and KstApp* was not being
deleted, resulting in kstdoc not being deleted, resulting in the global lists
being nonempty (and the static destruction trying to empty them, of course in
the wrong order!).

(this was found with the new regression testing scripts)


  M +1 -1      kstvector.cpp   1.40
  M +10 -5     main.cpp   1.31


--- kdeextragear-2/kst/kst/kstvector.cpp  #1.39:1.40
@@ -37,5 +37,5 @@ double KST::NOPOINT = 0.0/0.0; // NaN
 /** Create a vector */
 KstVector::KstVector(const QString& name, int size)
-: KstObject(), _scalars(11) {
+: KstObject(), _nsum(0), _scalars(11) {
   //kdDebug() << "+++ CREATING VECTOR: " << (void*) this << endl;
   _tag = name;

--- kdeextragear-2/kst/kst/main.cpp  #1.30:1.31
@@ -190,5 +190,5 @@ KstRVectorPtr CreateVector(QString field
     kdError() << I18N_NOOP("Error: Invalid field: ") << vector->getField()
          << endl << I18N_NOOP("File: ") << vector->getFilename() << endl;
-    exit(0);
+    exit(0); // fixme: this can cause crashes
   }
 
@@ -283,4 +283,5 @@ int main(int argc, char *argv[]) {
           std::cerr << I18N_NOOP("Error: No data in file: ")
                << args->arg(i_file) << "\n";
+          delete kst;
           exit(0);
         }
@@ -293,5 +294,5 @@ int main(int argc, char *argv[]) {
           /* make the y axis vectors */
           for (i_ycol = 0; i_ycol < ycolList.count(); ++i_ycol ) {
-            //for (ycol = ycolList.begin(); ycol != ycolList.end(); ++ycol ) {
+            /*for (ycol = ycolList.begin(); ycol != ycolList.end(); ++ycol ) */
             yvector = CreateVector(*(ycolList.at(i_ycol)), file, in);
 
@@ -461,12 +462,16 @@ int main(int argc, char *argv[]) {
 
     if (print_and_exit) {
+      delete kst;
       exit(0);
     } else {
       args->clear();
+      app.setMainWidget(kst);
       kst->show();
     }
-
+    // LEAVE THIS HERE - causes crashes otherwise!
+    int rc = app.exec();
+    delete kst; 
+    return rc;
   }
-
-  return app.exec();
+return app.exec();
 }




More information about the Kst mailing list