X-Git-Url: http://git.liburcu.org/?a=blobdiff_plain;f=lttv%2Fmodules%2Fgui%2Flttvwindow%2Flttvwindow%2Fcallbacks.c;h=d58c3137af64f90a95c9f630df9e8b5612aaf787;hb=665fdbb70138df57711a6d90924836952add7ff1;hp=565cec17a76d5876b3eea4395be020d0e483ed0e;hpb=8f31828398b8a4fcdb679324291132f4f0e3dce6;p=lttv.git diff --git a/lttv/modules/gui/lttvwindow/lttvwindow/callbacks.c b/lttv/modules/gui/lttvwindow/lttvwindow/callbacks.c index 565cec17..d58c3137 100644 --- a/lttv/modules/gui/lttvwindow/lttvwindow/callbacks.c +++ b/lttv/modules/gui/lttvwindow/lttvwindow/callbacks.c @@ -39,6 +39,7 @@ #include #include #include +#include #include #include #include @@ -465,11 +466,66 @@ 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 + if (syncTraceset(tsc)) + { + /* 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; itraceset_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 +607,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);