Merge tag 'v2.3.28' into testing
[lgpl/argeo-commons.git] / swt / rcp / org.argeo.cms.swt.rcp / src / org / argeo / cms / ui / rcp / CmsRcpDisplayFactory.java
index cd554de9d1ec09f63616a11dd1510b99ecd5bc67..96de08e10d6c5caedf23da78f819aa67567fe42f 100644 (file)
@@ -61,15 +61,18 @@ public class CmsRcpDisplayFactory {
                public void run() {
                        try {
                                display = Display.getDefault();
-                               display.setRuntimeExceptionHandler((e) -> e.printStackTrace());
-                               display.setErrorHandler((e) -> e.printStackTrace());
-
-                               while (!shutdown) {
-                                       if (!display.readAndDispatch())
-                                               display.sleep();
+                               boolean displayOwner = display.getThread() == this;
+                               if (displayOwner) {
+                                       display.setRuntimeExceptionHandler((e) -> e.printStackTrace());
+                                       display.setErrorHandler((e) -> e.printStackTrace());
+
+                                       while (!shutdown) {
+                                               if (!display.readAndDispatch())
+                                                       display.sleep();
+                                       }
+                                       display.dispose();
+                                       display = null;
                                }
-                               display.dispose();
-                               display = null;
                        } catch (UnsatisfiedLinkError e) {
                                logger.log(Level.ERROR,
                                                "Cannot load SWT, either because the SWT DLLs are no in the java.library.path,"
@@ -79,6 +82,7 @@ public class CmsRcpDisplayFactory {
                }
        }
 
+       @Deprecated
        public Display getDisplay() {
                return display;
        }