aboutsummaryrefslogtreecommitdiffhomepage
path: root/event.cpp
diff options
context:
space:
mode:
authorGravatar ridiculousfish <corydoras@ridiculousfish.com>2012-02-17 11:36:49 -0800
committerGravatar ridiculousfish <corydoras@ridiculousfish.com>2012-02-17 11:37:25 -0800
commit9787901ddb05d3ceb4ed4fc66b76581acc37d62e (patch)
treee8478d3eab028eca5713c3e69e773c898e7ee5a0 /event.cpp
parent6e58c9f7c8f21b4e5eaa698d275eefe013117cdf (diff)
Fix for removing too many event handlers (that's why "Goodbye" never got printed")
Diffstat (limited to 'event.cpp')
-rw-r--r--event.cpp25
1 files changed, 19 insertions, 6 deletions
diff --git a/event.cpp b/event.cpp
index 69d7f83f..c6d31b03 100644
--- a/event.cpp
+++ b/event.cpp
@@ -85,12 +85,12 @@ static event_list_t blocked;
they must name the same function.
*/
-static int event_match( event_t *classv, event_t *instance )
+static int event_match( const event_t *classv, const event_t *instance )
{
if( ! classv->function_name.empty() && ! instance->function_name.empty() )
{
- if( classv->function_name == instance->function_name )
+ if( classv->function_name != instance->function_name )
return 0;
}
@@ -164,7 +164,7 @@ static int event_is_blocked( event_t *e )
return event_block_list_blocks_type(parser.global_event_blocks, e->type);
}
-wcstring event_get_desc( event_t *e )
+wcstring event_get_desc( const event_t *e )
{
CHECK( e, 0 );
@@ -221,6 +221,14 @@ wcstring event_get_desc( event_t *e )
return result;
}
+static void show_all_handlers(void) {
+ puts("event handlers:");
+ for (event_list_t::const_iterator iter = events.begin(); iter != events.end(); iter++) {
+ const event_t *foo = *iter;
+ wcstring tmp = event_get_desc(foo);
+ printf(" handler now %ls\n", tmp.c_str());
+ }
+}
void event_add_handler( event_t *event )
{
@@ -234,12 +242,15 @@ void event_add_handler( event_t *event )
{
signal_handle( e->param1.signal, 1 );
}
-
+
events.push_back(e);
+
+ show_all_handlers();
}
void event_remove( event_t *criterion )
{
+
size_t i;
event_list_t new_list;
@@ -284,6 +295,7 @@ void event_remove( event_t *criterion )
}
}
events.swap(new_list);
+ show_all_handlers();
}
int event_get( event_t *criterion, std::vector<event_t *> *out )
@@ -332,8 +344,9 @@ static int event_is_killed( event_t *e )
optimize the 'no matches' path. This means that nothing is
allocated/initialized unless needed.
*/
-static void event_fire_internal( event_t *event )
+static void event_fire_internal( const event_t *event )
{
+
size_t i, j;
event_list_t fire;
@@ -411,7 +424,7 @@ static void event_fire_internal( event_t *event )
prev_status = proc_get_last_status();
parser_t &parser = parser_t::principal_parser();
parser.push_block( EVENT );
- parser.current_block->state1<event_t *>() = event;
+ parser.current_block->state1<const event_t *>() = event;
parser.eval( buffer.c_str(), 0, TOP );
parser.pop_block();
proc_pop_interactive();