From c66be58262719b6f899bf670b6fcd8a93e014122 Mon Sep 17 00:00:00 2001 From: =?utf8?q?C=C3=A9dric=20Aguerre?= Date: Wed, 2 Nov 2016 14:06:42 +0100 Subject: [PATCH] KW10744 - Workaround for object deletion --- src/PV_SWIG/presentations.py | 12 ++++++++++-- test/VisuPrs/3D_viewer/B2.py | 6 +++--- test/VisuPrs/SWIG_scripts/A4.py | 12 ++++++------ test/VisuPrs/SWIG_scripts/A5.py | 2 +- test/VisuPrs/SWIG_scripts/A6.py | 2 +- test/VisuPrs/SWIG_scripts/A9.py | 4 ++-- test/VisuPrs/SWIG_scripts/B1.py | 12 ++++++------ test/VisuPrs/SWIG_scripts/B5.py | 4 ++-- test/VisuPrs/SWIG_scripts/B6.py | 2 +- test/VisuPrs/SWIG_scripts/B7.py | 2 +- test/VisuPrs/SWIG_scripts/B9.py | 4 ++-- test/VisuPrs/SWIG_scripts/C6.py | 2 +- test/VisuPrs/Tables/A0.py | 2 +- test/VisuPrs/Tables/A2.py | 2 +- test/VisuPrs/Util/paravistest.py | 3 ++- test/VisuPrs/bugs/C8.py | 2 +- test/VisuPrs/bugs/C9.py | 2 +- test/VisuPrs/bugs/D5.py | 2 +- test/VisuPrs/dump_study/A0.py | 2 +- test/VisuPrs/dump_study/A1.py | 2 +- test/VisuPrs/dump_study/A2.py | 2 +- test/VisuPrs/dump_study/A3.py | 2 +- test/VisuPrs/dump_study/A4.py | 2 +- test/VisuPrs/dump_study/A5.py | 2 +- test/VisuPrs/dump_study/A6.py | 2 +- test/VisuPrs/dump_study/A8.py | 2 +- test/VisuPrs/dump_study/A9.py | 2 +- test/VisuPrs/dump_study/B0.py | 8 +++----- test/VisuPrs/dump_study/B1.py | 2 +- test/VisuPrs/dump_study/B3.py | 2 +- test/VisuPrs/dump_study/B4.py | 2 +- test/VisuPrs/dump_study/B5.py | 3 ++- 32 files changed, 60 insertions(+), 52 deletions(-) diff --git a/src/PV_SWIG/presentations.py b/src/PV_SWIG/presentations.py index b795657c..11ea19c8 100644 --- a/src/PV_SWIG/presentations.py +++ b/src/PV_SWIG/presentations.py @@ -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() diff --git a/test/VisuPrs/3D_viewer/B2.py b/test/VisuPrs/3D_viewer/B2.py index db1dfcd9..95940634 100644 --- a/test/VisuPrs/3D_viewer/B2.py +++ b/test/VisuPrs/3D_viewer/B2.py @@ -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() diff --git a/test/VisuPrs/SWIG_scripts/A4.py b/test/VisuPrs/SWIG_scripts/A4.py index 39f5d6f7..63b7f51b 100644 --- a/test/VisuPrs/SWIG_scripts/A4.py +++ b/test/VisuPrs/SWIG_scripts/A4.py @@ -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() diff --git a/test/VisuPrs/SWIG_scripts/A5.py b/test/VisuPrs/SWIG_scripts/A5.py index cb8edcc8..66fa366f 100644 --- a/test/VisuPrs/SWIG_scripts/A5.py +++ b/test/VisuPrs/SWIG_scripts/A5.py @@ -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 ]' diff --git a/test/VisuPrs/SWIG_scripts/A6.py b/test/VisuPrs/SWIG_scripts/A6.py index d63269d2..c864e239 100644 --- a/test/VisuPrs/SWIG_scripts/A6.py +++ b/test/VisuPrs/SWIG_scripts/A6.py @@ -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) diff --git a/test/VisuPrs/SWIG_scripts/A9.py b/test/VisuPrs/SWIG_scripts/A9.py index e597187c..1319c4a7 100644 --- a/test/VisuPrs/SWIG_scripts/A9.py +++ b/test/VisuPrs/SWIG_scripts/A9.py @@ -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 diff --git a/test/VisuPrs/SWIG_scripts/B1.py b/test/VisuPrs/SWIG_scripts/B1.py index 103af939..6a922731 100644 --- a/test/VisuPrs/SWIG_scripts/B1.py +++ b/test/VisuPrs/SWIG_scripts/B1.py @@ -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 diff --git a/test/VisuPrs/SWIG_scripts/B5.py b/test/VisuPrs/SWIG_scripts/B5.py index 6c5da613..c720eaf9 100644 --- a/test/VisuPrs/SWIG_scripts/B5.py +++ b/test/VisuPrs/SWIG_scripts/B5.py @@ -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 diff --git a/test/VisuPrs/SWIG_scripts/B6.py b/test/VisuPrs/SWIG_scripts/B6.py index 20dcca05..4bceb75a 100644 --- a/test/VisuPrs/SWIG_scripts/B6.py +++ b/test/VisuPrs/SWIG_scripts/B6.py @@ -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' diff --git a/test/VisuPrs/SWIG_scripts/B7.py b/test/VisuPrs/SWIG_scripts/B7.py index a425c443..0572304f 100644 --- a/test/VisuPrs/SWIG_scripts/B7.py +++ b/test/VisuPrs/SWIG_scripts/B7.py @@ -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) diff --git a/test/VisuPrs/SWIG_scripts/B9.py b/test/VisuPrs/SWIG_scripts/B9.py index 8113b836..f38c9c8c 100644 --- a/test/VisuPrs/SWIG_scripts/B9.py +++ b/test/VisuPrs/SWIG_scripts/B9.py @@ -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(): diff --git a/test/VisuPrs/SWIG_scripts/C6.py b/test/VisuPrs/SWIG_scripts/C6.py index 5dea829b..696a290b 100644 --- a/test/VisuPrs/SWIG_scripts/C6.py +++ b/test/VisuPrs/SWIG_scripts/C6.py @@ -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 diff --git a/test/VisuPrs/Tables/A0.py b/test/VisuPrs/Tables/A0.py index fcdf68ff..ee40126d 100755 --- a/test/VisuPrs/Tables/A0.py +++ b/test/VisuPrs/Tables/A0.py @@ -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) diff --git a/test/VisuPrs/Tables/A2.py b/test/VisuPrs/Tables/A2.py index c719dcab..155b8595 100755 --- a/test/VisuPrs/Tables/A2.py +++ b/test/VisuPrs/Tables/A2.py @@ -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) diff --git a/test/VisuPrs/Util/paravistest.py b/test/VisuPrs/Util/paravistest.py index 0df553cc..663f4598 100755 --- a/test/VisuPrs/Util/paravistest.py +++ b/test/VisuPrs/Util/paravistest.py @@ -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""" diff --git a/test/VisuPrs/bugs/C8.py b/test/VisuPrs/bugs/C8.py index ff2bf376..139b5dc0 100644 --- a/test/VisuPrs/bugs/C8.py +++ b/test/VisuPrs/bugs/C8.py @@ -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" diff --git a/test/VisuPrs/bugs/C9.py b/test/VisuPrs/bugs/C9.py index 693a1557..ca4ca478 100644 --- a/test/VisuPrs/bugs/C9.py +++ b/test/VisuPrs/bugs/C9.py @@ -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() diff --git a/test/VisuPrs/bugs/D5.py b/test/VisuPrs/bugs/D5.py index 0ab78541..35e340b5 100644 --- a/test/VisuPrs/bugs/D5.py +++ b/test/VisuPrs/bugs/D5.py @@ -64,4 +64,4 @@ for table_nb in range(0, tables_count): lookup_table, "") reset_view() - pvsimple.Delete(bar) + delete_pv_object(bar) diff --git a/test/VisuPrs/dump_study/A0.py b/test/VisuPrs/dump_study/A0.py index 6ca008c6..327379d5 100644 --- a/test/VisuPrs/dump_study/A0.py +++ b/test/VisuPrs/dump_study/A0.py @@ -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 diff --git a/test/VisuPrs/dump_study/A1.py b/test/VisuPrs/dump_study/A1.py index 80226504..f1725d3c 100644 --- a/test/VisuPrs/dump_study/A1.py +++ b/test/VisuPrs/dump_study/A1.py @@ -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 diff --git a/test/VisuPrs/dump_study/A2.py b/test/VisuPrs/dump_study/A2.py index b8fb5783..c2092c3c 100644 --- a/test/VisuPrs/dump_study/A2.py +++ b/test/VisuPrs/dump_study/A2.py @@ -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 diff --git a/test/VisuPrs/dump_study/A3.py b/test/VisuPrs/dump_study/A3.py index 67cf245f..e5bf8f77 100644 --- a/test/VisuPrs/dump_study/A3.py +++ b/test/VisuPrs/dump_study/A3.py @@ -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 diff --git a/test/VisuPrs/dump_study/A4.py b/test/VisuPrs/dump_study/A4.py index 1076346b..fcea7616 100644 --- a/test/VisuPrs/dump_study/A4.py +++ b/test/VisuPrs/dump_study/A4.py @@ -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 diff --git a/test/VisuPrs/dump_study/A5.py b/test/VisuPrs/dump_study/A5.py index 3c830d26..af97474e 100644 --- a/test/VisuPrs/dump_study/A5.py +++ b/test/VisuPrs/dump_study/A5.py @@ -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 diff --git a/test/VisuPrs/dump_study/A6.py b/test/VisuPrs/dump_study/A6.py index e5613916..249cc22e 100644 --- a/test/VisuPrs/dump_study/A6.py +++ b/test/VisuPrs/dump_study/A6.py @@ -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 diff --git a/test/VisuPrs/dump_study/A8.py b/test/VisuPrs/dump_study/A8.py index ab9580a5..38c27eed 100644 --- a/test/VisuPrs/dump_study/A8.py +++ b/test/VisuPrs/dump_study/A8.py @@ -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 diff --git a/test/VisuPrs/dump_study/A9.py b/test/VisuPrs/dump_study/A9.py index 23dba938..fda0b94a 100644 --- a/test/VisuPrs/dump_study/A9.py +++ b/test/VisuPrs/dump_study/A9.py @@ -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 diff --git a/test/VisuPrs/dump_study/B0.py b/test/VisuPrs/dump_study/B0.py index fcea366a..c9809480 100644 --- a/test/VisuPrs/dump_study/B0.py +++ b/test/VisuPrs/dump_study/B0.py @@ -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..." - - diff --git a/test/VisuPrs/dump_study/B1.py b/test/VisuPrs/dump_study/B1.py index 9fc42575..42a7f5b7 100644 --- a/test/VisuPrs/dump_study/B1.py +++ b/test/VisuPrs/dump_study/B1.py @@ -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) diff --git a/test/VisuPrs/dump_study/B3.py b/test/VisuPrs/dump_study/B3.py index a497c918..c1d21298 100644 --- a/test/VisuPrs/dump_study/B3.py +++ b/test/VisuPrs/dump_study/B3.py @@ -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) diff --git a/test/VisuPrs/dump_study/B4.py b/test/VisuPrs/dump_study/B4.py index a0425170..6db45cba 100644 --- a/test/VisuPrs/dump_study/B4.py +++ b/test/VisuPrs/dump_study/B4.py @@ -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) diff --git a/test/VisuPrs/dump_study/B5.py b/test/VisuPrs/dump_study/B5.py index 85edfa8d..cd54ea55 100644 --- a/test/VisuPrs/dump_study/B5.py +++ b/test/VisuPrs/dump_study/B5.py @@ -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') -- 2.39.2