Revision: 19690
          http://sourceforge.net/p/gate/code/19690
Author:   ian_roberts
Date:     2016-10-18 13:11:53 +0000 (Tue, 18 Oct 2016)
Log Message:
-----------
Use invokeAndWait rather than invokeLater to add items to the document exporter 
menu, to avoid deadlocks when the menu tries to update itself for a new 
exporter on one thread at the same time as the plugin manager is registering a 
different resource type.

Modified Paths:
--------------
    gate/trunk/src/main/gate/gui/DocumentExportMenu.java

Modified: gate/trunk/src/main/gate/gui/DocumentExportMenu.java
===================================================================
--- gate/trunk/src/main/gate/gui/DocumentExportMenu.java        2016-10-18 
01:23:24 UTC (rev 19689)
+++ gate/trunk/src/main/gate/gui/DocumentExportMenu.java        2016-10-18 
13:11:53 UTC (rev 19690)
@@ -67,6 +67,8 @@
 import javax.swing.SwingUtilities;
 import javax.swing.table.TableCellEditor;
 
+import org.apache.log4j.Logger;
+
 /**
  * A menu which updates as plugins are (un)loaded to allow the export of
  * documents and corpora to any of the supported output formats.
@@ -74,6 +76,8 @@
 @SuppressWarnings("serial")
 public class DocumentExportMenu extends XJMenu implements CreoleListener {
 
+  private static final Logger log = Logger.getLogger(DocumentExportMenu.class);
+
   static DocumentExportDialog dialog = new DocumentExportDialog();
 
   protected IdentityHashMap<Resource, JMenuItem> itemByResource =
@@ -455,14 +459,22 @@
     final Resource res = e.getResource();
 
     if(res instanceof DocumentExporter) {
-      SwingUtilities.invokeLater(new Runnable() {
-        
+      Runnable runnable = new Runnable() {
         @Override
         public void run() {
           addExporter((DocumentExporter)res);
         }
-      });
+      };
       
+      if(SwingUtilities.isEventDispatchThread()) {
+        runnable.run();
+      } else {
+        try {
+          SwingUtilities.invokeAndWait(runnable);
+        } catch(Exception ex) {
+          log.warn("Exception registering document exporter", ex);
+        }
+      }
     }
   }
 

This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most 
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
GATE-cvs mailing list
GATE-cvs@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gate-cvs

Reply via email to