Opened 4 years ago
Closed 4 years ago
#3018 closed defect (fixed)
[PATCH] Make sure tools menu entries (and actions) are deactivated when no layer
| Reported by: | avar | Owned by: | avar |
|---|---|---|---|
| Priority: | major | Component: | Core |
| Version: | latest | Keywords: | |
| Cc: | karl.guggisberg@… |
Description
- Start JOSM
- Press "c" (combine way)
java.lang.NullPointerException at org.openstreetmap.josm.actions.CombineWayAction.actionPerformed(CombineWayAction.java:59) at javax.swing.SwingUtilities.notifyAction(SwingUtilities.java:1636) at javax.swing.JComponent.processKeyBinding(JComponent.java:2851) at javax.swing.KeyboardManager.fireBinding(KeyboardManager.java:267) at javax.swing.KeyboardManager.fireKeyboardAction(KeyboardManager.java:216) at javax.swing.JComponent.processKeyBindingsForAllComponents(JComponent.java:2928) at javax.swing.JComponent.processKeyBindings(JComponent.java:2920) at javax.swing.JComponent.processKeyEvent(JComponent.java:2814) at java.awt.Component.processEvent(Component.java:6040) at java.awt.Container.processEvent(Container.java:2041) at java.awt.Component.dispatchEventImpl(Component.java:4630) at java.awt.Container.dispatchEventImpl(Container.java:2099) at java.awt.Component.dispatchEvent(Component.java:4460) at java.awt.KeyboardFocusManager.redispatchEvent(KeyboardFocusManager.java:1848) at java.awt.DefaultKeyboardFocusManager.dispatchKeyEvent(DefaultKeyboardFocusManager.java:704) at java.awt.DefaultKeyboardFocusManager.preDispatchKeyEvent(DefaultKeyboardFocusManager.java:969) at java.awt.DefaultKeyboardFocusManager.typeAheadAssertions(DefaultKeyboardFocusManager.java:841) at java.awt.DefaultKeyboardFocusManager.dispatchEvent(DefaultKeyboardFocusManager.java:668) at java.awt.Component.dispatchEventImpl(Component.java:4502) at java.awt.Container.dispatchEventImpl(Container.java:2099) at java.awt.Window.dispatchEventImpl(Window.java:2475) at java.awt.Component.dispatchEvent(Component.java:4460) at java.awt.EventQueue.dispatchEvent(EventQueue.java:599) at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269) at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184) at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161) at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)
Attachments (1)
Change History (14)
comment:1 Changed 4 years ago by Gubaer
- Cc karl.guggisberg@… added
- Resolution set to fixed
- Status changed from new to closed
comment:2 Changed 4 years ago by Landwirt
- Resolution fixed deleted
- Status changed from closed to reopened
- Summary changed from NullPointerException when starting JOSM & pressing "C" to NullPointerException when starting JOSM & using one of the tools
I have to say that this problem affects perhaps all tools - UnGlueAction, MergeNodesAction etc. Just load JOSM and start an action from the Tools menu.
comment:3 Changed 4 years ago by Gubaer
- Summary changed from NullPointerException when starting JOSM & using one of the tools to Make sure tools menu entries (and actions) are deactivated when no layer
comment:4 Changed 4 years ago by Gubaer
- Resolution set to fixed
- Status changed from reopened to closed
fixed in r1820
comment:5 Changed 4 years ago by Landwirt
- Resolution fixed deleted
- Status changed from closed to reopened
I reopen the ticket once again, because the tools/actions are not immediately activated after a layer has been created or opened. Even after drawing selected objects have to be re-selected to enable the actions.
comment:6 Changed 4 years ago by anonymous
Ticket #2948 has been marked as a duplicate of this ticket.
comment:7 Changed 4 years ago by Landwirt
- Summary changed from Make sure tools menu entries (and actions) are deactivated when no layer to [PATCH] Make sure tools menu entries (and actions) are deactivated when no layer
I made a patch to update the updateEnabledState function of most actions.
comment:8 Changed 4 years ago by Landwirt
Ticket #3038 has been marked as a duplicate of this ticket.
comment:9 Changed 4 years ago by Gubaer
- Owner changed from team to avar
- Status changed from reopened to needinfo
The patch mainly replaces
setEnabled(getCurrentDataSet() != null && ! getCurrentDataSet().getSelected().isEmpty());
by
setEnabled(getEditLayer() != null);
if (this.enabled) {
setEnabled(getCurrentDataSet() != null && !getCurrentDataSet().getSelected().isEmpty());
}
in actions.
The replacement is logically equivalent with the orignal, though, it looks only more elaborated.
Am I missing something?
comment:10 Changed 4 years ago by Landwirt
I believe I mixed up the patches - the this.enabled part shouldn't be there as I replaced all that lines by just the getEditLayer line. Nonetheless both is wrong, and best example why I haven't asked for svn access :-D
But I have another patch for a possible solution. As I couldn't find out why getCurrentDataSet().getSelected() seems to be always empty, I simply extended the updateEnabledState.
Changed 4 years ago by Landwirt
comment:11 Changed 4 years ago by Gubaer
Nonetheless both is wrong, and best example why I haven't asked for svn access :-D
I won't apply this patch either, at least not entirely.
Most of the stuff you added is redundant. It's already working exactly the way you try to fix it. I'm therefore wondering with what JOSM version you are working. Can you explain again what you try to fix?
The patch for ReverseWayAction.java is ok, though. This OK was forgotten in the last update so your cleanup is welcome.
comment:12 Changed 4 years ago by Landwirt
In eclipse I currently have 1826, but you can also try today's josm-latest: draw a way, switch to select mode - though the way is selected the actions in the Tools menu are still disabled. That's because in updateEnableState the result of !getCurrentDataSet().getSelected().isEmpty() is incorrectly "false".
The patch for ReverseWayAction.java is ok
Parts in PasteAction.java should also work - currently Pasting is disabled when nothing is selected.
comment:13 Changed 4 years ago by Gubaer
- Resolution set to fixed
- Status changed from needinfo to closed
fixed in r1844



fixed in r1817