Commit 832667ac authored by Stefan Tauner's avatar Stefan Tauner
Browse files

Use 'depends_on' value for enablements checks only if its *dependency's* type is boolean

Previously, in dbdec061, we looked at the wrong field's type.
Also, fix non-boolean use of 'depends_on' in _sanitize_fiu of Settings.pm.
parent 24f78389
......@@ -723,7 +723,7 @@ sub _sanitize_fiu {
sub _disabled_via_dependency {
my ($map_ref, $consts_ref, $k) = @_;
my $dependency = $map_ref->{$k}->{'depends_on'};
return defined($dependency) && !$consts_ref->{$dependency};
return defined($dependency) && $map_ref->{$k}->{'type'} eq 'boolean' && !$consts_ref->{$dependency};
}
sub _validate_hashmap {
......
......@@ -1609,12 +1609,15 @@ sub _validate_entry {
my $logger = get_logger("");
my ($self, $map, $widget, $name, $consts_ref, $new_ref, $diff, $old_str, $char_idx, $change_type) = @_;
# If the entry depends on another one there are two possibilities:
# - if the dependency is of type boolean we regard it as an enable flag and may have to skip validation, or
# - else $dep_ref is set accordingly to be available in validate_value() below if need be.
my $dep_name = $map->{$name}->{'depends_on'};
my $dep_ref;
if (defined($map->{$name}->{'depends_on'})) {
$dep_ref = \$self->{'settings'}->{'design'}->{$map->{$name}->{'depends_on'}};
# don't validate if this entry is disabled
if ($map->{$name}->{'type'} eq 'boolean' and $$dep_ref == 0) {
if (defined($dep_name)) {
$dep_ref = \$self->{'settings'}->{'design'}->{$dep_name};
my $dep_type = DESIGNMAP->{$dep_name}->{'type'};
if ($dep_type eq 'boolean' and $$dep_ref == 0) {
$logger->debug("Don't validate $name as it is disabled.");
$self->_indicate_warning($widget, 0, $map, $name);
return undef;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment