#6725 closed defect (fixed)
[Patch] Plugins need to be loaded before tool definitions for toolbar buttons (WAS: Missing tool definition in utilsplugin2 when item placed in toolbar)
Reported by: | rickmastfan67 | Owned by: | team |
---|---|---|---|
Priority: | normal | Milestone: | 22.02 |
Component: | Core | Version: | latest |
Keywords: | toolbar plugin button | Cc: |
Description (last modified by )
Just found something left over from the old "dumbutils" plugin that was merged into utilsplugin2.
Whenever you place the "Replace Geometry" icon into the "toolbar", this message pops up when you start up JOSM via the command line.
Could not load tool definition dumbutils/replacegeometry
Just thought you would like to know about it and fix it if you want to as it doesn't seem to have any problems in the toolbar, even with that message showing up.
Also, that message still shows up when you disable utilsplugin2, but shows up a second time after all the other plugins load. And it keeps showing up in the CL when you hit "F12" to pull up the preferences.
NOTE: To get this message to show up the first time in the CL, you must first put the "Replace Geometry" icon into your toolbar and restart JOSM. Then, when it restarts, you'll see the message for the first time.
Attachments (1)
Change History (19)
comment:1 by , 14 years ago
Owner: | changed from | to
---|---|
Status: | new → assigned |
comment:2 by , 14 years ago
Component: | Plugin utilsplugin2 → Core |
---|---|
Description: | modified (diff) |
Owner: | changed from | to
Priority: | trivial → minor |
Status: | assigned → new |
comment:3 by , 14 years ago
Summary: | Missing tool definition in utilsplugin2 when item placed in toolbar → Plugins need to be loaded before tool definitions for toolbar buttons (WAS: Missing tool definition in utilsplugin2 when item placed in toolbar) |
---|
comment:4 by , 4 years ago
Keywords: | toolbar plugin button added |
---|---|
Priority: | minor → normal |
Is this still a problem?
comment:5 by , 4 years ago
Well, the error still shows up to this date to be honest whenever starting up JOSM as long as I have the "Replace Geometry" button in my toolbar for quick access.
2021-03-25 22:43:22.918 INFO: Could not load tool definition dumbutils/replacegeometry
Don't know if it hurts anything to be honest.
follow-up: 8 comment:6 by , 3 years ago
I think it's not a problem because the toolbar is refreshed again after the plugins are loaded.
I am not sure why it is needded to refresh the toolbar before the plugins are loaded (this causes the INFO message).
comment:7 by , 3 years ago
The toolbar preferences are initialised here source://trunk/src/org/openstreetmap/josm/gui/preferences/ToolbarPreferences.java@18360#L982.
When I comment this line out, only the preferences disappear. The loading order probably can be delayed but need to be checked.
comment:8 by , 3 years ago
Replying to GerdP:
I think it's not a problem because the toolbar is refreshed again after the plugins are loaded.
I am not sure why it is needed to refresh the toolbar before the plugins are loaded (this causes the INFO message).
With r18303 I only get the messages once.
java -Djosm.home=/tmp/.josm_test -jar /usr/share/josm/josm-tested-18303.jar 2022-01-04 14:37:51.199 INFO: Log level is at INFO (INFO, 800) 2022-01-04 14:38:00.417 INFO: Obtained 82 Tag2Link rules from resource://META-INF/resources/webjars/tag2link/2021.3.21/index.json 2022-01-04 14:38:05.699 INFO: Could not load tool definition icons/splitroundabout 2022-01-04 14:38:05.709 INFO: Could not load tool definition icons/sortptroutemembers 2022-01-04 14:38:05.774 INFO: loading plugin 'pt_assistant' (version 1ff2e15) 2022-01-04 14:38:05.927 SEVERE: Failed to locate image 'bus.png'
With r18360 I get them twice
java -Djosm.home=/tmp/.josm_test -jar /usr/share/josm/josm-tested-18360.jar 2022-01-04 14:43:02.462 INFO: Log level is at INFO (INFO, 800) 2022-01-04 14:43:12.079 INFO: Obtained 82 Tag2Link rules from resource://META-INF/resources/webjars/tag2link/2021.3.21/index.json 2022-01-04 14:43:17.964 INFO: Could not load tool definition icons/splitroundabout 2022-01-04 14:43:17.965 INFO: Could not load tool definition icons/sortptroutemembers 2022-01-04 14:43:18.066 INFO: Could not load tool definition icons/splitroundabout 2022-01-04 14:43:18.066 INFO: Could not load tool definition icons/sortptroutemembers 2022-01-04 14:43:18.135 INFO: loading plugin 'pt_assistant' (version 1ff2e15) 2022-01-04 14:43:18.256 SEVERE: Failed to locate image 'bus.png'
This was a test with empty preferences and installing only pt_assistant and restarts after installation and after JOSM and plugin upgrade. Plugin did not change.
Plugins: + pt_assistant (1ff2e15)
comment:9 by , 3 years ago
That's a different story, but yes, the messages appear twice now because the refresh is also triggered when the presets are modified. I guess the pt_plugin does that.
comment:10 by , 3 years ago
I get two log entries with my plugin too, when the toolbar button is visible.
edit:
- it isn't calling
MainApplication.getToolbar().refreshToolbarControl()
and - uses
JosmAction(String name, String iconName, String tooltip, Shortcut shortcut, boolean registerInToolbar)
constructor with registerInToolbar=true
comment:11 by , 3 years ago
The reason for these messages is that the preference toolbar
is processed before the plugins are loaded. This contains icons/actions from the plugins, so that fails at that stage. Later, when all plugins are loaded, the toolbar is refreshed and the actions are found.
The refresh is now also triggered when the presets are loaded, that's why the messages appear more often.
I've no idea under what circumstances the info message really indicates a problem.
Would it help if the message text would be changed to "Could not yet load tool definition "?
comment:12 by , 3 years ago
What about showing this message only after the plugins are loaded and suppress it before? The message makes only sense for cases where toolbar actions really can't be shown, i.e. actions from removed plugins and so on.
comment:13 by , 3 years ago
Yes, sounds good. Will try to find out how and where to pass that information to the ToolbarPreferences
instance...
by , 3 years ago
Attachment: | 6725.patch added |
---|
comment:14 by , 3 years ago
Milestone: | → 22.01 |
---|---|
Summary: | Plugins need to be loaded before tool definitions for toolbar buttons (WAS: Missing tool definition in utilsplugin2 when item placed in toolbar) → [Patch] Plugins need to be loaded before tool definitions for toolbar buttons (WAS: Missing tool definition in utilsplugin2 when item placed in toolbar) |
No idea if this is a good way to do it but it solves the problem and still shows the message when something is really missing, e.g. after uninstalling the pt_assistant plugin.
This is not the plugin's bug. JOSM tries to load tool definitions for toolbar buttons before it loads plugins, and, obviously, fails. Everything works fine after plugins are loaded.