Avoid handle no more valid if closing demo before end. 20/14220/2
Bruno JOFRET [Fri, 28 Mar 2014 16:07:00 +0000 (17:07 +0100)]
Change-Id: I84e93a88fb85decd91f1a61d78e85aa37efbe139

scilab/modules/graphics/demos/lighting/color_light.dem.sce
scilab/modules/graphics/demos/lighting/rot_light.dem.sce
scilab/modules/graphics/demos/lighting/rot_plot3d.dem.sce

index f513b38..d81a806 100644 (file)
@@ -34,6 +34,9 @@ function demo_color_light()
     for j=1: num
         n = 700;
         for i=1:n
+            if ~is_handle_valid(l) then
+                break
+            end
             t = i / n;
             cdiff = diff0 * (1 - t) + diff1 * t;
             cspec = spec0 * (1 - t) + spec1 * t;
@@ -42,6 +45,9 @@ function demo_color_light()
             l.specular_color = cspec;
             sleep(3);
         end
+        if ~is_handle_valid(l) then
+            break
+        end
         diff0 = diff1;
         spec0 = spec1;
         diff1 = rand(1, 3);
index e986823..2bda5d8 100644 (file)
@@ -23,7 +23,11 @@ function demo_rot_light()
         x = 2*cos(i*%pi/180);
         y = 2*sin(i*%pi/180);
         z = 2;
-        l.position = [x y z];
+        if is_handle_valid(l) then
+            l.position = [x y z];
+        else
+            break
+        end
     end
     // DEMO END
 endfunction
index 8e6bf25..db4f8d5 100644 (file)
@@ -21,7 +21,11 @@ function demo_rot_light()
 
     for i=1:360
         sleep(5);
-        a.rotation_angles = [70 i];
+        if (is_handle_valid(a)) then
+            a.rotation_angles = [70 i];
+        else
+            break
+        end
     end
     // DEMO END
 endfunction