Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix loading of custom rendering files containing dashes and underscores (regression) #3296

Merged
merged 1 commit into from Dec 8, 2016

Conversation

njohnston
Copy link
Contributor

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:

app.getRendererRegistry().getRenderer(renderer);

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:

    if(!hasRender(name)){
      return null;
    }

hasRender() just checks that the supplied name exists in one of two collections: externalRenderers and internalRenderers. My custom renderer was an external one so I dumped externalRenderers:

externalRenderers: {GPX_routes_without_dashes=/storage/emulated/0/osmand/rendering/GPX_routes_without_dashes.render.xml}

Immediately I realised the problem. My custom rendering file is named GPX_routes_without_dashes.render.xml. Its entry in externalRenderers is GPX_routes_without_dashes but OsmAnd is looking for GPX 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 creating visibleNamesList.

Selecting a custom rendering style whose filename contains one or more
dashes or underscores failed with a "Exception occurred: renderer was not
loaded" message.

This was because since commit 7fc7b5a,
dashes and underscores in custom rendering style names are replaced by
spaces for display and selection, but stored with dashes and underscores in
externalRenderers in RendererRegistry.

The fix is to apply the same processing to each renderer name when
inserting into externalRenderers as when creating visibleNamesList.
@vshcherb vshcherb merged commit 9780909 into osmandapp:master Dec 8, 2016
@vshcherb
Copy link
Member

vshcherb commented Dec 8, 2016

Thanks for fix!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants