Temporarily remove sync trace call from gui
[lttv.git] / lttv / modules / gui / lttvwindow / lttvwindow / callbacks.c
index 565cec17a76d5876b3eea4395be020d0e483ed0e..5499da30193a4b67562cd49220e9e50feeda20c3 100644 (file)
@@ -39,6 +39,7 @@
 #include <lttv/iattribute.h>
 #include <lttv/stats.h>
 #include <lttv/filter.h>
+#include <lttv/sync/sync_chain_lttv.h>
 #include <lttvwindow/mainwindow.h>
 #include <lttvwindow/mainwindow-private.h>
 #include <lttvwindow/menu.h>
@@ -454,6 +455,7 @@ void insert_viewer(GtkWidget* widget, lttvwindow_viewer_constructor constructor)
   }
 }
 
+
 /**
  * Function to set/update traceset for the viewers
  * @param tab viewer's tab 
@@ -465,11 +467,68 @@ void insert_viewer(GtkWidget* widget, lttvwindow_viewer_constructor constructor)
 
 int SetTraceset(Tab * tab, LttvTraceset *traceset)
 {
+  guint i;
+  TimeInterval time_span;
+  TimeWindow new_time_window;
+  LttTime new_current_time;
   LttvTracesetContext *tsc =
-        LTTV_TRACESET_CONTEXT(tab->traceset_info->traceset_context);
-  TimeInterval time_span = tsc->time_span;
-  TimeWindow new_time_window = tab->time_window;
-  LttTime new_current_time = tab->current_time;
+    LTTV_TRACESET_CONTEXT(tab->traceset_info->traceset_context);
+
+  // Perform time synchronization on the traces
+  /* Mathieu Desnoyers: temporarily disable syncTraceset */
+  //if (syncTraceset(tsc))
+  if (0)
+  {
+    /* There is some time-dependant information that was calculated during
+     * context initialization. Destroy the old contexts and initialize new
+     * ones.
+     * Modified from lttvwindow_add_trace()
+    */
+    // Keep a reference to the traces so they are not freed
+    for(i = 0; i < lttv_traceset_number(traceset); i++)
+    {
+      LttvTrace *trace = lttv_traceset_get(traceset, i);
+      lttv_trace_ref(trace);
+    }
+
+    // Remove state update hooks
+    lttv_state_remove_event_hooks(
+      (LttvTracesetState*)tab->traceset_info->traceset_context);
+
+    lttv_context_fini(LTTV_TRACESET_CONTEXT(
+        tab->traceset_info->traceset_context));
+    g_object_unref(tab->traceset_info->traceset_context);
+
+    for(i = 0; i < lttv_traceset_number(traceset); i++)
+    {
+      LttvTrace *trace = lttv_traceset_get(traceset, i);
+      lttvwindowtraces_remove_trace(trace);
+      lttvwindowtraces_add_trace(trace);
+    }
+
+    // Create new context
+    tab->traceset_info->traceset_context =
+      g_object_new(LTTV_TRACESET_STATS_TYPE, NULL);
+    lttv_context_init(LTTV_TRACESET_CONTEXT(tab->traceset_info->
+        traceset_context), traceset);
+
+    // Add state update hooks
+    lttv_state_add_event_hooks(
+      (LttvTracesetState*)tab->traceset_info->traceset_context);
+
+    // Remove local reference to the traces
+    for(i=0; i<lttv_traceset_number(traceset); i++)
+    {
+      LttvTrace *trace = lttv_traceset_get(traceset, i);
+      lttv_trace_unref(trace);
+    }
+
+    tsc = LTTV_TRACESET_CONTEXT(tab->traceset_info->traceset_context);
+  }
+
+  time_span = tsc->time_span;
+  new_time_window = tab->time_window;
+  new_current_time = tab->current_time;
 
   /* Set the tab's time window and current time if
    * out of bounds */
@@ -551,15 +610,16 @@ int SetTraceset(Tab * tab, LttvTraceset *traceset)
   LttvHooks * tmp;
   LttvAttributeValue value;
   gint retval = 0;
-
  
   retval= lttv_iattribute_find_by_path(tab->attributes,
     "hooks/updatetraceset", LTTV_POINTER, &value);
   g_assert(retval);
 
   tmp = (LttvHooks*)*(value.v_pointer);
-  if(tmp == NULL) retval = 1;
-  else lttv_hooks_call(tmp,traceset);
+  if(tmp == NULL)
+         retval = 1;
+  else
+         lttv_hooks_call(tmp,traceset);
 
   time_change_manager(tab, new_time_window);
   current_time_change_manager(tab, new_current_time);
This page took 0.035317 seconds and 4 git commands to generate.