From 481e7cbf62fe8a1ca7402b58c6e41debd66d1e07 Mon Sep 17 00:00:00 2001 From: Mikhail Khodjaiants Date: Tue, 25 Mar 2003 21:20:07 +0000 Subject: [PATCH] Fix for bug 35092. --- debug/org.eclipse.cdt.debug.ui/ChangeLog | 4 +++ .../cdt/debug/internal/ui/CDebugImages.java | 32 +++++++++++++++---- 2 files changed, 30 insertions(+), 6 deletions(-) diff --git a/debug/org.eclipse.cdt.debug.ui/ChangeLog b/debug/org.eclipse.cdt.debug.ui/ChangeLog index 91b32191b9d..b4254cbd8fb 100644 --- a/debug/org.eclipse.cdt.debug.ui/ChangeLog +++ b/debug/org.eclipse.cdt.debug.ui/ChangeLog @@ -1,3 +1,7 @@ +2003-03-25 Mikhail Khodjaiants + Fix for bug 35092. + * CDebugImages.java + 2003-03-25 Mikhail Khodjaiants Added the 'logErrorMessage' static method to the 'CDebugUIPlugin' class. * CDebugUIPlugin.java diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/CDebugImages.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/CDebugImages.java index 807ec419ab0..75ca621262c 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/CDebugImages.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/CDebugImages.java @@ -7,6 +7,8 @@ package org.eclipse.cdt.debug.internal.ui; import java.net.MalformedURLException; import java.net.URL; +import java.util.HashMap; +import java.util.Iterator; import org.eclipse.cdt.debug.ui.CDebugUIPlugin; import org.eclipse.jface.action.IAction; @@ -41,7 +43,8 @@ public class CDebugImages } // The plugin registry - private final static ImageRegistry IMAGE_REGISTRY = new ImageRegistry( CDebugUIPlugin.getStandardDisplay() ); + private static ImageRegistry fgImageRegistry = null; + private static HashMap fgAvoidSWTErrorMap = null; /* * Available cached Images in the C/C++ debug plug-in image registry. @@ -133,7 +136,7 @@ public class CDebugImages */ public static Image get( String key ) { - return IMAGE_REGISTRY.get( key ); + return getImageRegistry().get( key ); } /** @@ -157,10 +160,19 @@ public class CDebugImages /* * Helper method to access the image registry from the JDIDebugUIPlugin class. */ - /* package */ - static ImageRegistry getImageRegistry() + /* package */ static ImageRegistry getImageRegistry() { - return IMAGE_REGISTRY; + if ( fgImageRegistry == null ) + { + fgImageRegistry = new ImageRegistry(); + for ( Iterator iter = fgAvoidSWTErrorMap.keySet().iterator(); iter.hasNext(); ) + { + String key = (String)iter.next(); + fgImageRegistry.put( key, (ImageDescriptor)fgAvoidSWTErrorMap.get( key ) ); + } + fgAvoidSWTErrorMap = null; + } + return fgImageRegistry; } //---- Helper methods to access icons on the file system -------------------------------------- @@ -198,7 +210,15 @@ public class CDebugImages try { ImageDescriptor result = ImageDescriptor.createFromURL( makeIconFileURL( prefix, name.substring( NAME_PREFIX_LENGTH ) ) ); - IMAGE_REGISTRY.put( name, result ); + if ( fgAvoidSWTErrorMap == null ) + { + fgAvoidSWTErrorMap = new HashMap(); + } + fgAvoidSWTErrorMap.put( name, result ); + if ( fgImageRegistry != null ) + { + CDebugUIPlugin.logErrorMessage( "Internal Error: Image registry already defined" ); //$NON-NLS-1$ + } return result; } catch( MalformedURLException e )