X-Git-Url: http://git.lttng.org/?a=blobdiff_plain;f=ltt%2Fbranches%2Fpoly%2Flttv%2Fmodules%2Fgui%2FmainWin%2Fsrc%2Finit_module.c;h=ed724a42439717446a443158760ae2d75339e9c6;hb=2061e03dd5e8aa09fbed5b08ae702fe2eb33be06;hp=19cb148e841a0e77a281fc0de9acc7adcfc0a78b;hpb=7a859036ac53f538bd0ff723a1b450d7f26fa733;p=lttv.git diff --git a/ltt/branches/poly/lttv/modules/gui/mainWin/src/init_module.c b/ltt/branches/poly/lttv/modules/gui/mainWin/src/init_module.c index 19cb148e..ed724a42 100644 --- a/ltt/branches/poly/lttv/modules/gui/mainWin/src/init_module.c +++ b/ltt/branches/poly/lttv/modules/gui/mainWin/src/init_module.c @@ -26,24 +26,19 @@ #include "callbacks.h" /* global variable */ -LttvTracesetStats * gTracesetContext = NULL; -static LttvTraceset * traceset; +//LttvTracesetStats * gTracesetContext = NULL; +//static LttvTraceset * traceset; WindowCreationData gWinCreationData; /** Array containing instanced objects. */ GSList * Main_Window_List = NULL ; -static LttvHooks - *before_traceset, - *after_traceset, - *before_trace, - *after_trace, - *before_tracefile, - *after_tracefile, - *before_event, - *after_event, +LttvHooks *main_hooks; +/* Initial trace from command line */ +LttvTrace *gInit_Trace = NULL; + static char *a_trace; void lttv_trace_option(void *hook_data) @@ -52,7 +47,7 @@ void lttv_trace_option(void *hook_data) trace = ltt_trace_open(a_trace); if(trace == NULL) g_critical("cannot open trace %s", a_trace); - lttv_traceset_add(traceset, trace); + gInit_Trace = lttv_trace_new(trace); } /***************************************************************************** @@ -82,13 +77,7 @@ static gboolean Window_Creation_Hook(void *hook_data, void *call_data) add_pixmap_directory ("pixmaps"); add_pixmap_directory ("modules/gui/mainWin/pixmaps"); - - if(!gTracesetContext){ - gTracesetContext = g_object_new(LTTV_TRACESET_STATS_TYPE, NULL); - lttv_context_init(LTTV_TRACESET_CONTEXT(gTracesetContext), traceset); - } - - constructMainWin(NULL, Window_Creation_Data); + constructMainWin(NULL, Window_Creation_Data, TRUE); gtk_main (); @@ -101,7 +90,8 @@ static gboolean Window_Creation_Hook(void *hook_data, void *call_data) G_MODULE_EXPORT void init(LttvModule *self, int argc, char *argv[]) { LttvAttributeValue value; - + + // Global attributes only used for interaction with main() here. LttvIAttribute *attributes = LTTV_IATTRIBUTE(lttv_global_attributes()); g_critical("GUI init()"); @@ -111,42 +101,6 @@ G_MODULE_EXPORT void init(LttvModule *self, int argc, char *argv[]) { "pathname of the directory containing the trace", LTTV_OPT_STRING, &a_trace, lttv_trace_option, NULL); - traceset = lttv_traceset_new(); - - before_traceset = lttv_hooks_new(); - after_traceset = lttv_hooks_new(); - before_trace = lttv_hooks_new(); - after_trace = lttv_hooks_new(); - before_tracefile = lttv_hooks_new(); - after_tracefile = lttv_hooks_new(); - before_event = lttv_hooks_new(); - after_event = lttv_hooks_new(); - - g_assert(lttv_iattribute_find_by_path(attributes, "hooks/traceset/before", - LTTV_POINTER, &value)); - *(value.v_pointer) = before_traceset; - g_assert(lttv_iattribute_find_by_path(attributes, "hooks/traceset/after", - LTTV_POINTER, &value)); - *(value.v_pointer) = after_traceset; - g_assert(lttv_iattribute_find_by_path(attributes, "hooks/trace/before", - LTTV_POINTER, &value)); - *(value.v_pointer) = before_trace; - g_assert(lttv_iattribute_find_by_path(attributes, "hooks/trace/after", - LTTV_POINTER, &value)); - *(value.v_pointer) = after_trace; - g_assert(lttv_iattribute_find_by_path(attributes, "hooks/tracefile/before", - LTTV_POINTER, &value)); - *(value.v_pointer) = before_tracefile; - g_assert(lttv_iattribute_find_by_path(attributes, "hooks/tracefile/after", - LTTV_POINTER, &value)); - *(value.v_pointer) = after_tracefile; - g_assert(lttv_iattribute_find_by_path(attributes, "hooks/event/before", - LTTV_POINTER, &value)); - *(value.v_pointer) = before_event; - g_assert(lttv_iattribute_find_by_path(attributes, "hooks/event/after", - LTTV_POINTER, &value)); - *(value.v_pointer) = after_event; - g_assert(lttv_iattribute_find_by_path(attributes, "hooks/main/before", LTTV_POINTER, &value)); g_assert((main_hooks = *(value.v_pointer)) != NULL); @@ -158,42 +112,52 @@ G_MODULE_EXPORT void init(LttvModule *self, int argc, char *argv[]) { } -void -free_system_view(systemView * SystemView) -{ - if(!SystemView)return; - //free_EventDB(SystemView->EventDB); - //free_SystemInfo(SystemView->SystemInfo); - //free_Options(SystemView->Options); - if(SystemView->Next) - free_system_view(SystemView->Next); - g_free(SystemView); -} - -void free_tab(tab * Tab) -{ - if(!Tab) return; - if(Tab->custom->vbox) - gtk_widget_destroy(Tab->custom->vbox); - if(Tab->Attributes) - g_object_unref(Tab->Attributes); - - if(Tab->Next) free_tab(Tab->Next); - g_free(Tab); -} - void mainWindow_free(mainWindow * mw) { + guint i, nb; + if(mw){ - Main_Window_List = g_slist_remove(Main_Window_List, mw); + +g_critical("begin remove"); + lttv_hooks_destroy(mw->Traceset_Info->before_traceset); + lttv_hooks_destroy(mw->Traceset_Info->after_traceset); + lttv_hooks_destroy(mw->Traceset_Info->before_trace); + lttv_hooks_destroy(mw->Traceset_Info->after_trace); + lttv_hooks_destroy(mw->Traceset_Info->before_tracefile); + lttv_hooks_destroy(mw->Traceset_Info->after_tracefile); + lttv_hooks_destroy(mw->Traceset_Info->before_event); + lttv_hooks_destroy(mw->Traceset_Info->after_event); +g_critical("end remove"); - //should free memory allocated dynamically first - free_system_view(mw->SystemView); - free_tab(mw->Tab); + if(mw->Traceset_Info->path != NULL) + g_free(mw->Traceset_Info->path); + if(mw->Traceset_Info->TracesetContext != NULL){ + lttv_context_fini(LTTV_TRACESET_CONTEXT(mw->Traceset_Info->TracesetContext)); + g_object_unref(mw->Traceset_Info->TracesetContext); + } + if(mw->Traceset_Info->traceset != NULL) { + nb = lttv_traceset_number(mw->Traceset_Info->traceset); + for(i = 0 ; i < nb ; i++) { + ltt_trace_close( + lttv_trace(lttv_traceset_get(mw->Traceset_Info->traceset, i))); + } + } + + lttv_traceset_destroy(mw->Traceset_Info->traceset); + g_object_unref(mw->Attributes); - g_free(mw); + g_free(mw->Traceset_Info); + mw->Traceset_Info = NULL; + + Main_Window_List = g_slist_remove(Main_Window_List, mw); + + g_hash_table_destroy(mw->hash_menu_item); + g_hash_table_destroy(mw->hash_toolbar_item); + + g_free(mw); + mw = NULL; } } @@ -206,8 +170,8 @@ mainWindow_Destructor(mainWindow * mw) // gtk_widget_destroy(mw->AboutBox); mw = NULL; } - - mainWindow_free(mw); + //mainWindow_free called when the object mw in the widget is unref. + //mainWindow_free(mw); } @@ -227,35 +191,17 @@ void destroy_walk(gpointer data, gpointer user_data) G_MODULE_EXPORT void destroy() { LttvAttributeValue value; - - guint i, nb; + LttvTrace *trace; lttv_option_remove("trace"); - lttv_hooks_destroy(before_traceset); - lttv_hooks_destroy(after_traceset); - lttv_hooks_destroy(before_trace); - lttv_hooks_destroy(after_trace); - lttv_hooks_destroy(before_tracefile); - lttv_hooks_destroy(after_tracefile); - lttv_hooks_destroy(before_event); - lttv_hooks_destroy(after_event); lttv_hooks_remove_data(main_hooks, Window_Creation_Hook, &gWinCreationData); - nb = lttv_traceset_number(traceset); - for(i = 0 ; i < nb ; i++) { - ltt_trace_close(lttv_traceset_get(traceset, i)); - } - - lttv_traceset_destroy(traceset); - g_critical("GUI destroy()"); g_slist_foreach(Main_Window_List, destroy_walk, NULL ); g_slist_free(Main_Window_List); - - g_object_unref(gTracesetContext); }