From: Vincent Pit Date: Fri, 20 Nov 2015 13:20:11 +0000 (-0200) Subject: Fix loading with recentish Xchat/HexChat X-Git-Url: http://git.vpit.fr/?a=commitdiff_plain;h=73947ac5;p=perl%2Fscripts%2Fxchat.git Fix loading with recentish Xchat/HexChat --- diff --git a/Xchat/XPI.pm b/Xchat/XPI.pm index ff98ec7..1d92364 100644 --- a/Xchat/XPI.pm +++ b/Xchat/XPI.pm @@ -23,7 +23,8 @@ sub new { $class = ref($class) || $class; my %opts = @_; - my $caller = (caller 0)[0]; + my ($caller, $file) = (caller 0)[0, 1]; + unless (defined $opts{tag}) { $opts{tag} = ($caller =~ /([^:]*):*$/) ? $1 : 'UNKNOWN'; } @@ -52,6 +53,10 @@ sub new { *$ph->{$_} = $opts{$_} for @attributes; *$ph->{buf} = ''; + my $internal_pkg = Xchat::Embed::file2pkg($file); + no warnings 'redefine'; + local *Xchat::Embed::find_pkg = sub { $internal_pkg, $caller }; + local *HexChat::Embed::find_pkg = sub { $internal_pkg, $caller }; Xchat::register(@opts{qw}, sub { $ph->flush; if (*$ph->{atexit_id}) {