]> OCCT Git - occt-copy.git/commitdiff
0022738: Exception on destruction of Graphic3d_Structure
authorAPL <>
Fri, 30 Sep 2011 06:56:53 +0000 (06:56 +0000)
committerbugmaster <bugmaster@opencascade.com>
Mon, 5 Mar 2012 15:30:36 +0000 (19:30 +0400)
src/Graphic3d/Graphic3d_Group.cdl
src/Graphic3d/Graphic3d_Group_1.cxx
src/Graphic3d/Graphic3d_Structure.cxx

index 5f7f17cb6d95c7758b972d3c55d6d392374a8d29..60dbafa9687d16d3447581a90c02d26fd2c23237 100755 (executable)
         -- Category: Methods to modify the class definition
         ---------------------------------------------------
     
-        Clear ( me  : mutable )
+        Clear ( me  : mutable;
+                theUpdateStructureMgr : Boolean from Standard = Standard_True )
             is static;
         ---Level: Public
         ---Purpose: Supress all primitives and attributes of <me>.
+        --          To clear group without update in Graphic3d_StructureManager
+        --          pass Standard_False as <theUpdateStructureMgr>. This
+        --          used on context and viewer destruction, when the pointer
+        --          to structure manager in Graphic3d_Structure could be 
+        --          already released (pointers are used here to avoid handle 
+        --          cross-reference);
         ---Category: Methods to modify the class definition
     
         Destroy ( me    : mutable )
index 49110918bbbd12fb6ebe9a6a71b14747dd91edbf..43a255ea93ddab853998868e97c4440911af278b 100755 (executable)
 
 //-Methods, in order
 
-void Graphic3d_Group::Clear () {
-
-       if (IsDeleted ()) return;
-
-       MyCGroup.ContextLine.IsSet      = 0,
-       MyCGroup.ContextText.IsSet      = 0,
-       MyCGroup.ContextMarker.IsSet    = 0,
-       MyCGroup.ContextFillArea.IsSet  = 0;
+void Graphic3d_Group::Clear (Standard_Boolean theUpdateStructureMgr)
+{
+  if (IsDeleted ()) return;
 
-       MyCGroup.ContextLine.IsDef      = 0,
-       MyCGroup.ContextText.IsDef      = 0,
-       MyCGroup.ContextMarker.IsDef    = 0,
-       MyCGroup.ContextFillArea.IsDef  = 0;
+  MyCGroup.ContextLine.IsSet     = 0,
+  MyCGroup.ContextText.IsSet     = 0,
+  MyCGroup.ContextMarker.IsSet   = 0,
+  MyCGroup.ContextFillArea.IsSet = 0;
 
-       MyCGroup.PickId.IsDef           = 0,
-       MyCGroup.PickId.IsSet           = 0,
-       MyCGroup.PickId.Value           = 0;
+  MyCGroup.ContextLine.IsDef     = 0,
+  MyCGroup.ContextText.IsDef     = 0,
+  MyCGroup.ContextMarker.IsDef   = 0,
+  MyCGroup.ContextFillArea.IsDef = 0;
 
-       MyBounds.XMin   = ShortRealLast (),
-       MyBounds.YMin   = ShortRealLast (),
-       MyBounds.ZMin   = ShortRealLast ();
+  MyCGroup.PickId.IsDef = 0,
+  MyCGroup.PickId.IsSet = 0,
+  MyCGroup.PickId.Value = 0;
 
-       MyBounds.XMax   = ShortRealFirst (),
-       MyBounds.YMax   = ShortRealFirst (),
-       MyBounds.ZMax   = ShortRealFirst ();
+  MyBounds.XMin        = ShortRealLast (),
+  MyBounds.YMin        = ShortRealLast (),
+  MyBounds.ZMin        = ShortRealLast ();
 
-       if (MyContainsFacet) MyStructure->GroupsWithFacet (-1);
-       MyContainsFacet = Standard_False,
-       MyIsEmpty       = Standard_True;
+  MyBounds.XMax        = ShortRealFirst (),
+  MyBounds.YMax        = ShortRealFirst (),
+  MyBounds.ZMax        = ShortRealFirst ();
 
-       MyGraphicDriver->ClearGroup (MyCGroup);
+  if (MyContainsFacet) MyStructure->GroupsWithFacet (-1);
+  MyContainsFacet = Standard_False,
+  MyIsEmpty       = Standard_True;
 
-       Update ();
+  MyGraphicDriver->ClearGroup (MyCGroup);
 
+  // clear method could be used on Graphic3d_Structure destruction,
+  // and its structure manager could be already destroyed, in that
+  // case we don't need to update it;
+  if (theUpdateStructureMgr)
+    Update ();
 }
 
 void Graphic3d_Group::Destroy () {
index 534d547e1b56d825fdbe5ade0c78c601749fbe01..6d580f1dd0d419a33a9a407f571f57539e005e81 100755 (executable)
@@ -261,10 +261,14 @@ void Graphic3d_Structure::Remove () {
 
   Standard_Integer i, Length;
 
-  // clean groups in graphics driver at first
+  // clean groups in graphics driver at first; this is also should be done
+  // to avoid unwanted group cleaning in group's destructor
+  // Pass Standard_False to Clear(..) method to avoid updating in
+  // structure manager, it isn't necessary, besides of it structure manager
+  // could be already destroyed and invalid pointers used in structure;
   Length = MyGroups.Length();
   for (Standard_Integer aGrId = 1; aGrId <= Length; ++aGrId)
-    MyGroups.ChangeValue (aGrId)->Clear();
+    MyGroups.ChangeValue (aGrId)->Clear (Standard_False);
 
   //        Standard_Address APtr = (void *) This ().operator->();
   Standard_Address APtr = (void *) this;