Modify

Opened 9 years ago

Closed 9 years ago

Last modified 9 years ago

#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)

PreferencesSetDefaultValues.patch (4.0 KB ) - added by kolesar 9 years ago.
PreferencesSetDefaultValues.2.patch (3.7 KB ) - added by kolesar 9 years ago.

Download all attachments as: .zip

Change History (6)

by kolesar, 9 years ago

in reply to:  description ; comment:1 by bastiK, 9 years ago

Replying to kolesar:

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.

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 not Property objects. But Property objects are not loaded before the corresponding class is loaded, so they are not necessarily constructed when JOSM starts up.

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 if Main.pref != null.

Last edited 9 years ago by bastiK (previous) (diff)

in reply to:  1 comment:2 by kolesar, 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 if Main.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 kolesar, 9 years ago

comment:3 by bastiK, 9 years ago

Resolution: fixed
Status: newclosed

In 9689/josm:

applied #12454 - set default values of preferences on construct (patch by kolesar)

comment:4 by bastiK, 9 years ago

Milestone: 16.02

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.