]> git.vpit.fr Git - perl/scripts/xchat.git/blobdiff - Xchat/XPI.pm
Fix loading with recentish Xchat/HexChat
[perl/scripts/xchat.git] / Xchat / XPI.pm
index ff98ec762b9150f59e1ed50a680eded1469113d5..1d9236454c1ef9d715d77a50c30ce55654b5aee0 100644 (file)
@@ -23,7 +23,8 @@ sub new {
  $class    = ref($class) || $class;
  my %opts  = @_;
 
  $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';
  }
  unless (defined $opts{tag}) {
   $opts{tag}     = ($caller =~ /([^:]*):*$/) ? $1 : 'UNKNOWN';
  }
@@ -52,6 +53,10 @@ sub new {
  *$ph->{$_}  = $opts{$_} for @attributes;
  *$ph->{buf} = '';
 
  *$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<name version banner>}, sub {
   $ph->flush;
   if (*$ph->{atexit_id}) {
  Xchat::register(@opts{qw<name version banner>}, sub {
   $ph->flush;
   if (*$ph->{atexit_id}) {