From f63e3b60b84193f2eb75211722a69af4e288e777 Mon Sep 17 00:00:00 2001 From: Roman Shevchenko Date: Tue, 3 Jan 2012 19:10:10 +0100 Subject: [PATCH] IDEA-78729 (check for incorrect atoms in X clipboard) --- .../intellij/ide/ClipboardSynchronizer.java | 17 +++++++++-------- .../com/intellij/ide/ToolkitBugsProcessor.java | 18 +----------------- 2 files changed, 10 insertions(+), 25 deletions(-) diff --git a/platform/platform-impl/src/com/intellij/ide/ClipboardSynchronizer.java b/platform/platform-impl/src/com/intellij/ide/ClipboardSynchronizer.java index 0e5046e5ab64..8c292681bfc0 100644 --- a/platform/platform-impl/src/com/intellij/ide/ClipboardSynchronizer.java +++ b/platform/platform-impl/src/com/intellij/ide/ClipboardSynchronizer.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2011 JetBrains s.r.o. + * Copyright 2000-2012 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -38,6 +38,7 @@ import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.util.Collection; import java.util.Collections; +import java.util.Set; /** *

This class is used to workaround the problem with getting clipboard contents (http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4818143). @@ -391,15 +392,15 @@ public class ClipboardSynchronizer implements ApplicationComponent { if (formats == null || formats.length == 0) { return Collections.emptySet(); } - else { - //noinspection unchecked - return DataTransferer.getInstance().getFlavorsForFormats(formats, FLAVOR_MAP).keySet(); + for (int i = 0, length = formats.length; i < length; i++) { + if (formats[i] == 0) return Collections.emptySet(); } + @SuppressWarnings({"unchecked", "UnnecessaryLocalVariable"}) + final Set set = DataTransferer.getInstance().getFlavorsForFormats(formats, FLAVOR_MAP).keySet(); + return set; } - catch (IllegalAccessException ignore) { - } - catch (IllegalArgumentException ignore) { - } + catch (IllegalAccessException ignore) { } + catch (IllegalArgumentException ignore) { } catch (InvocationTargetException e) { final Throwable cause = e.getCause(); if (cause instanceof IllegalStateException) { diff --git a/platform/platform-impl/src/com/intellij/ide/ToolkitBugsProcessor.java b/platform/platform-impl/src/com/intellij/ide/ToolkitBugsProcessor.java index 85faedf87423..5bb3cb45c561 100644 --- a/platform/platform-impl/src/com/intellij/ide/ToolkitBugsProcessor.java +++ b/platform/platform-impl/src/com/intellij/ide/ToolkitBugsProcessor.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2010 JetBrains s.r.o. + * Copyright 2000-2012 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -129,22 +129,6 @@ public class ToolkitBugsProcessor { } } - static class Sun_6322854 extends Handler { - Sun_6322854() { - super("NPE - Failed to retrieve atom name"); - } - - @Override - boolean process(Throwable e, StackTraceElement[] stack) { - if (e instanceof NullPointerException && stack.length > 2) { - return (e.getMessage() != null && e.getMessage().startsWith("Failed to retrieve atom name")) - && stack[1].getClassName().equals("sun.awt.X11.XAtom"); - - } - return false; - } - } - static class Tricky_JEditorPane_registerEditorKitForContentType_NPE extends Handler { Tricky_JEditorPane_registerEditorKitForContentType_NPE() { super("http://ea.jetbrains.com/browser/ea_problems/13587 - JEditorPane_registerEditorKitForContentType_NPE");