#12454 closed defect (fixed)
[patch] set default values of preferences on construct
Reported by: | kolesar | Owned by: | team |
---|---|---|---|
Priority: | normal | Milestone: | 16.02 |
Component: | Core | Version: | |
Keywords: | Cc: |
Description
Preferences that are not set in preferences.xml are hidden from Einstein preferences page until they are read at the first time. Creating org.openstreetmap.josm.data.preferences.*Property
instances is not enough, they don't set default values on construct.
Added get() at end of Property constuctors that sets default values in preferences. First tried to add it to AbstractProperty
but some child classes add properties later on construct that are missing at invoking get() before. Constructor of AbstractProperty creates Main.pref if it is null, because some classes create property objects without calling MainApplication (for example build task epsg
).
Attachments (2)
Change History (6)
by , 9 years ago
Attachment: | PreferencesSetDefaultValues.patch added |
---|
comment:2 by , 9 years ago
Replying to bastiK:
Replying to kolesar:
Constructor of AbstractProperty creates Main.pref if it is null, because some classes create property objects without calling MainApplication (for example build task
epsg
).
I don't like this. Can the classes that use properties without initialization be fixed instead? Edit: Or call
get()
only ifMain.pref != null
.
I have chosen this central solution because classes (and their programmers) need not to know what is required for that specific class.
Updated patch to call get() if Main.pref is available.
by , 9 years ago
Attachment: | PreferencesSetDefaultValues.2.patch added |
---|
comment:4 by , 9 years ago
Milestone: | → 16.02 |
---|
Replying to kolesar:
What you are doing here is only a mini-step towards solving the problem. Not only are the majority of preferences created by direct calls to
Main.pref.get...(String)
and notProperty
objects. ButProperty
objects are not loaded before the corresponding class is loaded, so they are not necessarily constructed when JOSM starts up.I don't like this. Can the classes that use properties without initialization be fixed instead? Edit: Or call
get()
only ifMain.pref != null
.