| 208 | | static int signal_emit_real(Signal *rec, int params, va_list va, |
| 209 | | SignalHook *first_hook) |
| 210 | | { |
| 211 | | const void *arglist[SIGNAL_MAX_ARGUMENTS];
|
| 212 | | Signal *prev_emitted_signal; |
| 213 | | SignalHook *hook, *prev_emitted_hook; |
| 214 | | int i, stopped, stop_emit_count, continue_emit_count; |
| 215 | | |
| 216 | | for (i = 0; i < SIGNAL_MAX_ARGUMENTS; i++)
|
| 217 | | arglist[i] = i >= params ? NULL : va_arg(va, const void *);
|
| 218 | | |
| 219 | | |
| 220 | | |
| 221 | | stop_emit_count = rec->stop_emit; |
| 222 | | continue_emit_count = rec->continue_emit; |
| 223 | | |
| 224 | | signal_ref(rec);
|
| 225 | | |
| 226 | | stopped = FALSE;
|
| 227 | | rec->emitting++; |
| 228 | | |
| 229 | | prev_emitted_signal = current_emitted_signal; |
| 230 | | prev_emitted_hook = current_emitted_hook; |
| 231 | | current_emitted_signal = rec; |
| 232 | | |
| 233 | | for (hook = first_hook; hook != NULL; hook = hook->next) {
|
| 234 | | if (hook->func == NULL)
|
| 235 | | continue; |
| 236 | | |
| 237 | | current_emitted_hook = hook; |
| 238 | | #if SIGNAL_MAX_ARGUMENTS != 6
|
| 239 | | # error SIGNAL_MAX_ARGUMENTS changed - update code |
| 240 | | #endif |
| 241 | | signal_user_data = hook->user_data; |
| 242 | | hook->func(arglist[0], arglist[1], arglist[2], arglist[3], |
| 243 | | arglist[4], arglist[5]); |
| 244 | | |
| 245 | | if (rec->continue_emit != continue_emit_count) |
| 246 | | rec->continue_emit--; |
| 247 | | |
| 248 | | if (rec->stop_emit != stop_emit_count) { |
| 249 | | stopped = TRUE;
|
| 250 | | rec->stop_emit--; |
| 251 | | break; |
| 252 | | } |
| 253 | | } |
| 254 | | |
| 255 | | current_emitted_signal = prev_emitted_signal; |
| 256 | | current_emitted_hook = prev_emitted_hook; |
| 257 | | |
| 258 | | rec->emitting--; |
| 259 | | signal_user_data = NULL;
|
| 260 | | |
| 261 | | if (!rec->emitting) { |
| 262 | | g_assert(rec->stop_emit == 0);
|
| 263 | | g_assert(rec->continue_emit == 0);
|
| 264 | | |
| 265 | | if (rec->remove_count > 0) |
| 266 | | signal_hooks_clean(rec); |
| 267 | | } |
| 268 | | |
| 269 | | signal_unref(rec);
|
| 270 | | return stopped; |
| 271 | | } |