From: azv Date: Mon, 24 Jun 2019 14:10:05 +0000 (+0300) Subject: Fix crashes in unit tests (produced by stack of transactions) X-Git-Tag: VEDF2019Lot4~101^2~19 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=86ba0ec3056d8ee6f39bbd81d040af90933861b2;p=modules%2Fshaper.git Fix crashes in unit tests (produced by stack of transactions) --- diff --git a/src/FeaturesPlugin/Test/TestPlacement_Edge_Edge.py b/src/FeaturesPlugin/Test/TestPlacement_Edge_Edge.py index e0c262dd0..317c16f84 100644 --- a/src/FeaturesPlugin/Test/TestPlacement_Edge_Edge.py +++ b/src/FeaturesPlugin/Test/TestPlacement_Edge_Edge.py @@ -133,7 +133,6 @@ aSession.finishOperation() assert (len(aPlacementFt.results()) > 0) aPlacementResult = modelAPI_ResultBody(aPlacementFt.firstResult()) assert (aPlacementResult is not None) -aSession.finishOperation() from salome.shaper import model assert(model.checkPythonDump()) diff --git a/src/FeaturesPlugin/Test/TestPlacement_Edge_Vertex.py b/src/FeaturesPlugin/Test/TestPlacement_Edge_Vertex.py index d5315e6b7..197e344d3 100644 --- a/src/FeaturesPlugin/Test/TestPlacement_Edge_Vertex.py +++ b/src/FeaturesPlugin/Test/TestPlacement_Edge_Vertex.py @@ -133,7 +133,6 @@ aSession.finishOperation() assert (len(aPlacementFt.results()) > 0) aPlacementResult = modelAPI_ResultBody(aPlacementFt.firstResult()) assert (aPlacementResult is not None) -aSession.finishOperation() from salome.shaper import model assert(model.checkPythonDump()) diff --git a/src/FeaturesPlugin/Test/TestPlacement_Face_Edge.py b/src/FeaturesPlugin/Test/TestPlacement_Face_Edge.py index 5cdaeff55..85e121d3a 100644 --- a/src/FeaturesPlugin/Test/TestPlacement_Face_Edge.py +++ b/src/FeaturesPlugin/Test/TestPlacement_Face_Edge.py @@ -133,7 +133,6 @@ aSession.finishOperation() assert (len(aPlacementFt.results()) > 0) aPlacementResult = modelAPI_ResultBody(aPlacementFt.firstResult()) assert (aPlacementResult is not None) -aSession.finishOperation() from salome.shaper import model assert(model.checkPythonDump()) diff --git a/src/FeaturesPlugin/Test/TestPlacement_Face_Face.py b/src/FeaturesPlugin/Test/TestPlacement_Face_Face.py index edcfc7bce..8b34dc5bf 100644 --- a/src/FeaturesPlugin/Test/TestPlacement_Face_Face.py +++ b/src/FeaturesPlugin/Test/TestPlacement_Face_Face.py @@ -133,7 +133,6 @@ aSession.finishOperation() assert (len(aPlacementFt.results()) > 0) aPlacementResult = modelAPI_ResultBody(aPlacementFt.firstResult()) assert (aPlacementResult is not None) -aSession.finishOperation() from salome.shaper import model assert(model.checkPythonDump()) diff --git a/src/FeaturesPlugin/Test/TestPlacement_Face_Vertex.py b/src/FeaturesPlugin/Test/TestPlacement_Face_Vertex.py index e7ee2f835..31d3ed87a 100644 --- a/src/FeaturesPlugin/Test/TestPlacement_Face_Vertex.py +++ b/src/FeaturesPlugin/Test/TestPlacement_Face_Vertex.py @@ -133,7 +133,6 @@ aSession.finishOperation() assert (len(aPlacementFt.results()) > 0) aPlacementResult = modelAPI_ResultBody(aPlacementFt.firstResult()) assert (aPlacementResult is not None) -aSession.finishOperation() from salome.shaper import model assert(model.checkPythonDump()) diff --git a/src/Model/Model_Session.cpp b/src/Model/Model_Session.cpp index afdf7e4a5..aed8b486a 100644 --- a/src/Model/Model_Session.cpp +++ b/src/Model/Model_Session.cpp @@ -98,12 +98,14 @@ void Model_Session::finishOperation() { setCheckTransactions(false); ROOT_DOC->finishOperation(); - while(myOperationAttachedToNext.back()) { - // with nested, the first transaction can not be attached - ROOT_DOC->finishOperation(); + if (!myOperationAttachedToNext.empty()) { + while (myOperationAttachedToNext.back()) { + // with nested, the first transaction can not be attached + ROOT_DOC->finishOperation(); + myOperationAttachedToNext.pop_back(); + } myOperationAttachedToNext.pop_back(); } - myOperationAttachedToNext.pop_back(); setCheckTransactions(true); } @@ -111,12 +113,14 @@ void Model_Session::abortOperation() { setCheckTransactions(false); ROOT_DOC->abortOperation(); - while(myOperationAttachedToNext.back()) { - // with nested, the first transaction can not be attached - ROOT_DOC->abortOperation(); + if (!myOperationAttachedToNext.empty()) { + while (myOperationAttachedToNext.back()) { + // with nested, the first transaction can not be attached + ROOT_DOC->abortOperation(); + myOperationAttachedToNext.pop_back(); + } myOperationAttachedToNext.pop_back(); } - myOperationAttachedToNext.pop_back(); setCheckTransactions(true); // here the update mechanism may work after abort, so, suppress the warnings about // modifications outside of the transactions