don't play with clipboard inside swing thread (JVM bug on mac & linux)
authorKonstantin Bulenkov <kb@jetbrains.com>
Mon, 5 Jul 2010 09:57:07 +0000 (13:57 +0400)
committerKonstantin Bulenkov <kb@jetbrains.com>
Mon, 5 Jul 2010 09:57:07 +0000 (13:57 +0400)
platform/lang-impl/src/com/intellij/unscramble/AnalyzeStacktraceUtil.java

index 5a62e1b22d77252f41ff868b51e1365893a4c156..474ac2003e0af01299bda6be35e379e0d5528bf4 100644 (file)
@@ -27,6 +27,7 @@ import com.intellij.execution.ui.ConsoleViewContentType;
 import com.intellij.execution.ui.ExecutionConsole;
 import com.intellij.execution.ui.RunContentDescriptor;
 import com.intellij.execution.ui.actions.CloseAction;
+import com.intellij.ide.CopyPasteManagerEx;
 import com.intellij.openapi.Disposable;
 import com.intellij.openapi.actionSystem.*;
 import com.intellij.openapi.application.ApplicationManager;
@@ -71,16 +72,15 @@ public class AnalyzeStacktraceUtil {
 
   @Nullable
   public static String getTextInClipboard() {
-    String text = null;
-    try {
-      Transferable contents = Toolkit.getDefaultToolkit().getSystemClipboard().getContents(AnalyzeStacktraceUtil.class);
-      if (contents != null) {
-        text = (String)contents.getTransferData(DataFlavor.stringFlavor);
+    final Transferable contents = CopyPasteManagerEx.getInstance().getContents();
+    if (contents != null) {
+      try {
+        return (String)contents.getTransferData(DataFlavor.stringFlavor);
+      } catch (Exception e) {
+        //no luck
       }
     }
-    catch (Exception ignore) {
-    }
-    return text;
+    return null;
   }
 
   public interface ConsoleFactory {