]> SALOME platform Git repositories - modules/hydro.git/commitdiff
Salome HOME
Crash on QStack top() call without the empty of the stack check.
authornds <nds@opencascade.com>
Fri, 31 Jan 2014 11:06:34 +0000 (11:06 +0000)
committernds <nds@opencascade.com>
Fri, 31 Jan 2014 11:06:34 +0000 (11:06 +0000)
New study, edit some object, Close, open new study, edit, close ->crash.

src/HYDROGUI/HYDROGUI_Operation.cxx

index 5fe0773011920a6249b00a52e8eb911453bc1ebb..de64a1878949e6d968c2e113e507a4ecb668d272 100644 (file)
@@ -182,20 +182,21 @@ void HYDROGUI_Operation::stopOperation()
 
   // pop the operation from the cached map of active operations
   QStack<HYDROGUI_Operation*>& anOperations = myModule->getActiveOperations();
-  if ( anOperations.top() == this )
-  {
-    anOperations.pop();
-  }
-  else {
-    // find in the stack the current operation and remove it from the stack
-    QVectorIterator<HYDROGUI_Operation*> aVIt( anOperations );
-    aVIt.toBack();
-    aVIt.previous(); // skip the top show/hide operation
-    while ( aVIt.hasPrevious() )
+  if ( !anOperations.empty() ) {
+    if ( anOperations.top() == this )
+      anOperations.pop();
+    else
     {
-      HYDROGUI_Operation* anOp = aVIt.previous();
-      if ( anOp == this )
-        anOperations.remove( anOperations.lastIndexOf( anOp ) );
+      // find in the stack the current operation and remove it from the stack
+      QVectorIterator<HYDROGUI_Operation*> aVIt( anOperations );
+      aVIt.toBack();
+      aVIt.previous(); // skip the top show/hide operation
+      while ( aVIt.hasPrevious() )
+      {
+        HYDROGUI_Operation* anOp = aVIt.previous();
+        if ( anOp == this )
+          anOperations.remove( anOperations.lastIndexOf( anOp ) );
+      }
     }
   }
   // release the preview manager with removing the added preview Z layer