Modify

Opened 6 years ago

Closed 6 years ago

Last modified 6 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 6 years ago.
PreferencesSetDefaultValues.2.patch (3.7 KB) - added by kolesar 6 years ago.

Download all attachments as: .zip

Change History (6)

Changed 6 years ago by kolesar

comment:1 in reply to:  description ; Changed 6 years ago by bastiK

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?

Version 0, edited 6 years ago by bastiK (next)

comment:2 in reply to:  1 Changed 6 years ago by kolesar

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.

Changed 6 years ago by kolesar

comment:3 Changed 6 years ago by bastiK

Resolution: fixed
Status: newclosed

In 9689/josm:

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

comment:4 Changed 6 years ago by bastiK

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.

Add Comment


E-mail address and name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.