From aa429131a379cdbfb9b8e75cb27b5707a219fcd0 Mon Sep 17 00:00:00 2001 From: Tom Feist Date: Fri, 8 Apr 2011 20:53:03 +0100 Subject: add sig_unbind as a demonstration of the signal_remove coderef bug, and a patch to fix it. --- feature-tests/sig_unbind.pl | 58 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 feature-tests/sig_unbind.pl (limited to 'feature-tests') diff --git a/feature-tests/sig_unbind.pl b/feature-tests/sig_unbind.pl new file mode 100644 index 0000000..3123182 --- /dev/null +++ b/feature-tests/sig_unbind.pl @@ -0,0 +1,58 @@ +use strict; +use warnings; + + +use Irssi (@Irssi::EXPORT_OK); +use Irssi::Irc; +use Irssi::TextUI; + +use Data::Dumper; + + +our $VERSION = '0.1'; +our %IRSSI = ( + authors => 'shabble', + contact => 'shabble+irssi@metavore.org', + name => '', + description => '', + license => 'Public Domain', + ); + +command_bind("dosig_r", + sub { + my $ref = \&cmd_oink; + _print("binding oink to $ref"); + signal_add("command oink", $ref); + }); + +command_bind("undosig_r", + sub { + my $ref = \&cmd_oink; + + _print("unbinding oink from $ref"); + + signal_remove("command oink", $ref); + }); + +command_bind("dosig_s", + sub { + signal_add("command oink", 'cmd_oink'); + }); + +command_bind("undosig_s", + sub { + signal_remove("command oink", 'cmd_oink'); + }); + +sub cmd_oink { + Irssi::active_win()->print("Oink:"); +} + +sub _print { + Irssi::active_win()->print($_[0]); +} + +command("dosig_r"); +command("oink"); +command("undosig_r"); +command("oink"); -- cgit v1.2.3