From ce1eba944e0dc8a17d89f3c5c1acda77dec68201 Mon Sep 17 00:00:00 2001 From: Blay09 Date: Sat, 28 Jun 2014 20:25:30 +0200 Subject: [PATCH] Fix error dialog being displayed in a headless context. This was causing an infinite cycle of java.awt.HeadlessException in case handleError was called in an environment without display. --- .../src/main/java/com/jme3/app/Application.java | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/jme3-core/src/main/java/com/jme3/app/Application.java b/jme3-core/src/main/java/com/jme3/app/Application.java index e34cc0ba0..396b3ecb9 100644 --- a/jme3-core/src/main/java/com/jme3/app/Application.java +++ b/jme3-core/src/main/java/com/jme3/app/Application.java @@ -518,12 +518,14 @@ public class Application implements SystemListener { public void handleError(String errMsg, Throwable t){ // Print error to log. logger.log(Level.SEVERE, errMsg, t); - // Display error message on screen - if (t != null) { - JmeSystem.showErrorDialog(errMsg + "\n" + t.getClass().getSimpleName() + - (t.getMessage() != null ? ": " + t.getMessage() : "")); - } else { - JmeSystem.showErrorDialog(errMsg); + // Display error message on screen if not in headless mode + if (context.getType() != JmeContext.Type.Headless) { + if (t != null) { + JmeSystem.showErrorDialog(errMsg + "\n" + t.getClass().getSimpleName() + + (t.getMessage() != null ? ": " + t.getMessage() : "")); + } else { + JmeSystem.showErrorDialog(errMsg); + } } stop(); // stop the application