--- rxvt-unicode/src/rxvtperl.xs 2006/01/02 18:20:23 1.3 +++ rxvt-unicode/src/rxvtperl.xs 2006/01/02 19:05:05 1.4 @@ -210,21 +210,14 @@ bool rxvt_perl_interp::invoke (rxvt_term *term, hook_type htype, ...) { - if (!perl) - return false; + // INIT and DESTROY must be requested by the runtime + if (!perl || !should_invoke [htype]) + return false; + if (htype == HOOK_INIT) // first hook ever called term->self = (void *)newSVptr ((void *)term, "urxvt::term"); - else if (htype == HOOK_DESTROY) - { - // TODO: clear magic - hv_clear ((HV *)SvRV ((SV *)term->self)); - SvREFCNT_dec ((SV *)term->self); - } - if (!should_invoke [htype]) - return false; - dSP; va_list ap; @@ -272,6 +265,13 @@ if (SvTRUE (ERRSV)) rxvt_warn ("perl hook %d evaluation error: %s", htype, SvPV_nolen (ERRSV)); + if (htype == HOOK_DESTROY) + { + // TODO: clear magic + hv_clear ((HV *)SvRV ((SV *)term->self)); + SvREFCNT_dec ((SV *)term->self); + } + return count; }