From 4a0a5d69ffcb7592b092991ddb3761653c389ce6 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Wed, 27 Jun 2012 02:49:18 +0200 Subject: NEWT WindowImpl.runOnEDTIfAvail(..): Run task from current thread if owning the windowLock. Avoiding deadlock when cmds issued from within locked code path. This allows e.g. GLEventListener::display(..) { .. glWindow.setSize(100, 100); .. } --- src/newt/classes/jogamp/newt/WindowImpl.java | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/newt/classes/jogamp/newt/WindowImpl.java b/src/newt/classes/jogamp/newt/WindowImpl.java index 68a2430f7..73bd9ed1c 100644 --- a/src/newt/classes/jogamp/newt/WindowImpl.java +++ b/src/newt/classes/jogamp/newt/WindowImpl.java @@ -1574,12 +1574,16 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer } public void runOnEDTIfAvail(boolean wait, final Runnable task) { - Screen scrn = getScreen(); - if(null==scrn) { - throw new RuntimeException("Null screen of inner class: "+this); + if(windowLock.isOwner()) { + task.run(); + } else { + Screen scrn = getScreen(); + if(null==scrn) { + throw new RuntimeException("Null screen of inner class: "+this); + } + DisplayImpl d = (DisplayImpl) scrn.getDisplay(); + d.runOnEDTIfAvail(wait, task); } - DisplayImpl d = (DisplayImpl) scrn.getDisplay(); - d.runOnEDTIfAvail(wait, task); } private final Runnable requestFocusAction = new Runnable() { -- cgit v1.2.3