[Kst] branches/work/kst/portto4/kst/src/libkst

Peter Kümmel syntheticpp at gmx.net
Sun Oct 7 20:02:09 UTC 2012


SVN commit 1319589 by kuemmel:

add message box when ::resize fails

We hit a limit of resize in win32 release builds.
When resize fails (because of memory fragmentation?)
show at least a message box about the failed memory handling.

 M  +6 -2      datamatrix.cpp  
 M  +2 -0      datasourcepluginmanager.cpp  
 M  +3 -2      datavector.cpp  
 M  +3 -1      matrix.cpp  
 M  +10 -0     primitive.cpp  
 M  +2 -0      primitive.h  


--- branches/work/kst/portto4/kst/src/libkst/datamatrix.cpp #1319588:1319589
@@ -218,7 +218,9 @@
   if (requiredSize != _zSize) {
     bool resizeOK = resizeZ(requiredSize);
     if (!resizeOK) {
-      abort(); // FIXME: what to do?
+      // TODO: Is aborting all we can do?
+      fatalError("Not enough memory for matrix data");
+      return;
     }
   }
 
@@ -305,7 +307,9 @@
   if (requiredSize != _zSize) {
     bool resizeOK = resizeZ(requiredSize);
     if (!resizeOK) {
-      abort(); // FIXME: what to do?
+      // TODO: Is aborting all we can do?
+      fatalError("Not enough memory for matrix data");
+      return;
     }
   }
   // read new data from file
--- branches/work/kst/portto4/kst/src/libkst/datasourcepluginmanager.cpp #1319588:1319589
@@ -61,8 +61,10 @@
   rootDir.cdUp();
   path = rootDir.canonicalPath() + '/';
   path += QLatin1String(KST_INSTALL_PLUGINS);
+  // Visal Studio paths
   pluginPaths << path + QLatin1String("/Release");
   pluginPaths << path + QLatin1String("/Debug");
+  pluginPaths << path + QLatin1String("/RelWithDebInfo");
 
   Debug::self()->log(QString("\nPlugin Search Pathes:"));
   foreach(const QString& p, pluginPaths) {
--- branches/work/kst/portto4/kst/src/libkst/datavector.cpp #1319588:1319589
@@ -544,8 +544,9 @@
     if ((new_nf - 1)*SPF + 1 != _size) {
       bool rc = resize((new_nf - 1)*SPF + 1);
       if (!rc) {
-        // FIXME: handle failed resize
-        abort();
+        // TODO: Is aborting all we can do?
+        fatalError("Not enough memory for vector data");
+        return;
       }
     }
 
--- branches/work/kst/portto4/kst/src/libkst/matrix.cpp #1319588:1319589
@@ -479,7 +479,9 @@
 #endif
     }
 #else
-    abort();  // avoid unpleasant surprises
+    // TODO: Is aborting all we can do?
+    fatalError("Not enough memory for matrix data");
+    return false;
 #endif
     _zSize = sz;
     updateScalars();
--- branches/work/kst/portto4/kst/src/libkst/primitive.cpp #1319588:1319589
@@ -19,6 +19,7 @@
 //#define UPDATEDEBUG
 #include "primitive.h"
 #include <QDebug>
+#include <QMessageBox>
 
 #include <limits.h>
 
@@ -95,8 +96,17 @@
 }
 
 
+void Primitive::fatalError(const QString& msg)
+{
+  QString message = msg;
+  QMessageBox::StandardButton btn = QMessageBox::critical(0, "A fatal error occurred", message, QMessageBox::Abort);
+  if (btn == QMessageBox::Abort) {
+    exit(-2);
+  }
+}
 
 
+
 }
 
 // vim: et sw=2 ts=2
--- branches/work/kst/portto4/kst/src/libkst/primitive.h #1319588:1319589
@@ -75,6 +75,8 @@
     virtual qint64 minInputSerial() const;
     virtual qint64 maxInputSerialOfLastChange() const;
 
+    virtual void fatalError(const QString& msg);
+
   protected:
     /** Possibly null.  Be careful, this is non-standard usage of a KstShared.
      * FIXME: pretty sure this is wrong: it shouldn't be a qpointer... not sure


More information about the Kst mailing list