During load, restore callback functions of figure handle at the end 07/10607/2
Antoine ELIAS [Mon, 25 Feb 2013 16:40:54 +0000 (17:40 +0100)]
Change-Id: I24e65f00159b188d86a9f1ad1cce1f5582a9ceaa

scilab/modules/io/macros/%_sodload.sci
scilab/modules/io/tests/unit_tests/load_figure.dia.ref [new file with mode: 0644]
scilab/modules/io/tests/unit_tests/load_figure.tst [new file with mode: 0644]

index 8d4c3ae..ff6f7c4 100644 (file)
@@ -141,6 +141,8 @@ function %_sodload(%__filename__, varargin)
 
         h = gcf();
         isVisible = h.visible;
+        resizefcn = "";
+        event_handler = "";
         h.visible = "off";
 
         fields(fields=="figure_id") = [];
@@ -165,6 +167,10 @@ function %_sodload(%__filename__, varargin)
                     xsetech(wrect=[0 0 .1 .1])
                     createSingleHandle(c.values(i));
                 end
+            elseif fields(i) == "event_handler" then
+                event_handler = figureProperties(fields(i));
+            elseif fields(i) == "resizefcn" then
+                resizefcn = figureProperties(fields(i));
             elseif fields(i) == "visible" then
                 isVisible = figureProperties(fields(i));// do not set visible = "true" before the end of load.
             else
@@ -173,6 +179,8 @@ function %_sodload(%__filename__, varargin)
         end
 
         h.visible = isVisible;
+        h.resizefcn = resizefcn;
+        h.event_handler = event_handler;
     endfunction
 
     //
diff --git a/scilab/modules/io/tests/unit_tests/load_figure.dia.ref b/scilab/modules/io/tests/unit_tests/load_figure.dia.ref
new file mode 100644 (file)
index 0000000..3725c06
--- /dev/null
@@ -0,0 +1,16 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2013 - Scilab Enterprises - Antoine ELIAS
+//
+//  This file is distributed under the same license as the Scilab package.
+// =============================================================================
+//
+// <-- TEST WITH GRAPHIC -->
+//
+f = gcf();
+sleep(500);
+f.resizefcn = "disp(""should not be called"")";
+save("TMPDIR/load_uimenu.sod", "f");
+delete(gcf());clear f;
+load("TMPDIR/load_uimenu.sod");
+assert_checkequal(get(f, "type"), "Figure");
diff --git a/scilab/modules/io/tests/unit_tests/load_figure.tst b/scilab/modules/io/tests/unit_tests/load_figure.tst
new file mode 100644 (file)
index 0000000..02d351b
--- /dev/null
@@ -0,0 +1,17 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2013 - Scilab Enterprises - Antoine ELIAS
+//
+//  This file is distributed under the same license as the Scilab package.
+// =============================================================================
+//
+// <-- TEST WITH GRAPHIC -->
+//
+
+f = gcf();
+sleep(500);
+f.resizefcn = "disp(""should not be called"")";
+save("TMPDIR/load_uimenu.sod", "f");
+delete(gcf());clear f;
+load("TMPDIR/load_uimenu.sod");
+assert_checkequal(get(f, "type"), "Figure");