]> SALOME platform Git repositories - modules/paravis.git/commitdiff
Salome HOME
KW10744 - Workaround for object deletion
authorCédric Aguerre <cedric.aguerre@edf.fr>
Wed, 2 Nov 2016 13:06:42 +0000 (14:06 +0100)
committerCédric Aguerre <cedric.aguerre@edf.fr>
Wed, 2 Nov 2016 13:06:42 +0000 (14:06 +0100)
32 files changed:
src/PV_SWIG/presentations.py
test/VisuPrs/3D_viewer/B2.py
test/VisuPrs/SWIG_scripts/A4.py
test/VisuPrs/SWIG_scripts/A5.py
test/VisuPrs/SWIG_scripts/A6.py
test/VisuPrs/SWIG_scripts/A9.py
test/VisuPrs/SWIG_scripts/B1.py
test/VisuPrs/SWIG_scripts/B5.py
test/VisuPrs/SWIG_scripts/B6.py
test/VisuPrs/SWIG_scripts/B7.py
test/VisuPrs/SWIG_scripts/B9.py
test/VisuPrs/SWIG_scripts/C6.py
test/VisuPrs/Tables/A0.py
test/VisuPrs/Tables/A2.py
test/VisuPrs/Util/paravistest.py
test/VisuPrs/bugs/C8.py
test/VisuPrs/bugs/C9.py
test/VisuPrs/bugs/D5.py
test/VisuPrs/dump_study/A0.py
test/VisuPrs/dump_study/A1.py
test/VisuPrs/dump_study/A2.py
test/VisuPrs/dump_study/A3.py
test/VisuPrs/dump_study/A4.py
test/VisuPrs/dump_study/A5.py
test/VisuPrs/dump_study/A6.py
test/VisuPrs/dump_study/A8.py
test/VisuPrs/dump_study/A9.py
test/VisuPrs/dump_study/B0.py
test/VisuPrs/dump_study/B1.py
test/VisuPrs/dump_study/B3.py
test/VisuPrs/dump_study/B4.py
test/VisuPrs/dump_study/B5.py

index b795657c2ffb185db3857d67cb0a8689c33e839a..11ea19c8ecdad868a9c22b51d7706315ee3993d5 100644 (file)
@@ -1557,7 +1557,7 @@ def VectorsOnField(proxy, entity, field_name, timestamp_nb,
         lookup_table.LockScalarRange = 1
     else:
         raise RuntimeError("Object %s has no 'LockDataRange' or 'LockScalarRange' attribute!"%(lookup_table))
-    
+
     lookup_table.RGBPoints = [data_range[0], 0, 0, 1, data_range[1], 1, 0, 0]
 
     # Set properties
@@ -2045,7 +2045,7 @@ def IsoSurfacesOnField(proxy, entity, field_name, timestamp_nb,
     if (scalar_range is None):
         scalar_range = get_data_range(proxy, entity,
                                       field_name, cut_off=True)
-        
+
     # Get contour values for the range
     surfaces = get_contours(scalar_range, nb_surfaces)
 
@@ -2747,3 +2747,11 @@ def CreatePrsForProxy(proxy, view, prs_types, picture_dir, picture_ext):
                     # Show and dump the presentation into a graphics file
                     process_prs_for_test(prs, view, pic_name)
     return
+
+
+def delete_pv_object(obj):
+  # There is a bug when repeating CreateRenderView/Delete calls
+  # Here is a workaround proposed by KW (#10744)
+  import gc
+  del obj
+  gc.collect()
index db1dfcd930362fa78e805d8aabffe6ad5c102c43..95940634b6cd90c7022287756dcd67a87043cf65 100644 (file)
@@ -41,15 +41,15 @@ Render(my_view)
 
 # Split
 a_view_r = CreateRenderView()
-Delete(a_view_r)
+delete_pv_object(a_view_r)
 
 # Split
 a_view_l = CreateRenderView()
-Delete(a_view_l)
+delete_pv_object(a_view_l)
 
 # Split
 a_view_t = CreateRenderView()
-Delete(a_view_t)
+delete_pv_object(a_view_t)
 
 # Split
 a_view_b = CreateRenderView()
index 39f5d6f7866e18b63fd0a7fdb77dddbe761c5b36..63b7f51baefd0c7d2a6464f0ae0428ad2174c315 100644 (file)
@@ -34,7 +34,7 @@ view = pvsimple.GetRenderView()
 sleep(DELAY)
 
 # Destroy the view
-pvsimple.Delete(view)
+delete_pv_object(view)
 
 
 # Create view and set background
@@ -96,7 +96,7 @@ sleep(DELAY)
 
 # Destroy the view
 print "Destroy the view with Scalar Map"
-pvsimple.Delete(view)
+delete_pv_object(view)
 
 
 # Create another view for cut planes
@@ -159,7 +159,7 @@ sleep(DELAY)
 
 # Destroy the view
 print "Destroy the view with Cut Planes"
-pvsimple.Delete(view)
+delete_pv_object(view)
 
 
 # Create one more view for isosurfaces
@@ -196,7 +196,7 @@ sleep(DELAY)
 
 # Destroy the view
 print "Destroy the view with Iso Surfaces"
-pvsimple.Delete(view)
+delete_pv_object(view)
 
 
 # Create one more view for cut lines
@@ -240,8 +240,8 @@ sleep(DELAY)
 
 # Destroy two views
 #print "Destroy two views: with Cut Lines and the curves"
-#pvsimple.Delete(view)
-#pvsimple.Delete(xy_view)
+#delete_pv_object(view)
+#delete_pv_object(xy_view)
 
 # Create one more view for animation
 view = pvsimple.CreateRenderView()
index cb8edcc894d6fab7aba3d6b9bc3539712560e60f..66fa366f8193582a4902a2e80282951359b9ddd5 100644 (file)
@@ -66,7 +66,7 @@ ps.UpdatePipeline()
 # Display curves
 cur_view = pvsimple.GetRenderView()
 if cur_view:
-    pvsimple.Delete(cur_view)
+    delete_pv_object(cur_view)
 xy_view = pvsimple.CreateXYPlotView()
 xy_view.ChartTitle = 'Very useful data'
 xy_view.BottomAxisTitle = '[ Wt ]'
index d63269d2c25746531ce35f7c9a749153fade185d..c864e239c053f0cdecf8e8b56e00348e73affbc9 100644 (file)
@@ -37,7 +37,7 @@ sinus_csv.HaveHeaders = 1
 # Display curve
 cur_view = pvsimple.GetRenderView()
 if cur_view:
-    pvsimple.Delete(cur_view)
+    delete_pv_object(cur_view)
 xy_view = pvsimple.CreateXYPlotView()
 
 xy_rep = pvsimple.Show(sinus_csv)
index e597187c197b51ef426fc4a33f645b421c4cec3e..1319c4a7aab9834a1b64e5340ea23d2dcbe93ead 100644 (file)
@@ -20,7 +20,7 @@
 # This case corresponds to: /visu/SWIG_scripts/A9 case
 # Import MED file; create Scalar Map, Cut Planes, Cut Lines,
 # Cut Segment, Iso Surfaces, Animation; display curves.
+
 import math
 import random
 from time import sleep
@@ -45,7 +45,7 @@ view = pvs.GetRenderView()
 sleep(DELAY)
 
 # Destroy the view
-pvs.Delete(view)
+delete_pv_object(view)
 
 
 # Create view and set background
index 103af939ef68bfaf5f2cfd9706e8d63039830add..6a9227319f36eae28b3b443d4da9d24dd8c8c6f7 100644 (file)
@@ -34,7 +34,7 @@ view = pvsimple.GetRenderView()
 sleep(DELAY)
 
 # Destroy the view
-pvsimple.Delete(view)
+delete_pv_object(view)
 
 
 # Create view and set background
@@ -96,7 +96,7 @@ sleep(DELAY)
 
 # Destroy the view
 print "Destroy the view with Scalar Map"
-pvsimple.Delete(view)
+delete_pv_object(view)
 
 
 # Create another view for cut planes
@@ -159,7 +159,7 @@ sleep(DELAY)
 
 # Destroy the view
 print "Destroy the view with Cut Planes"
-pvsimple.Delete(view)
+delete_pv_object(view)
 
 
 # Create one more view for isosurfaces
@@ -196,7 +196,7 @@ sleep(DELAY)
 
 # Destroy the view
 print "Destroy the view with Iso Surfaces"
-pvsimple.Delete(view)
+delete_pv_object(view)
 
 
 # Create one more view for cut lines
@@ -240,8 +240,8 @@ sleep(DELAY)
 
 # Destroy two views
 #print "Destroy two views: with Cut Lines and the curves"
-#pvsimple.Delete(view)
-#pvsimple.Delete(xy_view)
+#delete_pv_object(view)
+#delete_pv_object(xy_view)
 
 
 # Create one more view for cut segment
index 6c5da6136fc872c70a665f75e8a6708b80cb7ace..c720eaf9006178a9a9a9b5387eedec6786cf804c 100644 (file)
@@ -49,8 +49,8 @@ print "view1 = pvsimple.GetRenderView()"
 
 sleep(DELAY)
 
-pvsimple.Delete(view1)
-print "pvsimple.Delete(view1)"
+delete_pv_object(view1)
+print "delete_pv_object(view1)"
 
 
 # Step 3
index 20dcca05fb33b86e6f38a2128981c0810bd96cc3..4bceb75a0fdde244891579899303aa773cd8f4ba 100644 (file)
@@ -94,7 +94,7 @@ ps_tr.UpdatePipeline()
 # Replace the current view with chart line one
 cur_view = pvsimple.GetRenderView()
 if cur_view:
-    pvsimple.Delete(cur_view)
+    delete_pv_object(cur_view)
 
 xy_view1 = pvsimple.CreateXYPlotView()
 xy_view1.ChartTitle = 'TEST table of real'
index a425c44365ec6c7d3e4ed625339f39af05690c0e..0572304f0b164f4361abd4dd47ac3c31c062ec92 100644 (file)
@@ -34,7 +34,7 @@ table_csv.FieldDelimiterCharacters = ';'
 # Display curve
 cur_view = pvsimple.GetRenderView()
 if cur_view:
-    pvsimple.Delete(cur_view)
+    delete_pv_object(cur_view)
 xy_view = pvsimple.CreateXYPlotView()
 
 xy_rep = pvsimple.Show(table_csv)
index 8113b8362073bca787ebcb8e2ae435bcede28981..f38c9c8c76a940ebfa26b65b8ea3d82899b20fdd 100644 (file)
@@ -45,8 +45,8 @@ pvsimple.ResetCamera(view2)
 
 # Delete
 source = cutlines.Input
-pvsimple.Delete(source)
-pvsimple.Delete(med_reader)
+delete_pv_object(source)
+delete_pv_object(med_reader)
 
 # Clear views from scalar bar and update views
 for rview in pvsimple.GetRenderViews():
index 5dea829be89309ee26e218b8b0c4fbadb44f7a17..696a290b5eaaa44321e28579054873dd285393a6 100644 (file)
@@ -33,7 +33,7 @@ if table_reader is None:
 # 2. Create curves viewer
 cur_view = pvsimple.GetRenderView()
 if cur_view:
-    pvsimple.Delete(cur_view)
+    delete_pv_object(cur_view)
 xy_view = pvsimple.CreateXYPlotView()
 
 # 3. Display curves in the viewer
index fcdf68ff5457a7c3a036ccab78655a3bcba19418..ee40126d35c048ff1669eb6e3388092729b81700 100755 (executable)
@@ -51,7 +51,7 @@ table_reader.UpdatePipeline()
 # Create curves
 cur_view = pvsimple.GetRenderView()
 if cur_view:
-    pvsimple.Delete(cur_view)
+    delete_pv_object(cur_view)
 xy_view = pvsimple.CreateXYPlotView()
 
 # xy_rep = pvsimple.Show(table_reader)
index c719dcaba8b53a2f09212133b0826850bef5c6a7..155b85955740ae59cd68f4eff60f93a105baa724 100755 (executable)
@@ -47,7 +47,7 @@ else:
 # Create curves
 cur_view = pvsimple.GetRenderView()
 if cur_view:
-    pvsimple.Delete(cur_view)
+    delete_pv_object(cur_view)
 xy_view = pvsimple.CreateXYPlotView()
 
 xy_rep = pvsimple.Show(table_reader)
index 0df553ccbbb04d2d4d8321bfe1d8896082e7f5e0..663f45986f681e4f50ab5972d5e97ade0d26a7ba 100755 (executable)
@@ -342,6 +342,7 @@ def Import_Med_Field(filename, field_names, check_errors=0, prs=[]):
 def delete_with_inputs(obj):
     """Deletes the given object with all its inputs"""
     import pvsimple
+    import presentations
 
     obj_to_delete = obj
     while obj_to_delete is not None:
@@ -350,7 +351,7 @@ def delete_with_inputs(obj):
         if hasattr(tmp_obj, 'Input'):
             obj_to_delete = tmp_obj.Input
 
-        pvsimple.Delete(tmp_obj)
+        presentations.delete_pv_object(tmp_obj)
 
 def get_png_picture_resolution(infile):
     """Returns size (width, height) of the PNG image"""
index ff2bf3760d9c6898519f43e53702eb94d456ce87..139b5dc05446e631c6e77b7198bf5ccf5f85b463 100644 (file)
@@ -38,7 +38,7 @@ else:
 # 2. Show curves
 cur_view = pvsimple.GetRenderView()
 if cur_view:
-    pvsimple.Delete(cur_view)
+    delete_pv_object(cur_view)
 
 xy_view = pvsimple.CreateXYPlotView()
 xy_view.ChartTitle = "The viewer for Curves from the Table"
index 693a1557b47e2eb080916b8f687a6db03b5b898d..ca4ca4783fb25ced3b671bfa4579b3702c5f4852 100644 (file)
@@ -50,5 +50,5 @@ if scalar_map is None :
 scalar_map.Visibility = 1
 pvsimple.Render()
 
-pvsimple.Delete(scalar_map)
+delete_pv_object(scalar_map)
 pvsimple.Render()
index 0ab78541959af54ed7650d11da8ef68d0cf31a6d..35e340b54c5543cc9f1f4d8036ae4bae21f6e389 100644 (file)
@@ -64,4 +64,4 @@ for table_nb in range(0, tables_count):
                          lookup_table, "")
 
     reset_view()
-    pvsimple.Delete(bar)
+    delete_pv_object(bar)
index 6ca008c6a26afd3e28a03ce762dd36c12b7e9488..327379d5d2c67c42e3e067c980e5cd3771648565 100644 (file)
@@ -70,7 +70,7 @@ save_trace( path_to_save, text )
 
 # 4. Delete the created objects, recreate the view
 delete_with_inputs(scalarmap)
-Delete(GetActiveView())
+delete_pv_object(GetActiveView())
 view = CreateRenderView()
 
 # 5. Execution of the created script
index 80226504cb27c640e7c891f875d16eca8837d470..f1725d3cb5498aa276f5218e66f2f4e7c6f95709 100644 (file)
@@ -76,7 +76,7 @@ save_trace( path_to_save, text )
 
 # 4. Delete the created objects, recreate the view
 delete_with_inputs(isosurfaces)
-Delete(GetActiveView())
+delete_pv_object(GetActiveView())
 view = CreateRenderView()
 
 # 5. Execution of the created script
index b8fb578343695782a728ee77b6abb5b4bde671cb..c2092c3c210d7291868de106675c8bab4e2da2be 100644 (file)
@@ -76,7 +76,7 @@ save_trace( path_to_save, text )
 
 # 4. Delete the created objects, recreate the view
 delete_with_inputs(cutplanes)
-Delete(GetActiveView())
+delete_pv_object(GetActiveView())
 view = CreateRenderView()
 
 # 5. Execution of the created script
index 67cf245f00b4d7d50e5051c7096d245a0a5ca872..e5bf8f77bc871814c45f85df1f0fc0a59a26fda8 100644 (file)
@@ -73,7 +73,7 @@ save_trace( path_to_save, text )
 
 # 4. Delete the created objects, recreate the view
 delete_with_inputs(deformedshape)
-Delete(GetActiveView())
+delete_pv_object(GetActiveView())
 view = CreateRenderView()
 
 # 5. Execution of the created script
index 1076346be23e49016ad6ae4084689dd39d0deada..fcea761675a685267685f9e4da465aa1bbbb494d 100644 (file)
@@ -68,7 +68,7 @@ save_trace( path_to_save, text )
 
 # 4. Delete the created objects, recreate the view
 delete_with_inputs(gausspoints)
-Delete(GetActiveView())
+delete_pv_object(GetActiveView())
 view = CreateRenderView()
 
 # 5. Execution of the created script
index 3c830d26489d867f1c68108b688c1a2b1cb8b203..af97474e1d9c3d1d9a736b32585fb2a24fb90915 100644 (file)
@@ -84,7 +84,7 @@ save_trace( path_to_save, text )
 
 # 4. Delete the created objects, recreate the view
 delete_with_inputs(plot3d)
-Delete(GetActiveView())
+delete_pv_object(GetActiveView())
 view = CreateRenderView()
 
 # 5. Execution of the created script
index e5613916c03e1d94ee61a8803f9a29b5ab3c124a..249cc22e63998f49f42d7130aee2d43be3c2c474 100644 (file)
@@ -73,7 +73,7 @@ save_trace( path_to_save, text )
 
 # 4. Delete the created objects, recreate the view
 delete_with_inputs(prs)
-Delete(GetActiveView())
+delete_pv_object(GetActiveView())
 view = CreateRenderView()
 
 # 5. Execution of the created script
index ab9580a53686b01d7c45a2b978d286eac34e929c..38c27eed51d21727d14bfb21daa15a15f2d24418 100644 (file)
@@ -79,7 +79,7 @@ save_trace( path_to_save, text )
 
 # 4. Delete the created objects, recreate the view
 delete_with_inputs(vectors)
-Delete(GetActiveView())
+delete_pv_object(GetActiveView())
 view = CreateRenderView()
 
 # 5. Execution of the created script
index 23dba938eba22e89c1d637d6513b6d4ea3c644f3..fda0b94a81125a3699c185fa11d457ccebe5442d 100644 (file)
@@ -87,7 +87,7 @@ save_trace( path_to_save, text )
 
 # 4. Delete the created objects, recreate the view
 delete_with_inputs(cutlines)
-Delete(GetActiveView())
+delete_pv_object(GetActiveView())
 view = CreateRenderView()
 
 # 5. Execution of the created script
index fcea366ad0cac8d9761b98cbfe687062daf52a68..c9809480bdf1b4c497e8a77a4c83c9d43af5679b 100644 (file)
@@ -54,7 +54,7 @@ for name in prs_names:
         prs = eval(name + "OnField(med_reader, EntityType.NODE, med_field, 1)")
     if prs is None:
         print "ERROR!!! ", name," presentation wasn't created..."
-       # StreamLines presentation is empty for "vitesse" field defined in the loaded MED file.
+        # StreamLines presentation is empty for "vitesse" field defined in the loaded MED file.
         # TODO: check why stream lines prs is empty
         if name == "StreamLines":
             print "WARNING: Stream lines presentation is empty!"
@@ -72,9 +72,9 @@ save_trace( path_to_save, text )
 # 4. Delete the created objects, recreate the view
 source_list = GetSources().values()
 for source in source_list:
-    Delete(source)
+    delete_pv_object(source)
 
-Delete(GetActiveView())
+delete_pv_object(GetActiveView())
 view = CreateRenderView()
 
 # 5. Execution of the created script
@@ -91,5 +91,3 @@ for name in prs_names:
 
 if errors > 0:
     raise RuntimeError, "There is(are) some error(s) was(were) found... For more info see ERRORs above..."
-
-
index 9fc42575d01b62de414b6480fe8020b5f6ec7b8c..42a7f5b7f48d6465ec14ca5117aaf862d1569e6b 100644 (file)
@@ -37,7 +37,7 @@ path_to_save = os.path.join(os.getenv("HOME"), "table.py")
 SaveTrace(path_to_save)
 
 # 3. Delete the created objects
-Delete(table_reader)
+delete_pv_object(table_reader)
 
 # 4. Execution of the created script
 execfile(path_to_save)
index a497c918a55df0ff708e9d8a9e1f910dd6c7bdaf..c1d21298d88be2d97121697e6263052b32586931 100644 (file)
@@ -80,7 +80,7 @@ path_to_save = os.path.join(os.getenv("HOME"), "table.py")
 save_trace( path_to_save, text )
 
 # 3. Delete the table
-Delete(table)
+delete_pv_object(table)
 
 # 4. Execution of the created script
 execfile(path_to_save)
index a0425170546cc08a3485eda172eaef3cc5abb271..6db45cba94e913fe9d6f0ba71c5772d0f2ca87f4 100644 (file)
@@ -81,7 +81,7 @@ path_to_save = os.path.join(os.getenv("HOME"), "table.py")
 save_trace( path_to_save, text )
 
 # 3. Delete the table
-Delete(table)
+delete_pv_object(table)
 
 # 4. Execution of the created script
 execfile(path_to_save)
index 85edfa8d2caf68b40a2d3ae6538aa12c8cdf2c5e..cd54ea5574aa38c7f8e098294af84e47648fde0a 100644 (file)
@@ -50,13 +50,14 @@ salome.myStudy = opened_study
 
 # 3. Find IsoSurfaces
 from pvsimple import *
+import presentations
 obj = FindSource('IsoSurfaces')
 if obj is None:
     print "FAILED: can't find IsoSurfaces!!!"
 
 # 4. Remove med reader object and all other sources
 for obj in GetSources().values():
-    Delete(obj)
+    presentations.delete_pv_object(obj)
 
 # 5. Check results
 obj = FindSource('ScalarMap')