Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[platform-ui-dev] ImageRegistry

I have a question and posible improvement to ImageRegistry.java. Is this the
right group/mailing list?

Synopsis:
When using the jface class MessageDialog, I am encountering an unusual
problem which I think might be a bug. I was interested in seeing if anyone
else had similar troubles. If I create a message dialog once it is
fine. If I then dispose of the current display and later create another
display I can no longer create MessageDialogs without a null pointer
exception. The error is ultimate because of code found in ImageRegistry.

ImageRegistry has a number of places where
Entry entry = (Entry)table.get(key);
and
table.put(key, entry);
are called. In an application where you have a long lived central Display
this works fine. In other cases the table field member can be set to null
from private void hookDisplayDispose(Display display). This throws errors at
inappropriate times. We would like to change all direct references to table
to a method call.

//old method example:
   public Image get(String key) {
      Entry entry = (Entry)table.get(key);
      if (entry == null) {
         return null;
      }
      if (entry.image == null && entry.descriptor != null) {
         entry.image = entry.descriptor.createImage();
      }
      return entry.image;
   }

//new method example
   public Image get(String key)   {
      Entry entry = getEntry(key);
      if(entry == null){
         return null;
      }
      if(entry.image == null && entry.descriptor != null){
         entry.image = entry.descriptor.createImage();
      }
      return entry.image;
   }


//new propsed methods
   private Entry getEntry(String key){
     return (Entry)getTable().get(key);
  }

   private void setEntry(String key, Entry entry){
      getTable().put(key, entry);
   }

   private Map getTable(){
      if (table == null){
         table = new HashMap(10);
      }
      return table
   }

   private Map table = null;

Aaron Coble, software development
Steven Ketcham, software development

Digital Solutions Inc.
4200 Industrial Park Drive
P.O. Box 1827
Altoona, PA 16602

http://www.DSICDI.com
Phone: 814.944.0405
Fax:    814.949.3307

"It is our policy and practice to make employment decisions without regard
to an individual's race creed, color, religion, national origin, age sex,
sexual orientation, marital status or disability and use this same policy
and practice with respect to compensation and opportunities for advancement.
This policy applies to all terms and conditions of employment including but
not limited to, hiring, placement, promotion, termination, layoff, recall,
transfer, leaves of absence and compensation."




Back to the top