From d4bab2edea41a67438a62c04074c2aad855bedcd Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Tue, 21 Mar 2023 10:38:14 +0100 Subject: GraphUI UISceneDemo*: Stop animation loop if window got destroyed --- src/demos/com/jogamp/opengl/demos/graph/ui/UISceneDemo00.java | 4 ++-- src/demos/com/jogamp/opengl/demos/graph/ui/UISceneDemo01.java | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'src/demos/com/jogamp') diff --git a/src/demos/com/jogamp/opengl/demos/graph/ui/UISceneDemo00.java b/src/demos/com/jogamp/opengl/demos/graph/ui/UISceneDemo00.java index 5a3fc3a65..8f8eac1cf 100644 --- a/src/demos/com/jogamp/opengl/demos/graph/ui/UISceneDemo00.java +++ b/src/demos/com/jogamp/opengl/demos/graph/ui/UISceneDemo00.java @@ -103,7 +103,7 @@ public class UISceneDemo00 { window.setTitle(UISceneDemo00.class.getSimpleName()+": "+window.getSurfaceWidth()+" x "+window.getSurfaceHeight()); } @Override - public void windowDestroyed(final WindowEvent e) { + public void windowDestroyNotify(final WindowEvent e) { animator.stop(); } }); @@ -151,7 +151,7 @@ public class UISceneDemo00 { final long t0_us = Clock.currentNanos() / 1000; // [us] long t1_us = t0_us; shape.moveTo(min_obj, 0f, 0f); // move shape to min start position - while( shape.getPosition()[0] < max_obj ) { + while( shape.getPosition()[0] < max_obj && window.isNativeValid() ) { final long t2_us = Clock.currentNanos() / 1000; final float dt_s = ( t2_us - t1_us ) / 1e6f; t1_us = t2_us; diff --git a/src/demos/com/jogamp/opengl/demos/graph/ui/UISceneDemo01.java b/src/demos/com/jogamp/opengl/demos/graph/ui/UISceneDemo01.java index c4c82cb1c..007a5403b 100644 --- a/src/demos/com/jogamp/opengl/demos/graph/ui/UISceneDemo01.java +++ b/src/demos/com/jogamp/opengl/demos/graph/ui/UISceneDemo01.java @@ -110,7 +110,7 @@ public class UISceneDemo01 { window.setTitle(UISceneDemo01.class.getSimpleName()+": "+window.getSurfaceWidth()+" x "+window.getSurfaceHeight()); } @Override - public void windowDestroyed(final WindowEvent e) { + public void windowDestroyNotify(final WindowEvent e) { animator.stop(); } }); @@ -159,7 +159,7 @@ public class UISceneDemo01 { final long t0_us = Clock.currentNanos() / 1000; // [us] long t1_us = t0_us; shape.moveTo(min_obj, 0f, 0f); // move shape to min start position - while( shape.getPosition()[0] < max_obj ) { + while( shape.getPosition()[0] < max_obj && window.isNativeValid() ) { final long t2_us = Clock.currentNanos() / 1000; final float dt_s = ( t2_us - t1_us ) / 1e6f; t1_us = t2_us; -- cgit v1.2.3