traceset position save fix
[lttv.git] / ltt / branches / poly / lttv / lttv / tracecontext.c
index 1084ad60632acb75314a517a5647a6e37cf5edd5..58310b4090f8453558dfd2a1f522e4d0e4856b95 100644 (file)
@@ -808,7 +808,10 @@ void lttv_process_traceset_end(LttvTracesetContext *self,
 
 /* Subtile modification : 
  * if tracefile has no event at or after the time requested, it is not put in
- * the queue, as the next read would fail. */
+ * the queue, as the next read would fail.
+ *
+ * Don't forget to empty the traceset pqueue before calling this.
+ */
 void lttv_process_trace_seek_time(LttvTraceContext *self, LttTime start)
 {
   guint i, nb_tracefile;
@@ -819,9 +822,6 @@ void lttv_process_trace_seek_time(LttvTraceContext *self, LttTime start)
 
   nb_tracefile = self->tracefiles->len;
 
-  g_tree_destroy(self->ts_context->pqueue);
-  self->ts_context->pqueue = g_tree_new(compare_tracefile);
-
   GTree *pqueue = self->ts_context->pqueue;
 
   for(i = 0 ; i < nb_tracefile ; i++) {
@@ -858,6 +858,9 @@ void lttv_process_traceset_seek_time(LttvTracesetContext *self, LttTime start)
 
   LttvTraceContext *tc;
 
+  g_tree_destroy(self->pqueue);
+  self->pqueue = g_tree_new(compare_tracefile);
+
   nb_trace = lttv_traceset_number(self->ts);
   for(i = 0 ; i < nb_trace ; i++) {
     tc = self->traces[i];
@@ -1073,7 +1076,10 @@ void lttv_traceset_context_position_save(const LttvTracesetContext *self,
 {
   guint i;
   guint num_traces = lttv_traceset_number(self->ts);
-
+  
+  pos->tfc = g_array_set_size(pos->tfc, 0);
+  pos->ep = g_array_set_size(pos->ep, 0);
+  
   for(i=0; i<num_traces;i++) {
     GArray * tracefiles = self->traces[i]->tracefiles;
     guint j;
@@ -1122,8 +1128,8 @@ void lttv_traceset_context_position_copy(LttvTracesetContextPosition *dest,
   int i;
   LttEventPosition **src_ep, **dest_ep;
   
-  g_array_set_size(dest->ep, src->ep->len);
-  g_array_set_size(dest->tfc, src->tfc->len);
+  dest->ep = g_array_set_size(dest->ep, src->ep->len);
+  dest->tfc = g_array_set_size(dest->tfc, src->tfc->len);
   
   for(i=0;i<src->ep->len;i++) {
     src_ep = &g_array_index(src->ep, LttEventPosition*, i);
This page took 0.024063 seconds and 4 git commands to generate.