From 86ba0ec3056d8ee6f39bbd81d040af90933861b2 Mon Sep 17 00:00:00 2001 From: azv Date: Mon, 24 Jun 2019 17:10:05 +0300 Subject: [PATCH] Fix crashes in unit tests (produced by stack of transactions) --- .../Test/TestPlacement_Edge_Edge.py | 1 - .../Test/TestPlacement_Edge_Vertex.py | 1 - .../Test/TestPlacement_Face_Edge.py | 1 - .../Test/TestPlacement_Face_Face.py | 1 - .../Test/TestPlacement_Face_Vertex.py | 1 - src/Model/Model_Session.cpp | 20 +++++++++++-------- 6 files changed, 12 insertions(+), 13 deletions(-) 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 -- 2.39.2