fix case when state hook was added more than once
authorcompudj <compudj@04897980-b3bd-0310-b5e0-8ef037075253>
Thu, 29 Jul 2004 21:16:24 +0000 (21:16 +0000)
committercompudj <compudj@04897980-b3bd-0310-b5e0-8ef037075253>
Thu, 29 Jul 2004 21:16:24 +0000 (21:16 +0000)
git-svn-id: http://ltt.polymtl.ca/svn@647 04897980-b3bd-0310-b5e0-8ef037075253

ltt/branches/poly/lttv/modules/gui/lttvwindow/lttvwindow/init_module.c
ltt/branches/poly/lttv/modules/gui/lttvwindow/lttvwindow/lttvwindowtraces.c

index 89d7fea7e03e0227ea37aca04706ea5c1d4f5ff1..a4e7d4272dfd9b9cc6a5db88d391f35a0f0e91c1 100644 (file)
@@ -185,9 +185,13 @@ static void init() {
     LttvHooks *hook_adder = lttv_hooks_new();
     lttv_hooks_add(hook_adder, lttv_state_save_hook_add_event_hooks, NULL,
                    LTTV_PRIO_DEFAULT);
+    lttv_hooks_add(hook_adder, lttv_state_hook_add_event_hooks, NULL,
+                   LTTV_PRIO_DEFAULT);
     LttvHooks *hook_remover = lttv_hooks_new();
     lttv_hooks_add(hook_remover, lttv_state_save_hook_remove_event_hooks,
                                     NULL, LTTV_PRIO_DEFAULT);
+    lttv_hooks_add(hook_remover, lttv_state_hook_remove_event_hooks,
+                                    NULL, LTTV_PRIO_DEFAULT);
     /* Add state computation background hook adder to attributes */
     lttvwindowtraces_register_computation_hooks(g_quark_from_string("state"),
         NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
@@ -199,9 +203,13 @@ static void init() {
     LttvHooks *hook_adder = lttv_hooks_new();
     lttv_hooks_add(hook_adder, lttv_stats_hook_add_event_hooks, NULL,
                    LTTV_PRIO_DEFAULT);
+    lttv_hooks_add(hook_adder, lttv_state_hook_add_event_hooks, NULL,
+                   LTTV_PRIO_DEFAULT);
     LttvHooks *hook_remover = lttv_hooks_new();
     lttv_hooks_add(hook_remover, lttv_stats_hook_remove_event_hooks,
                                     NULL, LTTV_PRIO_DEFAULT);
+    lttv_hooks_add(hook_remover, lttv_state_hook_remove_event_hooks,
+                                    NULL, LTTV_PRIO_DEFAULT);
     LttvHooks *after_request = lttv_hooks_new();
     lttv_hooks_add(after_request, lttv_stats_sum_traceset_hook, NULL,
         LTTV_PRIO_DEFAULT);
index 1ce869990fe2e10ee69ad30f18e4b7773daf913d..7e83fc30a22aa6065dfd457b7ab13e7f55bf8eb7 100644 (file)
@@ -548,7 +548,8 @@ void lttvwindowtraces_background_notify_remove(gpointer owner)
 /* Background processing helper functions */
 
 void lttvwindowtraces_add_computation_hooks(LttvAttributeName module_name,
-                                            LttvTracesetContext *tsc)
+                                            LttvTracesetContext *tsc,
+                                            LttvHooks *hook_adder)
 {
   LttvAttribute *g_attribute = lttv_global_attributes();
   LttvAttribute *module_attribute;
@@ -611,7 +612,9 @@ void lttvwindowtraces_add_computation_hooks(LttvAttributeName module_name,
                                      LTTV_HOOK_ADDER,
                                      &value);
   if(type == LTTV_POINTER) {
-    lttv_hooks_call((LttvHooks*)*(value.v_pointer), (gpointer)tss);
+    //lttv_hooks_call((LttvHooks*)*(value.v_pointer), (gpointer)tss);
+    if(hook_adder != NULL)
+      lttv_hooks_add_list(hook_adder, (LttvHooks*)*(value.v_pointer));
   }
 
 
@@ -626,7 +629,8 @@ void lttvwindowtraces_add_computation_hooks(LttvAttributeName module_name,
 }
                                             
 void lttvwindowtraces_remove_computation_hooks(LttvAttributeName module_name,
-                                               LttvTracesetContext *tsc)
+                                               LttvTracesetContext *tsc,
+                                               LttvHooks *hook_remover)
 {
   LttvAttribute *g_attribute = lttv_global_attributes();
   LttvAttribute *module_attribute;
@@ -695,7 +699,9 @@ void lttvwindowtraces_remove_computation_hooks(LttvAttributeName module_name,
                                      LTTV_HOOK_REMOVER,
                                      &value);
   if(type == LTTV_POINTER) {
-    lttv_hooks_call((LttvHooks*)*(value.v_pointer), (gpointer)tss);
+    //lttv_hooks_call((LttvHooks*)*(value.v_pointer), (gpointer)tss);
+    if(hook_remover != NULL)
+      lttv_hooks_add_list(hook_remover, (LttvHooks*)*(value.v_pointer));
   }
 }
 
@@ -997,6 +1003,7 @@ gboolean lttvwindowtraces_process_pending_requests(LttvTrace *trace)
 
     {
       GSList *iter = *list_in;
+      LttvHooks *hook_adder = lttv_hooks_new();
       /* - for each request in list_in */
       while(iter != NULL) {
         
@@ -1004,9 +1011,12 @@ gboolean lttvwindowtraces_process_pending_requests(LttvTrace *trace)
         /*- Call before chunk hooks for list_in*/
         /*- add hooks to context*/
         lttvwindowtraces_add_computation_hooks(bg_req->module_name,
-                                               tsc);
+                                               tsc,
+                                               hook_adder);
         iter = g_slist_next(iter);
       }
+      lttv_hooks_call(hook_adder,tsc);
+      lttv_hooks_destroy(hook_adder);
     }
   }
 
@@ -1024,6 +1034,7 @@ gboolean lttvwindowtraces_process_pending_requests(LttvTrace *trace)
     /*  3.1 call after_chunk hooks for list_in */
     {
       GSList *iter = *list_in;
+      LttvHooks *hook_remover = lttv_hooks_new();
       /* - for each request in list_in */
       while(iter != NULL) {
         
@@ -1031,9 +1042,12 @@ gboolean lttvwindowtraces_process_pending_requests(LttvTrace *trace)
         /* - Call after chunk hooks for list_in */
         /* - remove hooks from context */
         lttvwindowtraces_remove_computation_hooks(bg_req->module_name,
-                                                  tsc);
+                                                  tsc,
+                                                  hook_remover);
         iter = g_slist_next(iter);
       }
+      lttv_hooks_call(hook_remover,tsc);
+      lttv_hooks_destroy(hook_remover);
     }
 
     /* 3.2 for each notify_in */
@@ -1174,6 +1188,11 @@ gboolean lttvwindowtraces_process_pending_requests(LttvTrace *trace)
             }
           }
         }
+        {
+          /* - reset the context */
+          LTTV_TRACESET_CONTEXT_GET_CLASS(tsc)->fini(tsc);
+          LTTV_TRACESET_CONTEXT_GET_CLASS(tsc)->init(tsc,ts);
+        }
         /* - if list_out is empty */
         if(g_slist_length(*list_out) == 0) {
           /* - return FALSE (scheduler stopped) */
This page took 0.02723 seconds and 4 git commands to generate.