diff options
author | Oliver Tappe | 2008-05-25 00:40:33 +0200 |
---|---|---|
committer | Oliver Tappe | 2008-05-25 00:40:33 +0200 |
commit | bc6c812ba80f26b8445e8dbd35c79a2b8f2f3da9 (patch) | |
tree | 04e25f65674502d6f187dc3a92570a7466878f9e /lib/OpenSLX/Basics.pm | |
parent | stupid is as stupid does or murphys law (diff) | |
download | core-bc6c812ba80f26b8445e8dbd35c79a2b8f2f3da9.tar.gz core-bc6c812ba80f26b8445e8dbd35c79a2b8f2f3da9.tar.xz core-bc6c812ba80f26b8445e8dbd35c79a2b8f2f3da9.zip |
* fixed problem in module loading code that under some circumstances led to modules
being loaded several times (which in turn produced warnings about functions being
redefined)
git-svn-id: http://svn.openslx.org/svn/openslx/openslx/trunk@1800 95ad53e4-c205-0410-b2fa-d234c58c8868
Diffstat (limited to 'lib/OpenSLX/Basics.pm')
-rw-r--r-- | lib/OpenSLX/Basics.pm | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/lib/OpenSLX/Basics.pm b/lib/OpenSLX/Basics.pm index 679b9acb..07ab364b 100644 --- a/lib/OpenSLX/Basics.pm +++ b/lib/OpenSLX/Basics.pm @@ -605,9 +605,11 @@ sub instantiateClass $moduleName .= '.pm'; vlog(3, "trying to load $moduleName..."); - my @originalINC = @INC; - if (!eval { unshift @INC, @$incPaths; require $moduleName; 1 } ) { - @INC = @originalINC; + foreach my $incPath (@$incPaths) { + next if grep { $_ eq $incPath } @INC; + unshift @INC, $incPath; + } + if (!eval { require $moduleName; 1 } ) { # check if module does not exists anywhere in search path if (!-e $moduleName) { return if $flags->{acceptMissing}; @@ -616,7 +618,6 @@ sub instantiateClass # some other error (probably compilation problems) die _tr("Unable to load module '%s' (%s)\n", $moduleName, $@); } - @INC = @originalINC; if (defined $requestedVersion) { my $classVersion = $class->VERSION; if ($classVersion < $requestedVersion) { @@ -682,7 +683,6 @@ you can specify that base path via the I<$pathToClass> param. =cut - sub loadDistroModule { my $params = shift; @@ -724,8 +724,7 @@ sub loadDistroModule vlog(1, "trying ${distroScope}::$distroModule ..."); my $flags = { acceptMissing => 1 }; if ($pathToClass) { - $flags->{pathToClass} = $pathToClass; - $flags->{incPaths} = [ $pathToClass ]; + $flags->{incPaths} = [ $pathToClass ]; } $distro = instantiateClass("${distroScope}::$distroModule", $flags); return 0 if !$distro; # module does not exist, try next |