From c0feddaa3edef4ba83d5ad4136e166d7b49ce564 Mon Sep 17 00:00:00 2001 From: nds Date: Fri, 31 Jan 2014 11:06:34 +0000 Subject: [PATCH] Crash on QStack top() call without the empty of the stack check. New study, edit some object, Close, open new study, edit, close ->crash. --- src/HYDROGUI/HYDROGUI_Operation.cxx | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) 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 -- 2.39.2