Ticket #17184: 17184.patch

File 17184.patch, 5.8 KB (added by GerdP, 6 years ago)
  • src/org/openstreetmap/josm/actions/JosmAction.java

     
    252252    public void destroy() {
    253253        if (sc != null && !sc.isAutomatic()) {
    254254            MainApplication.unregisterActionShortcut(this);
     255            sc = null;
    255256        }
    256257        if (layerChangeAdapter != null) {
    257258            getLayerManager().removeLayerChangeListener(layerChangeAdapter);
    258259            getLayerManager().removeActiveLayerChangeListener(activeLayerChangeAdapter);
     260            layerChangeAdapter = null;
    259261        }
    260262        if (selectionChangeAdapter != null) {
    261263            SelectionEventManager.getInstance().removeSelectionListener(selectionChangeAdapter);
     264            selectionChangeAdapter = null;
    262265        }
    263266    }
    264267
  • src/org/openstreetmap/josm/actions/ShowStatusReportAction.java

     
    308308            case 2: BugReportSender.reportBug(reportHeader); break;
    309309            default: // do nothing
    310310        }
    311         GuiHelper.destroyComponents(ed, false);
    312311    }
    313312}
  • src/org/openstreetmap/josm/gui/ExtendedDialog.java

     
    459459        super.setVisible(visible);
    460460
    461461        if (!visible && disposeOnClose) {
     462            GuiHelper.destroyComponents(this, false);
    462463            dispose();
     464            buttons.clear();
    463465        }
    464466    }
    465467
  • src/org/openstreetmap/josm/gui/util/GuiHelper.java

     
    3333import java.util.concurrent.ExecutionException;
    3434import java.util.concurrent.FutureTask;
    3535
     36import javax.swing.Action;
    3637import javax.swing.GrayFilter;
    3738import javax.swing.ImageIcon;
     39import javax.swing.JButton;
    3840import javax.swing.JColorChooser;
    3941import javax.swing.JComponent;
    4042import javax.swing.JFileChooser;
     
    648650    }
    649651
    650652    /**
    651      * Destroys recursively all {@link Destroyable} components of a given container, and optionnally the container itself.
     653     * Destroys recursively all {@link Destroyable} components of a given container, and optionally the container itself.
    652654     * @param component the component to destroy
    653655     * @param destroyItself whether to destroy the component itself
    654656     * @since 14463
    655657     */
    656658    public static void destroyComponents(Component component, boolean destroyItself) {
     659
    657660        if (component instanceof Container) {
    658             for (Component c: ((Container) component).getComponents()) {
     661            for (Component c : ((Container) component).getComponents()) {
    659662                destroyComponents(c, true);
    660663            }
    661664        }
     665        if (component instanceof JButton) {
     666            if (!(component instanceof Destroyable)) {
     667                Action a = ((JButton) component).getAction();
     668                if (a instanceof Destroyable) {
     669                    ((Destroyable) a).destroy();
     670                }
     671                ((JButton) component).setAction(null);
     672            }
     673        }
    662674        if (destroyItself && component instanceof Destroyable) {
    663675            ((Destroyable) component).destroy();
    664676        }
  • src/org/openstreetmap/josm/gui/widgets/JosmTextArea.java

     
    1818 */
    1919public class JosmTextArea extends JTextArea implements Destroyable, FocusListener {
    2020
    21     private final PopupMenuLauncher launcher;
     21    private PopupMenuLauncher launcher;
    2222
    2323    /**
    2424     * Constructs a new {@code JosmTextArea}. A default model is set, the initial string
     
    125125    @Override
    126126    public void destroy() {
    127127        removeFocusListener(this);
    128         TextContextualPopupMenu.disableMenuFor(this, launcher);
     128        if (launcher != null) {
     129            TextContextualPopupMenu.disableMenuFor(this, launcher);
     130            launcher = null;
     131        }
    129132    }
    130133}
  • src/org/openstreetmap/josm/gui/widgets/TextContextualPopupMenu.java

     
    131131    protected TextContextualPopupMenu detach() {
    132132        if (isAttached()) {
    133133            component.removePropertyChangeListener(EDITABLE, propertyChangeListener);
    134             removeAll();
    135134            if (undoRedo) {
    136135                component.getDocument().removeUndoableEditListener(undoEditListener);
     136                if (!GraphicsEnvironment.isHeadless()) {
     137                    component.getInputMap().put(
     138                            KeyStroke.getKeyStroke(KeyEvent.VK_Z, PlatformManager.getPlatform().getMenuShortcutKeyMaskEx()), null);
     139                    component.getInputMap().put(
     140                            KeyStroke.getKeyStroke(KeyEvent.VK_Y, PlatformManager.getPlatform().getMenuShortcutKeyMaskEx()), null);
     141                }
    137142            }
     143
     144            removeAll();
    138145            component = null;
    139146        }
    140147        return this;