- for(i=0;i<pos->ep->len; i++) {
- LttEventPosition **ep = &g_array_index(pos->ep, LttEventPosition*, i);
- LttvTracefileContext **tfc =
- &g_array_index(pos->tfc, LttvTracefileContext*, i);
- if(*ep != NULL) {
- g_assert(ltt_tracefile_seek_position((*tfc)->tf, *ep) == 0);
- (*tfc)->timestamp = ltt_event_time(ltt_tracefile_get_event((*tfc)->tf));
- g_tree_insert(self->pqueue, (*tfc), (*tfc));
- } else {
- (*tfc)->timestamp = ltt_time_infinite;
+ /* If a position is set, seek the traceset to this position */
+ if(ltt_time_compare(pos->timestamp, ltt_time_infinite) != 0) {
+ g_tree_destroy(self->pqueue);
+ self->pqueue = g_tree_new(compare_tracefile);
+
+ for(i=0;i<pos->ep->len; i++) {
+ LttEventPosition **ep = &g_array_index(pos->ep, LttEventPosition*, i);
+ LttvTracefileContext **tfc =
+ &g_array_index(pos->tfc, LttvTracefileContext*, i);
+ if(*ep != NULL) {
+ if(ltt_tracefile_seek_position((*tfc)->tf, *ep) != 0)
+ return 1;
+ (*tfc)->timestamp = ltt_event_time(ltt_tracefile_get_event((*tfc)->tf));
+ g_assert(ltt_time_compare((*tfc)->timestamp, ltt_time_infinite) != 0);
+ g_tree_insert(self->pqueue, (*tfc), (*tfc));
+ } else {
+ (*tfc)->timestamp = ltt_time_infinite;
+ }