From c5b5eee19c4b2e48bb844082c71e19e88a1887c3 Mon Sep 17 00:00:00 2001 From: compudj Date: Sun, 28 Aug 2005 19:29:05 +0000 Subject: [PATCH] fix memleak git-svn-id: http://ltt.polymtl.ca/svn@1088 04897980-b3bd-0310-b5e0-8ef037075253 --- .../gui/lttvwindow/lttvwindow/callbacks.c | 40 ++-------------- .../gui/lttvwindow/lttvwindow/lttvwindow.c | 46 ++++++++++++++++++- .../gui/lttvwindow/lttvwindow/lttvwindow.h | 9 ++-- 3 files changed, 55 insertions(+), 40 deletions(-) diff --git a/ltt/branches/poly/lttv/modules/gui/lttvwindow/lttvwindow/callbacks.c b/ltt/branches/poly/lttv/modules/gui/lttvwindow/lttvwindow/callbacks.c index 29c874e1..564610a1 100644 --- a/ltt/branches/poly/lttv/modules/gui/lttvwindow/lttvwindow/callbacks.c +++ b/ltt/branches/poly/lttv/modules/gui/lttvwindow/lttvwindow/callbacks.c @@ -821,42 +821,6 @@ void open_traceset(GtkWidget * widget, gpointer user_data) } -static void events_request_free(EventsRequest *events_request) -{ - if(events_request == NULL) return; - - if(events_request->start_position != NULL) - lttv_traceset_context_position_destroy(events_request->start_position); - if(events_request->end_position != NULL) - lttv_traceset_context_position_destroy(events_request->end_position); - if(events_request->hooks != NULL) - g_array_free(events_request->hooks, TRUE); - if(events_request->before_chunk_traceset != NULL) - lttv_hooks_destroy(events_request->before_chunk_traceset); - if(events_request->before_chunk_trace != NULL) - lttv_hooks_destroy(events_request->before_chunk_trace); - if(events_request->before_chunk_tracefile != NULL) - lttv_hooks_destroy(events_request->before_chunk_tracefile); - if(events_request->event != NULL) - lttv_hooks_destroy(events_request->event); - if(events_request->event_by_id != NULL) - lttv_hooks_by_id_destroy(events_request->event_by_id); - if(events_request->after_chunk_tracefile != NULL) - lttv_hooks_destroy(events_request->after_chunk_tracefile); - if(events_request->after_chunk_trace != NULL) - lttv_hooks_destroy(events_request->after_chunk_trace); - if(events_request->after_chunk_traceset != NULL) - lttv_hooks_destroy(events_request->after_chunk_traceset); - if(events_request->before_request != NULL) - lttv_hooks_destroy(events_request->before_request); - if(events_request->after_request != NULL) - lttv_hooks_destroy(events_request->after_request); - - g_free(events_request); -} - - - /* lttvwindow_process_pending_requests * * This internal function gets called by g_idle, taking care of the pending @@ -4202,6 +4166,10 @@ Tab* create_tab(MainWindow * mw, Tab *copy_tab, tab->viewer_container = gtk_vbox_new(TRUE, 2); tab->scrollbar = gtk_hscrollbar_new(NULL); //tab->multivpaned = gtk_multi_vpaned_new(); + tab->time_window.start_time = ltt_time_zero; + tab->time_window.end_time = ltt_time_zero; + tab->time_window.time_width = ltt_time_zero; + tab->current_time = ltt_time_zero; gtk_box_pack_start(GTK_BOX(tab->vbox), tab->viewer_container, diff --git a/ltt/branches/poly/lttv/modules/gui/lttvwindow/lttvwindow/lttvwindow.c b/ltt/branches/poly/lttv/modules/gui/lttvwindow/lttvwindow/lttvwindow.c index 2cc2bf2c..cec78e03 100644 --- a/ltt/branches/poly/lttv/modules/gui/lttvwindow/lttvwindow/lttvwindow.c +++ b/ltt/branches/poly/lttv/modules/gui/lttvwindow/lttvwindow/lttvwindow.c @@ -897,7 +897,8 @@ void lttvwindow_events_request_remove_all(Tab *tab, //if(events_request->servicing == TRUE) { // lttv_hooks_call(events_request->after_request, NULL); //} - g_free(events_request); + events_request_free(events_request); + //g_free(events_request); tab->events_requests = g_slist_remove_link(tab->events_requests, element); element = g_slist_next(element); if(element == NULL) break; /* end of list */ @@ -994,3 +995,46 @@ LttvTracesetContext* lttvwindow_get_traceset_context(Tab *tab) { return (LttvTracesetContext*)tab->traceset_info->traceset_context; } + + +void events_request_free(EventsRequest *events_request) +{ + if(events_request == NULL) return; + + if(events_request->start_position != NULL) + lttv_traceset_context_position_destroy(events_request->start_position); + if(events_request->end_position != NULL) + lttv_traceset_context_position_destroy(events_request->end_position); + if(events_request->hooks != NULL) { + guint i; + GArray *hooks = events_request->hooks; + for(i=0;ilen;i++) { + lttv_trace_hook_destroy(&g_array_index(hooks, LttvTraceHook, i)); + } + g_array_free(events_request->hooks, TRUE); + } + if(events_request->before_chunk_traceset != NULL) + lttv_hooks_destroy(events_request->before_chunk_traceset); + if(events_request->before_chunk_trace != NULL) + lttv_hooks_destroy(events_request->before_chunk_trace); + if(events_request->before_chunk_tracefile != NULL) + lttv_hooks_destroy(events_request->before_chunk_tracefile); + if(events_request->event != NULL) + lttv_hooks_destroy(events_request->event); + if(events_request->event_by_id != NULL) + lttv_hooks_by_id_destroy(events_request->event_by_id); + if(events_request->after_chunk_tracefile != NULL) + lttv_hooks_destroy(events_request->after_chunk_tracefile); + if(events_request->after_chunk_trace != NULL) + lttv_hooks_destroy(events_request->after_chunk_trace); + if(events_request->after_chunk_traceset != NULL) + lttv_hooks_destroy(events_request->after_chunk_traceset); + if(events_request->before_request != NULL) + lttv_hooks_destroy(events_request->before_request); + if(events_request->after_request != NULL) + lttv_hooks_destroy(events_request->after_request); + + g_free(events_request); +} + + diff --git a/ltt/branches/poly/lttv/modules/gui/lttvwindow/lttvwindow/lttvwindow.h b/ltt/branches/poly/lttv/modules/gui/lttvwindow/lttvwindow/lttvwindow.h index 4b856245..1533ae24 100644 --- a/ltt/branches/poly/lttv/modules/gui/lttvwindow/lttvwindow/lttvwindow.h +++ b/ltt/branches/poly/lttv/modules/gui/lttvwindow/lttvwindow/lttvwindow.h @@ -239,8 +239,8 @@ FIXME : explain other important events */ -#ifndef VIEWER_H -#define VIEWER_H +#ifndef LTTVWINDOW_H +#define LTTVWINDOW_H /*! \file lttvwindow.h * \brief API used by the graphical viewers to interact with their top window. @@ -750,4 +750,7 @@ void set_time_window(Tab *tab, const TimeWindow *time_window); void set_current_time(Tab *tab, const LttTime *current_time); -#endif //VIEWER_H + +void events_request_free(EventsRequest *events_request); + +#endif //LTTVWINDOW_H -- 2.34.1