xcos: fix headless image generation (again) 04/21304/2
Clement David [Tue, 11 Feb 2020 10:38:05 +0000 (11:38 +0100)]
Change-Id: I9eb94e82ae1fbd97c8c78da9a08f4cc41ad451aa

scilab/modules/xcos/src/java/org/scilab/modules/xcos/configuration/ConfigurationManager.java

index 491a63c..9e1da4f 100644 (file)
@@ -16,6 +16,7 @@
 
 package org.scilab.modules.xcos.configuration;
 
+import java.awt.GraphicsEnvironment;
 import java.beans.PropertyChangeListener;
 import java.beans.PropertyChangeSupport;
 import java.io.File;
@@ -131,9 +132,11 @@ public final class ConfigurationManager {
                 final JAXBElement<SettingType> config = unmarshaller.unmarshal(new StreamSource(f), SettingType.class);
                 return config.getValue();
             } catch (JAXBException e) {
-                Logger.getLogger(ConfigurationManager.class.getName()).warning("user configuration file is not valid.\n" + "Switching to the default one." + e);
-
-                ScilabModalDialog.show(null, XcosMessages.ERR_CONFIG_INVALID, XcosMessages.XCOS_ERROR, IconType.ERROR_ICON);
+                if (GraphicsEnvironment.isHeadless()) {
+                    Logger.getLogger(ConfigurationManager.class.getName()).warning("user configuration file is not valid.\n" + "Switching to the default one." + e);
+                } else {
+                    ScilabModalDialog.show(null, XcosMessages.ERR_CONFIG_INVALID, XcosMessages.XCOS_ERROR, IconType.ERROR_ICON);
+                }
 
                 try {
                     f = new File(ScilabConstants.SCI.getAbsoluteFile() + XcosConstants.XCOS_ETC + INSTANCE_FILENAME);