Modify

Opened 14 months ago

Closed 10 months ago

Last modified 10 months ago

#23057 closed defect (fixed)

[patch] invisible layer becomes active when removing a layer

Reported by: dieterdreist Owned by: team
Priority: normal Milestone: 23.11
Component: Core Version:
Keywords: Cc:

Description (last modified by dieterdreist)

When you remove the active layer, the first layer (top in list) in the stack becomes active, even if it is invisible. This is inconsistent with the normal behavior, e.g. when you select the next or previous layer, where invisible layers are skipped. It would seem more intuitive if the next lower visible data layer (counting from the deleted layer) became active instead, and if there is none, the next higher visible data layer counting from the deleted layer

Attachments (2)

23057.patch (10.6 KB ) - added by taylor.smock 13 months ago.
josm_23057.patch (12.7 KB ) - added by gaben 10 months ago.
patch reupload

Download all attachments as: .zip

Change History (32)

comment:1 by dieterdreist, 14 months ago

Description: modified (diff)

comment:2 by dieterdreist, 14 months ago

Description: modified (diff)

comment:3 by gaben, 14 months ago

Owner: changed from team to dieterdreist
Status: newneedinfo

Please attach or paste the status report.

(@team: is there a comment template for needinfo comments?)

comment:4 by dieterdreist, 14 months ago

ok, I can’t currently access the machine, but will send it later. It’s on latest josm and was working as expected some months ago. I also noticed that after deleting the validator layer there continue to be issues displayed in the validator window.

comment:5 by dieterdreist, 14 months ago

Relative:URL: ^/trunk
Repository:UUID: 0c6e7542-c601-0410-84e7-c038aed88b3b
Last:Changed Date: 2023-07-10 22:19:01 +0200 (Mon, 10 Jul 2023)
Revision:18776
Build-Date:2023-07-11 01:30:57
URL:https://josm.openstreetmap.de/svn/trunk

Identification: JOSM/1.5 (18776 en) Mac OS X 13.4.1
OS Build number: macOS 13.4.1 (22F82)
Memory Usage: 1066 MB / 4096 MB (457 MB allocated, but free)
Java version: 20.0.1, Homebrew, OpenJDK 64-Bit Server VM
Look and Feel: javax.swing.plaf.metal.MetalLookAndFeel
Screen: Display 1 1920×1080 (scaling 1.00×1.00) Display 2 1920×1080 (scaling 1.00×1.00)
Maximum Screen Size: 1920×1080
Best cursor sizes: 16×16→16×16, 32×32→32×32
System property file.encoding: UTF-8
System property sun.jnu.encoding: UTF-8
Locale info: en_IT
Numbers with default locale: 1234567890 -> 1234567890
VM arguments: [-Djosm.home=<josm.pref>, -Dsun.java2d.opengl=true]
Dataset consistency test: No problems found

Plugins:
+ apache-commons (36034)
+ buildings_tools (36097)
+ editgpx (36097)
+ ejml (35924)
+ geotools (36068)
+ jackson (36034)
+ jaxb (35952)
+ jts (36004)
+ mbtiles (v2.6.1)
+ measurement (36097)
+ opendata (36097)
+ openqa (v0.3.3)
+ pbf (36034)
+ poly (36097)
+ todo (123)
+ undelete (36066)
+ utilsplugin2 (36097)

Tagging presets:
removed
Last edited 12 months ago by taylor.smock (previous) (diff)

comment:6 by gaben, 14 months ago

Owner: changed from dieterdreist to team
Status: needinfonew

Thank you!

by taylor.smock, 13 months ago

Attachment: 23057.patch added

comment:7 by gaben, 13 months ago

Summary: invisible layer becomes active when removing a layer[patch] invisible layer becomes active when removing a layer

comment:8 by taylor.smock, 12 months ago

Resolution: fixed
Status: newclosed

In 18837/josm:

Fix #23057: An invisible layer should not become active when removing a layer

comment:9 by taylor.smock, 12 months ago

Milestone: 23.09

comment:10 by taylor.smock, 11 months ago

Milestone: 23.0923.10

Ticket retargeted after milestone deleted

comment:11 by gaben, 11 months ago

Resolution: fixed
Status: closedreopened

Hmm, after this patch aerial imagery usually gets selected.

To reproduce:

  1. have three layers in this order:
    • data layer 2
    • data layer 1 <- select this as an active
    • an aerial image
  2. delete "data layer 1"

The selection should go to "data layer 2", but instead the background image becomes active.

Last edited 11 months ago by gaben (previous) (diff)

comment:12 by gaben, 10 months ago

I cannot run tests in dialogs/layer/DeleteLayerActionTest.java, as I'm getting an exception in IntelliJ:

java.lang.NullPointerException: Cannot enter synchronized block because "this.ownedWindowList" is null

	at java.desktop/java.awt.Window.addOwnedWindow(Window.java:2838)
	at java.desktop/java.awt.Window.ownedInit(Window.java:649)
	at java.desktop/java.awt.Window.<init>(Window.java:610)
	at java.desktop/java.awt.Dialog.<init>(Dialog.java:675)
	at java.desktop/javax.swing.JDialog.<init>(JDialog.java:593)
	at java.desktop/javax.swing.JDialog.<init>(JDialog.java:526)
	at org.openstreetmap.josm.gui.io.SaveLayersDialog.<init>(SaveLayersDialog.java:152)
	at org.openstreetmap.josm.gui.io.SaveLayersDialog.saveUnsavedModifications(SaveLayersDialog.java:117)
	at org.openstreetmap.josm.gui.dialogs.layer.DeleteLayerAction.actionPerformed(DeleteLayerAction.java:48)
	at org.openstreetmap.josm.gui.dialogs.layer.DeleteLayerActionTest.testSetActiveLayerOnlyOneVisible0to8(DeleteLayerActionTest.java:57)

Do you have any idea what's the cause? Other tests which I was working on ran just fine.

comment:13 by taylor.smock, 10 months ago

I use -ea -Djava.awt.headless=true -javaagent:/Users/tsmock/.ivy2/cache/org.jmockit/jmockit/jars/jmockit-1.49.a.jar in the VM options. You'll have to update the /Users/tsmock bit to point at your home directory though.

I actually have that set in the JUnit template so things "just work".

EDIT: I suspect the issue is due to jmockit not getting loaded.

Last edited 10 months ago by taylor.smock (previous) (diff)

comment:14 by gaben, 10 months ago

Ah thanks! The -Djava.awt.headless=true option was missing. Is it documented somewhere? I'd like to add to the dev guide.

Last edited 10 months ago by gaben (previous) (diff)

comment:15 by taylor.smock, 10 months ago

I have no clue. I know that the tests are run headless on the server, so I tend to just write the tests so they work under headless mode.

comment:16 by taylor.smock, 10 months ago

See source:trunk/build.xml@18891:467-506#L467 for other flags that JOSM adds for the tests.

comment:18 by gaben, 10 months ago

I have a patch for this, but also a question from user perspective. What should happen to the selection when all the layers are invisible (hidden)?

in reply to:  11 comment:19 by taylor.smock, 10 months ago

What should happen to the selection when all the layers are invisible (hidden)?

I have no clue. I'd probably just pick one in a consistent manner. E.g., the next layer down.

comment:20 by gaben, 10 months ago

Replying to taylor.smock:

I'd probably just pick one in a consistent manner. E.g., the next layer down.

That's fair. The attached patch implements this with some usual doc fixes and unit tests. Please test it :)

by gaben, 10 months ago

Attachment: josm_23057.patch added

patch reupload

comment:21 by gaben, 10 months ago

I just realized it's no longer unit testing the DeleteLayerAction 🤦‍♂️. Anyway, maybe it still fits there. Sorry for spamming.

comment:22 by taylor.smock, 10 months ago

Meh. There are plenty of integration tests in the unit test directory. As long as you aren't making a call to a server (or something else that is slow), I don't really care. :)

So what we are doing is testing the expected behavior of the DeleteLayerAction from a test class called DeleteLayerActionTest. Which is perfectly fine, IMO.

comment:23 by gaben, 10 months ago

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

comment:24 by taylor.smock, 10 months ago

@gaben: Why did you modify the Layer#toString method? Was it just for debugging, or was there an additional reason behind it?

comment:25 by gaben, 10 months ago

Yes, it was mostly for debugging, but I thought this parameter was worth enough to remain there.

What are toString methods used for anyway, if not debugging?

comment:26 by taylor.smock, 10 months ago

Milestone: 23.1023.11

Ticket retargeted after milestone deleted

comment:27 by taylor.smock, 10 months ago

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

comment:28 by taylor.smock, 10 months ago

Resolution: fixed
Status: reopenedclosed

In 18895/josm:

Fix #23057: data layers should be selected next, not non-data layers (patch by gaben, modified)

Modifications are as follows:

  • Fix test pollution uncovered by change in non-obvious determinate order of tests
  • Fix code so that MainLayerManagerTest.testRemoveLayerUnsetsActiveLayer passes

comment:29 by gaben, 10 months ago

Thank you! I was thinking about using better variable names as in the pushed version, but attaching patches for each ticket is a pain.

comment:30 by taylor.smock, 10 months ago

No problem -- I would have pushed it yesterday, but I had to figure out why the tests were failing locally first. And fix those. I finished that yesterday, and then spent this morning figuring out the best way to fix MainLayerManagerTest.testRemoveLayerUnsetsActiveLayer.

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain team.
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.