Changeset 4666 in josm


Ignore:
Timestamp:
Dec 15, 2011 9:12:57 PM (18 months ago)
Author:
Don-vip
Message:

see #7136 and #7128 - Downloading data on Mac OS X produces an exception

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/IconToggleButton.java

    r4609 r4666  
    6161            ((Destroyable) action).destroy(); 
    6262        } 
    63         action.removePropertyChangeListener(this); 
     63        if (action != null) { 
     64            action.removePropertyChangeListener(this); 
     65        } 
    6466    } 
    6567     
    6668    @Override 
    6769    public void applyButtonHiddenPreferences() { 
    68             String actionName = (String) getAction().getValue(AbstractAction.NAME); 
    69             boolean hiddenFlag = 
    70                     Main.pref.getBoolean(actionName + ".itbutton_hidden", false); 
    71             setVisible(!hiddenFlag);    
     70        String actionName = (String) getSafeActionValue(AbstractAction.NAME); 
     71        boolean hiddenFlag = Main.pref.getBoolean(actionName + ".itbutton_hidden", false); 
     72        setVisible(!hiddenFlag);    
    7273    } 
    7374 
    7475    @Override 
    7576    public void setButtonHidden(boolean b) { 
    76             String actionName = (String) getAction().getValue(AbstractAction.NAME); 
    77             setVisible(!b); 
    78             if (listener!=null) { // if someone wants to know about changes of visibility 
    79                 if (!b) listener.buttonShown(); else listener.buttonHidden(); 
    80             } 
    81             Main.pref.put(actionName + ".itbutton_hidden", b); 
    82              
     77        String actionName = (String) getSafeActionValue(AbstractAction.NAME); 
     78        setVisible(!b); 
     79        if (listener!=null) { // if someone wants to know about changes of visibility 
     80            if (!b) listener.buttonShown(); else listener.buttonHidden(); 
     81        } 
     82        Main.pref.put(actionName + ".itbutton_hidden", b); 
    8383    } 
     84     
    8485    @Override 
    8586    public void showButton() { 
    8687        setButtonHidden(false); 
    8788    } 
     89     
    8890    @Override 
    8991    public void hideButton() { 
     
    9395    @Override 
    9496    public String getActionName() { 
    95         return (String) getAction().getValue(Action.NAME); 
     97        return (String) getSafeActionValue(Action.NAME); 
    9698    } 
    9799 
    98100    @Override 
    99101    public Icon getIcon() { 
    100         return (Icon) getAction().getValue(Action.SMALL_ICON); 
     102        return (Icon) getSafeActionValue(Action.SMALL_ICON); 
    101103    } 
    102104 
     
    111113    } 
    112114 
    113   
     115    protected final Object getSafeActionValue(String key) { 
     116        // Mac OS X Aqua L&F can call accessors from constructor, so getAction() can be null in those cases 
     117        return getAction() != null ? getAction().getValue(key) : null; 
     118    } 
    114119} 
Note: See TracChangeset for help on using the changeset viewer.