From 1c49f817fddba9ce315bb070efd6ebe7e826c58b Mon Sep 17 00:00:00 2001 From: poire-z Date: Sat, 25 Jul 2020 23:15:31 +0200 Subject: [PATCH] Fix ConfigDialog's ButtonProgress Fine tune updating presets (#6433) Witnessed with "L/R Margins": tapping on a button sets the value to the preset table, by reference. Tapping the -/+ fine tuning buttons was updating these tables in-place, in effect modifying the presets. --- frontend/ui/widget/configdialog.lua | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/frontend/ui/widget/configdialog.lua b/frontend/ui/widget/configdialog.lua index 980f5d985..08af59e58 100644 --- a/frontend/ui/widget/configdialog.lua +++ b/frontend/ui/widget/configdialog.lua @@ -997,12 +997,17 @@ function ConfigDialog:onConfigFineTuneChoose(values, name, event, args, events, if direction == "-" then value = self.configurable[name] or values[1] if type(value) == "table" then + -- Don't update directly this table: it might be a reference + -- to one of the original preset values tables + local updated = {} for i=1, #value do - value[i] = value[i] - 1 - if value[i] < 0 then - value[i] = 0 + local v = value[i] - 1 + if v < 0 then + v = 0 end + table.insert(updated, v) end + value = updated else value = value - 1 if value < 0 then @@ -1012,9 +1017,11 @@ function ConfigDialog:onConfigFineTuneChoose(values, name, event, args, events, else value = self.configurable[name] or values[#values] if type(value) == "table" then + local updated = {} for i=1, #value do - value[i] = value[i] + 1 + table.insert(updated, value[i] + 1) end + value = updated else value = value + 1 end