From: nds Date: Fri, 31 Jan 2014 11:06:34 +0000 (+0000) Subject: Crash on QStack top() call without the empty of the stack check. X-Git-Tag: BR_hydro_v_1_0~8 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=c0feddaa3edef4ba83d5ad4136e166d7b49ce564;p=modules%2Fhydro.git Crash on QStack top() call without the empty of the stack check. New study, edit some object, Close, open new study, edit, close ->crash. --- diff --git a/src/HYDROGUI/HYDROGUI_Operation.cxx b/src/HYDROGUI/HYDROGUI_Operation.cxx index 5fe07730..de64a187 100644 --- a/src/HYDROGUI/HYDROGUI_Operation.cxx +++ b/src/HYDROGUI/HYDROGUI_Operation.cxx @@ -182,20 +182,21 @@ void HYDROGUI_Operation::stopOperation() // pop the operation from the cached map of active operations QStack& anOperations = myModule->getActiveOperations(); - if ( anOperations.top() == this ) - { - anOperations.pop(); - } - else { - // find in the stack the current operation and remove it from the stack - QVectorIterator 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 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