Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix vrange min/max adjusting when min exceeds max #3232

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter...
Filter file types
Jump to…
Jump to file or symbol
Failed to load files and symbols.
+5 −6
Diff settings

Always

Just for now

@@ -329,12 +329,7 @@ local function formspec(tabview, name, tabdata)
viewing_range_max_to_scrollbar() .. "]" ..
"tooltip[sb_viewing_range_max;" .. fgettext("Maximal Viewing Range: $1 nodes",
get_vrange_max) .. "]"

if (get_vrange_min == nil and get_vrange_min > get_vrange_max) then
core.setting_set("viewing_range_nodes_min", get_vrange_max)
end
elseif (core.setting_getbool("viewing_range_auto") == nil or
core.setting_getbool("viewing_range_auto") == false) then
else
tab_string = tab_string ..
"box[3.75,3.5;3.75,1.5;#999999]" ..
"label[3.85,3.5;" .. fgettext("Viewing Range :") .. "]" ..
@@ -346,6 +341,9 @@ local function formspec(tabview, name, tabdata)
"checkbox[3.85,4.3;cb_vrange_auto_adjust;" .. fgettext("Auto-adjust") .. ";" ..
dump(core.setting_getbool("viewing_range_auto")) .. "]"
end
if get_vrange_min > get_vrange_max then

This comment has been minimized.

Copy link
@kwolekr

kwolekr Oct 15, 2015

Contributor

This would crash if either of these variables are nil.

This comment has been minimized.

Copy link
@est31

est31 Oct 15, 2015

Contributor

How can they be nil?

This comment has been minimized.

This comment has been minimized.

Copy link
@kwolekr

kwolekr Oct 15, 2015

Contributor

Okay, fair enough. But what if a user accidentally sets it to a string value instead?

This comment has been minimized.

Copy link
@kilbith

kilbith Oct 15, 2015

Author Contributor

But what if a user accidentally sets it to a string value instead?

This doesn't cause an error at least. If max is a string, min is only considered (and vice-versa). If both are string, the vrange is set to 15.

core.setting_set("viewing_range_nodes_min", get_vrange_max)

This comment has been minimized.

Copy link
@kwolekr

kwolekr Oct 15, 2015

Contributor

Why have this correction after the formspec has already been rendered?

This comment has been minimized.

Copy link
@kilbith

kilbith Oct 15, 2015

Author Contributor
  1. This is always being rendered within the function formspec(), scrollbar is dynamically updated according to values and inversely.
  2. This checking deals only with the setting values, thus that doesn't matter which string the formspec currently has (i.e. it behaves the same than in the if statement or everywhere else, just matter of style).

And no, this ain't a dupe of previous PR, the condition has changed.

end

return tab_string
end
@@ -509,3 +507,4 @@ tab_settings = {
cbf_formspec = formspec,
cbf_button_handler = handle_settings_buttons
}

ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.