Modify

Opened 5 years ago

Closed 22 months ago

Last modified 22 months ago

#17465 closed defect (fixed)

IAE: Listener buildings_tools.DrawBuildingAction was not registered before or already removed.

Reported by: anonymous Owned by: Upliner
Priority: normal Milestone:
Component: Plugin buildings_tools Version:
Keywords: template_report Cc: marcelshabani@…, EmilyBA

Description

What steps will reproduce the problem?

What is the expected result?

I wanted to update JOSM from vesion 14460 to 14824 unfortunaly.

What happens instead?

I tried to download JOSM it fails in all the ways but it fails.

Please provide any additional information below. Attach a screenshot if possible.

URL:https://josm.openstreetmap.de/svn/trunk
Repository:UUID: 0c6e7542-c601-0410-84e7-c038aed88b3b
Last:Changed Date: 2018-11-28 01:09:01 +0100 (Wed, 28 Nov 2018)
Build-Date:2018-11-28 00:26:41
Revision:14460
Relative:URL: ^/trunk

Identification: JOSM/1.5 (14460 en) Windows 10 64-Bit
OS Build number: Windows 10 Enterprise 1803 (17134)
Memory Usage: 247 MB / 247 MB (111 MB allocated, but free)
Java version: 1.8.0_171-b11, Oracle Corporation, Java HotSpot(TM) Client VM
Screen: \Display0 1366x768
Maximum Screen Size: 1366x768
Dataset consistency test: No problems found

Plugins:
+ BuildingGeneralization (23)
+ buildings_tools (34867)
+ download_along (34869)
+ utilsplugin2 (34506)

Last errors/warnings:
- W: java.net.SocketTimeoutException: connect timed out
- W: java.net.SocketTimeoutException: connect timed out
- W: java.net.SocketTimeoutException: connect timed out
- W: java.net.SocketTimeoutException: connect timed out
- W: java.net.SocketTimeoutException: connect timed out
- W: java.net.SocketTimeoutException: connect timed out
- W: java.net.SocketTimeoutException: connect timed out
- W: java.net.SocketTimeoutException: connect timed out
- E: Handled by bug report queue: java.lang.IllegalArgumentException: Listener org.openstreetmap.josm.plugins.buildings_tools.DrawBuildingAction@1009c08 (instance of org.openstreetmap.josm.plugins.buildings_tools.DrawBuildingAction) was not registered before or already removed.
- W: Warning - <html>JOSM could not find information about the following plugins:<ul><li>BuildingGeneralization</li><li>utilsplugin2</li><li>buildings_tools</li><li>download_along</li></ul>The plugins are not going to be loaded.</html>


=== REPORTED CRASH DATA ===
BugReportExceptionHandler#handleException:
No data collected.

Warning issued by: BugReportExceptionHandler#handleException

=== STACK TRACE ===
Thread: AWT-EventQueue-0 (15) of main
java.lang.IllegalArgumentException: Listener org.openstreetmap.josm.plugins.buildings_tools.DrawBuildingAction@1009c08 (instance of org.openstreetmap.josm.plugins.buildings_tools.DrawBuildingAction) was not registered before or already removed.
	at org.openstreetmap.josm.tools.ListenerList.failRemove(ListenerList.java:132)
	at org.openstreetmap.josm.tools.ListenerList.removeListener(ListenerList.java:126)
	at org.openstreetmap.josm.data.Preferences.removePreferenceChangeListener(Preferences.java:176)
	at org.openstreetmap.josm.actions.mapmode.MapMode.exitMode(MapMode.java:85)
	at org.openstreetmap.josm.plugins.buildings_tools.DrawBuildingAction.exitMode(DrawBuildingAction.java:154)
	at org.openstreetmap.josm.gui.MapFrame.activeOrEditLayerChanged(MapFrame.java:845)
	at org.openstreetmap.josm.gui.layer.MainLayerManager.fireActiveLayerChange(MainLayerManager.java:269)
	at org.openstreetmap.josm.gui.layer.MainLayerManager.setActiveLayer(MainLayerManager.java:262)
	at org.openstreetmap.josm.gui.layer.MainLayerManager.realRemoveSingleLayer(MainLayerManager.java:302)
	at org.openstreetmap.josm.gui.layer.LayerManager.realRemoveLayer(LayerManager.java:265)
	at org.openstreetmap.josm.gui.layer.LayerManager.lambda$removeLayer$1(LayerManager.java:247)
	at org.openstreetmap.josm.gui.util.GuiHelper.runInEDTAndWaitWithException(GuiHelper.java:237)
	at org.openstreetmap.josm.gui.layer.LayerManager.removeLayer(LayerManager.java:247)
	at org.openstreetmap.josm.gui.layer.LayerManager.realResetState(LayerManager.java:511)
	at org.openstreetmap.josm.gui.layer.MainLayerManager.realResetState(MainLayerManager.java:491)
	at org.openstreetmap.josm.gui.util.GuiHelper.runInEDTAndWaitWithException(GuiHelper.java:237)
	at org.openstreetmap.josm.gui.layer.LayerManager.resetState(LayerManager.java:502)
	at org.openstreetmap.josm.gui.MainTermination.run(MainTermination.java:43)
	at org.openstreetmap.josm.spi.lifecycle.Lifecycle.exitJosm(Lifecycle.java:117)
	at org.openstreetmap.josm.gui.MainApplication.exitJosm(MainApplication.java:500)
	at org.openstreetmap.josm.gui.MainFrame$ExitWindowAdapter.windowClosing(MainFrame.java:181)
	at java.awt.AWTEventMulticaster.windowClosing(Unknown Source)
	at java.awt.Window.processWindowEvent(Unknown Source)
	at javax.swing.JFrame.processWindowEvent(Unknown Source)
	at java.awt.Window.processEvent(Unknown Source)
	at java.awt.Component.dispatchEventImpl(Unknown Source)
	at java.awt.Container.dispatchEventImpl(Unknown Source)
	at java.awt.Window.dispatchEventImpl(Unknown Source)
	at java.awt.Component.dispatchEvent(Unknown Source)
	at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
	at java.awt.EventQueue.access$500(Unknown Source)
	at java.awt.EventQueue$3.run(Unknown Source)
	at java.awt.EventQueue$3.run(Unknown Source)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
	at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
	at java.awt.EventQueue$4.run(Unknown Source)
	at java.awt.EventQueue$4.run(Unknown Source)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
	at java.awt.EventQueue.dispatchEvent(Unknown Source)
	at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
	at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
	at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
	at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
	at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
	at java.awt.EventDispatchThread.run(Unknown Source)

Attachments (1)

josm_fix_map_mode_readonly_layer_v1.patch (2.7 KB ) - added by Woazboat 2 years ago.
Disable edit map modes when layer is in readonly mode

Download all attachments as: .zip

Change History (27)

in reply to:  description comment:1 by Hb---, 5 years ago

Replying to anonym:

Memory Usage: 247 MB / 247 MB (111 MB allocated, but free)
Java version: 1.8.0_171-b11, Oracle Corporation, Java HotSpot(TM) Client VM

1.
You try to WebStart JOSM from a 32-bit Browser on a 64-Bit Operating system. This starting variant limits the available memory for JOSM to ~250 MB. This not enough.

Please download josm-tested.jar to your hard disk and start JOSM directly as shown in Download#Java.

2.
Your Java version seems a bit outdated. The above mentioned page provides a "manual" download link. Please update this first.

comment:2 by Don-vip, 5 years ago

Component: CorePlugin buildings_tools
Owner: changed from team to Upliner

comment:3 by GerdP, 5 years ago

@anonym: Please try to update the plugins, they are not all up to date.

comment:4 by Don-vip, 5 years ago

Summary: can't download or update josm in windows 10.IAE: Listener buildings_tools.DrawBuildingAction was not registered before or already removed.

comment:5 by Don-vip, 5 years ago

Ticket #17855 has been marked as a duplicate of this ticket.

comment:6 by Don-vip, 4 years ago

Ticket #18686 has been marked as a duplicate of this ticket.

comment:7 by simon04, 3 years ago

Ticket #20917 has been marked as a duplicate of this ticket.

comment:8 by simon04, 3 years ago

Cc: EmilyBA added

comment:9 by Don-vip, 3 years ago

Ticket #21100 has been marked as a duplicate of this ticket.

comment:10 by Woazboat, 2 years ago

Is there any particular reason why the buildings_tool DrawBuildingAction checks if a layer is supported using:

@Override
public boolean layerIsSupported(Layer l) {
    return l instanceof OsmDataLayer;
}

@Override
public void enterMode() {
    super.enterMode();

    MapFrame map = MainApplication.getMap();
    if (getLayerManager().getEditDataSet() == null) {
        map.selectSelectTool(false);
        return;
    }

    // ...
}

instead of e.g. how it's done in other actions like in DrawAction:

@Override
public boolean layerIsSupported(Layer l) {
    return isEditableDataLayer(l);
}

@Override
protected void updateEnabledState() {
    setEnabled(getLayerManager().getEditLayer() != null);
}

@Override
public void enterMode() {
    if (!isEnabled())
        return;
    super.enterMode();

    // ...
}

I think this might be the source of this bug

comment:11 by GerdP, 2 years ago

Yes, that's true. When I load an *.osm file with locked='true' the bug is reproducable.

by Woazboat, 2 years ago

Disable edit map modes when layer is in readonly mode

comment:12 by Woazboat, 2 years ago

The building tools plugin isn't the only one that's affected. Lots of other plugins also don't handle non-editable layers correctly. So far I've found this issue in pt_assistant, splinex and FastDraw (and that's only among the plugins that I have installed)

comment:13 by skyper, 2 years ago

Thought we'd have a ticket about pt_assistant, but cannot find it. FastDraw has already one. These tickets are possible candidates.

comment:14 by GerdP, 2 years ago

@Woazboat: I don't know what this code is supposed to do. Are you sure that it should be removed?

        if (getLayerManager().getEditDataSet() == null) {
            map.selectSelectTool(false);
            return;
        }

comment:15 by GerdP, 2 years ago

In 35864/osm:

fix #17366: IAE: Listener plugins.fastdraw.FastDrawingMode was not registered before or already removed
see #17465

  • Disable edit map modes when layer is in readonly mode (patch by Woazboat, modified to remove unused import)

comment:16 by GerdP, 2 years ago

In 35866/osm:

see #17465: IAE: Listener buildings_tools.DrawBuildingAction was not registered before or already removed.

  • layer is in readonly mode is not supported

in reply to:  14 comment:17 by Woazboat, 2 years ago

Replying to GerdP:

@Woazboat: I don't know what this code is supposed to do. Are you sure that it should be removed?

        if (getLayerManager().getEditDataSet() == null) {
            map.selectSelectTool(false);
            return;
        }

I'm fairly sure that's supposed to be an attempt to disallow use of the tool/mode when the current layer is not editable, but that's what layerIsSupported() and updateEnabledState() are for. Don't 100% know what map.selectSelectTool(false); is doing in there, but I as far as I can tell it's just supposed to switch to a different mode if activating this one failed because of the editable check.

in reply to:  13 comment:18 by Woazboat, 2 years ago

Replying to skyper:

Thought we'd have a ticket about pt_assistant, but cannot find it. FastDraw has already one. These tickets are possible candidates.

pt_assistant development is on github, maybe that's why: https://github.com/JOSM/pt_assistant

comment:19 by Woazboat, 2 years ago

What I'm not sure about is why the isEnabled() check in enterMode() is necessary (if at all). I only included it here because it's done this way in the other standard modes I've looked at for reference (e.g. draw mode).

public void enterMode() {
    if (!isEnabled())
        return;
    // ...
}

That check will cause enterMode() to abort without doing anything, but exitMode() will still be executed when the mode is changed, which will lead to the issue seen here in this ticket where a mode is exited without properly entering it first.

    public boolean selectMapMode(MapMode newMapMode, Layer newLayer) {
        MapMode oldMapMode = this.mapMode;
        if (newMapMode == oldMapMode)
            return true;
        if (newMapMode == null || !newMapMode.layerIsSupported(newLayer)) {
            newMapMode = null;
        }
        Logging.debug("Switching map mode from {0} to {1}",
                Optional.ofNullable(oldMapMode).map(m -> m.getClass().getSimpleName()).orElse("(none)"),
                Optional.ofNullable(newMapMode).map(m -> m.getClass().getSimpleName()).orElse("(none)"));

        if (oldMapMode != null) {
            MainApplication.getMenu().findMapModeMenuItem(oldMapMode).ifPresent(m -> m.setSelected(false));
            oldMapMode.exitMode();
        }
        this.mapMode = newMapMode;
        if (newMapMode != null) {
            newMapMode.enterMode();
            MainApplication.getMenu().findMapModeMenuItem(newMapMode).ifPresent(m -> m.setSelected(true));
        }
        lastMapMode.put(newLayer, newMapMode);
        fireMapModeChanged(oldMapMode, newMapMode);
        return newMapMode != null;
    }

    @Override
    public void activeOrEditLayerChanged(ActiveLayerChangeEvent e) {
        boolean modeChanged = false;
        Layer newLayer = e.getSource().getActiveLayer();
        if (mapMode == null || !mapMode.layerIsSupported(newLayer)) {
            MapMode newMapMode = getLastMapMode(newLayer);
            modeChanged = newMapMode != mapMode;
            if (newMapMode != null) {
                // it would be nice to select first supported mode when layer is first selected,
                // but it don't work well with for example editgpx layer
                selectMapMode(newMapMode, newLayer);
            } else if (mapMode != null) {
                mapMode.exitMode(); // if new mode is null - simply exit from previous mode
                mapMode = null;
            }
        }
        // if this is really a change (and not the first active layer)
        if (e.getPreviousActiveLayer() != null && !modeChanged && mapMode != null) {
            // Let mapmodes know about new active layer
            mapMode.exitMode();
            mapMode.enterMode();
        }

        // After all listeners notice new layer, some buttons will be disabled/enabled
        // and possibly need to be hidden/shown.
        validateToolBarsVisibility();
    }

comment:20 by skyper, 2 years ago

Don't forget that for many core modes, we actually have two modes, like the rectangle select and the lasso select mode or the different draw and extruder modes.

comment:21 by Woazboat, 2 years ago

Yes, but I don't see how the isEnabled() check in enterMode() would help in any situation. For the extrusion tool, all modes modify data and are simply disabled via:

    @Override
    public boolean layerIsSupported(Layer l) {
        return isEditableDataLayer(l);
    }

The select mode checks for non-editable layers like in a custom way (called when the left mouse button is pressed):

    private void determineMapMode(boolean hasSelectionNearby) {
        if (getLayerManager().getEditDataSet() != null) {
            if (shift && ctrl) {
                mode = Mode.ROTATE;
            } else if (alt && ctrl) {
                mode = Mode.SCALE;
            } else if (hasSelectionNearby || dragInProgress()) {
                mode = Mode.MOVE;
            } else {
                mode = Mode.SELECT;
            }
        } else {
            mode = Mode.SELECT;
        }
    }

comment:22 by taylor.smock, 22 months ago

Ticket #22181 has been marked as a duplicate of this ticket.

in reply to:  14 comment:23 by taylor.smock, 22 months ago

Replying to GerdP:

@Woazboat: I don't know what this code is supposed to do. Are you sure that it should be removed?

        if (getLayerManager().getEditDataSet() == null) {
            map.selectSelectTool(false);
            return;
        }

This if block has been around since r21236/osm (2010). We first started updating the status of the button in r4480 (2011), so buildings_tools may have been working around the same bug that r4480 fixed (see #6876).

I think we can safely remove it. I believe it exists to avoid an NPE, which should not happen with the change (isEditableDataLayer introduced in r13434), and it works around someone entering the mode, and then not being able to do anything, by exiting the mode (i.e., changing mode to select mode).

comment:24 by GerdP, 22 months ago

OK, go ahead!

comment:25 by taylor.smock, 22 months ago

Resolution: fixed
Status: newclosed

In 35997/osm:

Fix #17465: IAE: Listener buildings_tools.DrawBuildingAction was not registered before or already removed.

This occurs when a user attempts to enter the mapmode when the edit dataset is
null. We fix the problem by (a) updating the layerIsSupported method to use
isEditableDataLayer (introduced in r13434) and (b) removing a check that used
to ensure that if a user entered the mapmode when there was no editable layer,
we immediately exit from the mapmode and enter into the select mode. As all
calls to enterMode should be guarded by layerIsSupported (on layer change),
this is safe now that we are checking if the layer is editable.

comment:26 by taylor.smock, 22 months ago

In 35998/osm:

See #17465 (dist): IAE: Listener buildings_tools.DrawBuildingAction was not registered before or already removed.

This occurs when a user attempts to enter the mapmode when the edit dataset is
null. We fix the problem by (a) updating the layerIsSupported method to use
isEditableDataLayer (introduced in r13434) and (b) removing a check that used
to ensure that if a user entered the mapmode when there was no editable layer,
we immediately exit from the mapmode and enter into the select mode. As all
calls to enterMode should be guarded by layerIsSupported (on layer change),
this is safe now that we are checking if the layer is editable.

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain Upliner.
as The resolution will be set.
The resolution will be deleted. Next status will be 'reopened'.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.