98_structure.pm: even more checks for undefined devices (Forum #32493)

git-svn-id: svn://svn.code.sf.net/p/fhem/code/trunk@7655 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
rudolfkoenig
2015-01-21 19:27:54 +00:00
parent be4abcfd8a
commit 2aed003ffe

View File

@@ -59,9 +59,10 @@ sub
structAdd($$) structAdd($$)
{ {
my ($d, $attrList) = @_; my ($d, $attrList) = @_;
return if(!$defs{$d});
$defs{$d}{INstructAdd} = 1; $defs{$d}{INstructAdd} = 1;
foreach my $c (keys %{$defs{$d}{CONTENT}}) { foreach my $c (keys %{$defs{$d}{CONTENT}}) {
if($defs{$c}{INstructAdd}) { if($defs{$c} && $defs{$c}{INstructAdd}) {
Log 1, "recursive structure definition" Log 1, "recursive structure definition"
} else { } else {
@@ -69,7 +70,7 @@ structAdd($$)
structAdd($c, $attrList) if($defs{$c} && $defs{$c}{TYPE} eq "structure"); structAdd($c, $attrList) if($defs{$c} && $defs{$c}{TYPE} eq "structure");
} }
} }
delete $defs{$d}{INstructAdd}; delete $defs{$d}{INstructAdd} if($defs{$d});
} }
############################# #############################
@@ -93,10 +94,8 @@ structure_Define($$)
foreach my $a (@a) { foreach my $a (@a) {
foreach my $d (devspec2array($a)) { foreach my $d (devspec2array($a)) {
$list{$d} = 1; $list{$d} = 1;
if($init_done) { addToDevAttrList($d, $aList);
addToDevAttrList($d, $aList); structAdd($d, $aList) if($defs{$d} && $defs{$d}{TYPE} eq "structure");
structAdd($d, $aList) if($defs{$d} && $defs{$d}{TYPE} eq "structure");
}
} }
} }
$hash->{CONTENT} = \%list; $hash->{CONTENT} = \%list;