From 0323d1dc5a84bcc67fe18d55b67ae16962d1039e Mon Sep 17 00:00:00 2001 From: "Maxim.Mossienko" Date: Tue, 1 Mar 2011 21:24:14 +0300 Subject: [PATCH] replace init of swing components on component initialization in read action with static inner class access with no read action. this change is needed to avoid hang between read access requires EDT access (to init jcomponent) that might be in write action (IDEA-66030) --- .../openapi/fileTypes/impl/NativeFileIconProvider.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/platform/lang-impl/src/com/intellij/openapi/fileTypes/impl/NativeFileIconProvider.java b/platform/lang-impl/src/com/intellij/openapi/fileTypes/impl/NativeFileIconProvider.java index bd0627b22552..4267082afea5 100644 --- a/platform/lang-impl/src/com/intellij/openapi/fileTypes/impl/NativeFileIconProvider.java +++ b/platform/lang-impl/src/com/intellij/openapi/fileTypes/impl/NativeFileIconProvider.java @@ -34,7 +34,6 @@ import java.util.*; * @author yole */ public class NativeFileIconProvider implements FileIconProvider { - private final JFileChooser myFileChooser = new JFileChooser(); private final Map myIconCache = new HashMap(); // on Windows .exe and .ico files provide their own icons which can differ for each file, cache them by full file path private final Set myCustomIconExtensions = @@ -68,8 +67,8 @@ public class NativeFileIconProvider implements FileIconProvider { return null; } Icon icon; - try { - icon = myFileChooser.getIcon(f); + try { // VM will ensure lock to init -static final field--, note we should have no read access here, to avoid deadlock with EDT needed to init component + icon = SwingComponentHolder.ourFileChooser.getIcon(f); } catch (Exception e) { // see http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4854174 return null; @@ -89,6 +88,10 @@ public class NativeFileIconProvider implements FileIconProvider { }); } + static class SwingComponentHolder { + private static final JFileChooser ourFileChooser = new JFileChooser(); + } + protected boolean isNativeFileType(VirtualFile file) { return ElementBase.isNativeFileType(file.getFileType()); }