return unless @_ >= 2;
my $code = pop;
my $new_cxt = (@_ == 1) ? $_[0] : find_context(@_);
+ return undef unless defined $new_cxt;
my $cur_cxt = get_context;
+ my $guard = bless \$cur_cxt, 'Xchat::XPI::Utils::ContextGuard';
if (set_context $new_cxt) {
- my $guard = bless \$cur_cxt, 'Xchat::XPI::Utils::ContextGuard';
return $code->();
} else {
return undef;