Fix loading of custom rendering files containing dashes and underscores (regression) #3296
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
After I upgraded to OsmAnd+ 2.5.3, I noticed that my custom rendering file could not be selected. I got this toast: "Exception occurred: renderer was not loaded". Several people on the forum reported the same problem.
I couldn't see any exception in logcat, so I investigated in more detail. In src/net/osmand/plus/dialogs/ConfigureMapMenu.java I could see that the toast is generated if this code returns null:
getRenderer()
only returns null if the specified renderer cannot be found, or an exception occurs. I added some debug code and found that the specified renderer could not be found, so null was being returned here:hasRender()
just checks that the supplied name exists in one of two collections:externalRenderers
andinternalRenderers
. My custom renderer was an external one so I dumpedexternalRenderers
:Immediately I realised the problem. My custom rendering file is named GPX_routes_without_dashes.render.xml. Its entry in
externalRenderers
isGPX_routes_without_dashes
but OsmAnd is looking forGPX routes without dashes
(spaces instead of underscores).This used to work. I think it was regressed in 7fc7b5a.
The fix is to apply the same processing to each renderer name when inserting into
externalRenderers
as when creatingvisibleNamesList
.