1
0
mirror of https://github.com/irssi/irssi.git synced 2024-12-04 14:46:39 -05:00

"return 1" doesn't anymore stop signals in perl scripts. Fixed

Irssi::signal_stop() to properly stop the signal from going to other
perl scripts.


git-svn-id: http://svn.irssi.org/repos/irssi/trunk@1086 dbcabf3a-b0e7-0310-adc4-f8d773084564
This commit is contained in:
Timo Sirainen 2001-01-07 08:23:06 +00:00 committed by cras
parent a2d9661982
commit 14dbcd00bf
4 changed files with 20 additions and 18 deletions

View File

@ -318,6 +318,17 @@ int signal_get_emitted_id(void)
return rec->id;
}
/* return TRUE if specified signal was stopped */
int signal_is_stopped(int signal_id)
{
SIGNAL_REC *rec;
rec = g_hash_table_lookup(signals, GINT_TO_POINTER(signal_id));
g_return_val_if_fail(rec != NULL, FALSE);
return rec->emitting <= rec->stop_emit;
}
static void signal_remove_module(void *signal, SIGNAL_REC *rec,
const char *module)
{

View File

@ -42,6 +42,8 @@ void signal_stop_by_name(const char *signal);
const char *signal_get_emitted(void);
/* return the ID of the signal that is currently being emitted */
int signal_get_emitted_id(void);
/* return TRUE if specified signal was stopped */
int signal_is_stopped(int signal_id);
/* remove all signals that belong to `module' */
void signals_remove_module(const char *module);

View File

@ -49,8 +49,8 @@ static PERL_SIGNAL_ARGS_REC *perl_signal_args_find(int signal_id)
return NULL;
}
static int perl_call_signal(const char *func, int signal_id,
gconstpointer *args)
static void perl_call_signal(const char *func, int signal_id,
gconstpointer *args)
{
dSP;
int retcount, ret;
@ -106,28 +106,18 @@ static int perl_call_signal(const char *func, int signal_id,
}
PUTBACK;
retcount = perl_call_pv((char *) func, G_EVAL|G_SCALAR);
retcount = perl_call_pv((char *) func, G_EVAL|G_DISCARD);
SPAGAIN;
ret = 0;
if (SvTRUE(ERRSV)) {
STRLEN n_a;
signal_emit("gui dialog", 2, "error", SvPV(ERRSV, n_a));
(void)POPs;
} else if (retcount > 0) {
SV *sv = POPs;
if (SvIOK(sv) && SvIV(sv) == 1) ret = 1;
while (--retcount > 0)
(void)POPi;
}
PUTBACK;
FREETMPS;
LEAVE;
return ret;
}
static void sig_func(int priority, gconstpointer *args)
@ -141,10 +131,9 @@ static void sig_func(int priority, gconstpointer *args)
for (tmp = list == NULL ? NULL : *list; tmp != NULL; tmp = tmp->next) {
PERL_SIGNAL_REC *rec = tmp->data;
if (perl_call_signal(rec->func, signal_id, args)) {
signal_stop();
break;
}
perl_call_signal(rec->func, signal_id, args);
if (signal_is_stopped(signal_id))
break;
}
}

View File

@ -317,7 +317,7 @@ static int perl_source_event(PERL_SOURCE_REC *rec)
XPUSHs(sv_2mortal(new_pv(rec->data)));
PUTBACK;
retcount = perl_call_pv(rec->func, G_EVAL|G_SCALAR);
retcount = perl_call_pv(rec->func, G_EVAL|G_DISCARD);
SPAGAIN;
if (SvTRUE(ERRSV)) {