Project

General

Profile

Bug #12294

Default value in Lua Preferences behavior issues

Added by Philippe Weyland 3 months ago. Updated 3 months ago.

Status:
Fixed
Priority:
Low
Category:
Lua
Target version:
Start date:
08/14/2018
Due date:
% Done:

100%

Affected Version:
git master branch
System:
Windows
bitness:
64-bit
hardware architecture:
amd64/x86

Description

1. I see an inconsistent and/or strange behaviour depending on the presence or not of preferences.read before preferences.register in my code.
2. Double click to reset to default value doesn't work.

1.1. Code without preferences read before preferences register

dt.preferences.register("module_OpenInApp", "bin_path",    -- name
    "file",    -- type
    'OpenInApp: Application location',    -- label
    'Location of Application executable',    -- tooltip
    '(Not Set)'    -- default
)

In dt, value is set to '(None)' which makes sense but doesn't correspond to the set default value.
See attached file "Without_pref_read.png

After exiting dt I get this line in darktablerc:

lua/module_OpenInApp/bin_path=C:\Users\philippe\(Not Set)

With dt 2.4.4 I get
lua/module_OpenInApp/bin_path=(Not Set)

1.2. Code with preferences read before preferences register

bin_path = dt.preferences.read("module_OpenInApp", "bin_path", "file")
dt.preferences.register("module_OpenInApp", "bin_path",    -- name
    "file",    -- type
    'OpenInApp: Application location',    -- label
    'Location of Application executable',    -- tooltip
    '(Not Set)'    -- default
)

In dt, value is set to 'Philippe', i.e. my user folder, which can make sense but doesn't correspond to the set default value nor to get executable files.

See attached file "With_pref_read.png

After exiting dt I get this line in darktablerc (same with 2.4.4):

lua/module_OpenInApp/bin_path=

With_pref_read.png (6.75 KB) Philippe Weyland, 08/14/2018 11:30 PM

Without_pref_read.png (6.22 KB) Philippe Weyland, 08/14/2018 11:30 PM

History

#1 Updated by Tobias Ellinghaus 3 months ago

  • % Done changed from 0 to 100
  • Status changed from New to Fixed

The double click reset should be working now. Thanks for reporting.

#2 Updated by Philippe Weyland 3 months ago

Thanks Tobias. Double click reset works now.

But the default behaviour remains a bit strange and prevents to initialize properly the plugin.
I think that before any change or after reset we should always get a predictable value (as the default one (Edit: or nil value as, per principle, before registering dt doesn't know the default value)).
This is not the case.

After a reset I see the following values. Hopefully the default value is included, so that manageable.
- darktablerc: lua/module_OpenInApp/bin_path=C:\Users\philippe\(Not Set)
- preferences read: LUA pref bin_path C:\Users\philippe\(Not Set)

Here is what I get the first time I activate the plugin.
Without read before register:
- darktablerc: lua/module_OpenInApp/bin_path=(Not Set) Which is the actual default value.
With a read before register
- darktablerc: lua/module_OpenInApp/bin_path=
- preferences read: LUA pref bin_path

If I open lua preferences without making any change the values become the following:
Without read before register:
- darktablerc: lua/module_OpenInApp/bin_path=C:\Users\philippe\(Not Set)
With a read before register
- darktablerc: lua/module_OpenInApp/bin_path=C:\Users\philippe
- preferences read: LUA pref bin_path C:\Users\philippe

#3 Updated by Roman Lebedev 3 months ago

  • Target version set to 2.6.0

Also available in: Atom PDF