fixed memory leak in test drawing functions
authorcompudj <compudj@04897980-b3bd-0310-b5e0-8ef037075253>
Wed, 7 Jan 2004 18:02:05 +0000 (18:02 +0000)
committercompudj <compudj@04897980-b3bd-0310-b5e0-8ef037075253>
Wed, 7 Jan 2004 18:02:05 +0000 (18:02 +0000)
git-svn-id: http://ltt.polymtl.ca/svn@356 04897980-b3bd-0310-b5e0-8ef037075253

ltt/branches/poly/lttv/modules/guiControlFlow/CFV.c
ltt/branches/poly/lttv/modules/guiControlFlow/Draw_Item.c
ltt/branches/poly/lttv/modules/guiControlFlow/Draw_Item.h
ltt/branches/poly/lttv/modules/guiControlFlow/Drawing.c
ltt/branches/poly/lttv/modules/guiControlFlow/Drawing.h
ltt/branches/poly/lttv/modules/guiControlFlow/Event_Hooks.c
ltt/branches/poly/lttv/modules/guiControlFlow/Process_List.c

index fa8b6a3fe77b25301d393a98a2f8f33a9236445c..5bca7f543647e66c2cee15e89b04ffb2ff09ff1c 100644 (file)
@@ -151,6 +151,9 @@ guicontrolflow_destructor(ControlFlowData *Control_Flow_Data)
        
        g_info("CFV.c : guicontrolflow_destructor, %p", Control_Flow_Data);
        g_info("%p, %p, %p", update_time_window_hook, Control_Flow_Data, Control_Flow_Data->Parent_Window);
+       if(GTK_IS_WIDGET(Control_Flow_Data->Scrolled_Window_VC))
+               g_info("widget still exists");
+       
        /* Process List is removed with it's widget */
        //ProcessList_destroy(Control_Flow_Data->Process_List);
        if(Control_Flow_Data->Parent_Window != NULL)
index 70befcc4005a93308be4a29faefaa5d7cf41a4d3..4a6d6d2af729437828d2a816d3d33a376dced7ba 100644 (file)
 
 #define MAX_PATH_LEN 256
 
-/* The DrawContext keeps information about the current drawing position and
- * the previous one, so we can use both to draw lines.
- *
- * over : position for drawing over the middle line.
- * middle : middle line position.
- * under : position for drawing under the middle line.
- *
- * the modify_* are used to take into account that we should go forward
- * when we draw a text, an arc or an icon, while it's unneeded when we
- * draw a line or background.
- *
- */
-struct _DrawContext {
-       GdkDrawable     *drawable;
-       GdkGC           *gc;
-       
-
-       DrawInfo        *Current;
-       DrawInfo        *Previous;
-};
-
-struct _DrawInfo {
-       ItemInfo        *over;
-       ItemInfo        *middle;
-       ItemInfo        *under;
-       
-       ItemInfo        *modify_over;
-       ItemInfo        *modify_middle;
-       ItemInfo        *modify_under;
-};
-
-/* LttvExecutionState is accessible through the LttvTracefileState. Is has
- * a pointer to the LttvProcessState which points to the top of stack
- * execution state : LttvExecutionState *state.
- *
- * LttvExecutionState contains (useful here):
- * LttvExecutionMode t,
- * LttvExecutionSubmode n,
- * LttvProcessStatus s
- * 
- *
- * LttvTraceState will be used in the case we need the string of the
- * different processes, eventtype_names, syscall_names, trap_names, irq_names.
- *
- * LttvTracefileState also gives the cpu_name and, as it herits from
- * LttvTracefileContext, it gives the LttEvent structure, which is needed
- * to get facility name and event name.
- */
-struct _ItemInfo {
-       gint    x, y;
-       LttvTraceState          *ts;
-       LttvTracefileState      *tfs;
-};
-
-/*
- * Structure used to keep information about icons.
- */
-struct _IconStruct {
-       GdkPixmap *pixmap;
-       GdkBitmap *mask;
-};
-
-
-/*
- * The Item element is only used so the DrawOperation is modifiable by users.
- * During drawing, only the Hook is needed.
- */
-struct _DrawOperation {
-       DrawableItems   Item;
-       LttvHooks       *Hook;
-};
-
-/*
- * We define here each items that can be drawn, together with their
- * associated priority. Many item types can have the same priority,
- * it's only used for quicksorting the operations when we add a new one
- * to the array of operations to perform. Lower priorities are executed
- * first. So, for example, we may want to give background color a value
- * of 10 while a line would have 20, so the background color, which
- * is in fact a rectangle, does not hide the line.
- */
-
-static int Items_Priorities[] = {
-       50,     /* ITEM_TEXT */
-       40,     /* ITEM_ICON */
-       20,     /* ITEM_LINE */
-       30,     /* ITEM_POINT */
-       10      /* ITEM_BACKGROUND */
-};
-
-/*
- * Here are the different structures describing each item type that can be
- * drawn. They contain the information necessary to draw the item : not the
- * position (this is provided by the DrawContext), but the text, icon name,
- * line width, color; all the properties of the specific items.
- */
-
-struct _PropertiesText {
-       GdkColor        *foreground;
-       GdkColor        *background;
-       gint            size;
-       gchar           *Text;
-       RelPos          position;
-};
-
-
-struct _PropertiesIcon {
-       gchar           *icon_name;
-       gint            width;
-       gint            height;
-       RelPos          position;
-};
-
-struct _PropertiesLine {
-       GdkColor        *color;
-       gint            line_width;
-       GdkLineStyle    style;
-       RelPos          position;
-};
-
-struct _PropertiesArc {
-       GdkColor        *color;
-       gint            size;   /* We force circle by width = height */
-       gboolean        filled;
-       RelPos          position;
-};
-
-struct _PropertiesBG {
-       GdkColor        *color;
-};
-
-
 /* Drawing hook functions */
 gboolean draw_text( void *hook_data, void *call_data)
 {
@@ -291,7 +159,7 @@ gboolean draw_icon( void *hook_data, void *call_data)
        LttvAttributeValue value;
        gchar icon_name[MAX_PATH_LEN] = "icons/";
        IconStruct *icon_info;
-       
+
        strcat(icon_name, Properties->icon_name);
        
   g_assert(lttv_iattribute_find_by_path(attributes, icon_name,
index 6e5f5eb5cd2bfcdacc07531c941d4293757b3393..63efcc11baa989d9fc529c59a3c373fdcc596a82 100644 (file)
@@ -27,6 +27,139 @@ typedef enum _RelPos {
 } RelPos;
 
 
+/* The DrawContext keeps information about the current drawing position and
+ * the previous one, so we can use both to draw lines.
+ *
+ * over : position for drawing over the middle line.
+ * middle : middle line position.
+ * under : position for drawing under the middle line.
+ *
+ * the modify_* are used to take into account that we should go forward
+ * when we draw a text, an arc or an icon, while it's unneeded when we
+ * draw a line or background.
+ *
+ */
+struct _DrawContext {
+       GdkDrawable     *drawable;
+       GdkGC           *gc;
+       
+
+       DrawInfo        *Current;
+       DrawInfo        *Previous;
+};
+
+struct _DrawInfo {
+       ItemInfo        *over;
+       ItemInfo        *middle;
+       ItemInfo        *under;
+       
+       ItemInfo        *modify_over;
+       ItemInfo        *modify_middle;
+       ItemInfo        *modify_under;
+};
+
+/* LttvExecutionState is accessible through the LttvTracefileState. Is has
+ * a pointer to the LttvProcessState which points to the top of stack
+ * execution state : LttvExecutionState *state.
+ *
+ * LttvExecutionState contains (useful here):
+ * LttvExecutionMode t,
+ * LttvExecutionSubmode n,
+ * LttvProcessStatus s
+ * 
+ *
+ * LttvTraceState will be used in the case we need the string of the
+ * different processes, eventtype_names, syscall_names, trap_names, irq_names.
+ *
+ * LttvTracefileState also gives the cpu_name and, as it herits from
+ * LttvTracefileContext, it gives the LttEvent structure, which is needed
+ * to get facility name and event name.
+ */
+struct _ItemInfo {
+       gint    x, y;
+       LttvTraceState          *ts;
+       LttvTracefileState      *tfs;
+};
+
+/*
+ * Structure used to keep information about icons.
+ */
+struct _IconStruct {
+       GdkPixmap *pixmap;
+       GdkBitmap *mask;
+};
+
+
+/*
+ * The Item element is only used so the DrawOperation is modifiable by users.
+ * During drawing, only the Hook is needed.
+ */
+struct _DrawOperation {
+       DrawableItems   Item;
+       LttvHooks       *Hook;
+};
+
+/*
+ * We define here each items that can be drawn, together with their
+ * associated priority. Many item types can have the same priority,
+ * it's only used for quicksorting the operations when we add a new one
+ * to the array of operations to perform. Lower priorities are executed
+ * first. So, for example, we may want to give background color a value
+ * of 10 while a line would have 20, so the background color, which
+ * is in fact a rectangle, does not hide the line.
+ */
+
+static int Items_Priorities[] = {
+       50,     /* ITEM_TEXT */
+       40,     /* ITEM_ICON */
+       20,     /* ITEM_LINE */
+       30,     /* ITEM_POINT */
+       10      /* ITEM_BACKGROUND */
+};
+
+/*
+ * Here are the different structures describing each item type that can be
+ * drawn. They contain the information necessary to draw the item : not the
+ * position (this is provided by the DrawContext), but the text, icon name,
+ * line width, color; all the properties of the specific items.
+ */
+
+struct _PropertiesText {
+       GdkColor        *foreground;
+       GdkColor        *background;
+       gint            size;
+       gchar           *Text;
+       RelPos          position;
+};
+
+
+struct _PropertiesIcon {
+       gchar           *icon_name;
+       gint            width;
+       gint            height;
+       RelPos          position;
+};
+
+struct _PropertiesLine {
+       GdkColor        *color;
+       gint            line_width;
+       GdkLineStyle    style;
+       RelPos          position;
+};
+
+struct _PropertiesArc {
+       GdkColor        *color;
+       gint            size;   /* We force circle by width = height */
+       gboolean        filled;
+       RelPos          position;
+};
+
+struct _PropertiesBG {
+       GdkColor        *color;
+};
+
+
+
 void draw_item(        GdkDrawable *drawable,
                gint x,
                gint y,
index 0aa74529b905e4829a1f429b1ac073a67614973c..be9f3d92b5103294f31eecdceee19ea8ba718837 100644 (file)
@@ -37,15 +37,6 @@ static GdkColor CF_Colors [] =
 };
 
 
-//struct _Drawing_t {
-//     GtkWidget       *Drawing_Area_V;
-//     GdkPixmap       *Pixmap;
-//     ControlFlowData *Control_Flow_Data;
-
-//     gint            height, width, depth;
-
-//};
-
 /* Function responsible for updating the exposed area.
  * It must call processTrace() to ask for this update.
  */
@@ -55,6 +46,12 @@ void drawing_data_request(Drawing_t *Drawing,
                  gint width,
                        gint height)
 {
+       
+//     start from pixel to time(x)
+//     end from pixel to time (x + width)
+       
+//     LttvTracesetContext * tsc = get_traceset_context(event_viewer_data->mw);
+       
   if(width < 0) return ;
   if(height < 0) return ;
 
@@ -72,6 +69,13 @@ void drawing_data_request(Drawing_t *Drawing,
        guicontrolflow_get_process_list(Drawing->Control_Flow_Data),
        Drawing, *Pixmap, x, y, width, height);
   
+       // Let's call processTrace() !!
+       
+       
+       //lttv_process_traceset_seek_time(tsc, start);
+       //lttv_traceset_context_add_hooks(
+       //lttv_process_traceset
+       //lttv_traceset_context_remove_hooks
 }
                      
 /* Callbacks */
@@ -152,7 +156,6 @@ g_critical("missing data");
 //                   widget->allocation.height -
 //                                     Drawing->height);
  
-
   
   
   if (Drawing->Pixmap)
index dda39fb39b08637f0dcd5e02ab1b1d9974221f89..f211879ffb2390074097ae3f500fddd100a48cbf 100644 (file)
@@ -6,6 +6,7 @@
 #include <gtk/gtk.h>
 #include <ltt/ltt.h>
 #include "CFV.h"
+#include "Draw_Item.h"
 
 /* This part of the viewer does :
  * Draw horizontal lines, getting graphic context as arg.
@@ -31,8 +32,6 @@
 
 typedef struct _Drawing_t Drawing_t;
 
-
-//FIXME : TEMPORARILY PLACED HERE FOR GC !!
 struct _Drawing_t {
        GtkWidget       *Drawing_Area_V;
        GdkPixmap       *Pixmap;
@@ -42,7 +41,6 @@ struct _Drawing_t {
 
 };
 
-
 Drawing_t *drawing_construct(ControlFlowData *Control_Flow_Data);
 void drawing_destroy(Drawing_t *Drawing);
 
index e04a72b05aff075733728482819b0e64ba5ec96f..f9280f896f5d6f8298a2b9034c76ad8c075dbf92 100644 (file)
 #define MAX_PATH_LEN 256
 
 //FIXME : remove this include when tests finished.
-#include "Draw_Item.h"
 #include <string.h>
 
-struct _DrawContext {
-       GdkDrawable     *drawable;
-       GdkGC           *gc;
-       
-
-       DrawInfo        *Current;
-       DrawInfo        *Previous;
-};
-
-struct _DrawInfo {
-       ItemInfo        *over;
-       ItemInfo        *middle;
-       ItemInfo        *under;
-       
-       ItemInfo        *modify_over;
-       ItemInfo        *modify_middle;
-       ItemInfo        *modify_under;
-};
-
-/* LttvExecutionState is accessible through the LttvTracefileState. Is has
- * a pointer to the LttvProcessState which points to the top of stack
- * execution state : LttvExecutionState *state.
- *
- * LttvExecutionState contains (useful here):
- * LttvExecutionMode t,
- * LttvExecutionSubmode n,
- * LttvProcessStatus s
- * 
- *
- * LttvTraceState will be used in the case we need the string of the
- * different processes, eventtype_names, syscall_names, trap_names, irq_names.
- *
- * LttvTracefileState also gives the cpu_name and, as it herits from
- * LttvTracefileContext, it gives the LttEvent structure, which is needed
- * to get facility name and event name.
- */
-struct _ItemInfo {
-       gint    x, y;
-       LttvTraceState          *ts;
-       LttvTracefileState      *tfs;
-};
-
-
-
-struct _PropertiesIcon {
-       gchar           *icon_name;
-       gint            width;
-       gint            height;
-       RelPos          position;
-};
-
-
-
 void test_draw_item(Drawing_t *Drawing,
                        GdkPixmap *Pixmap) 
 {
@@ -116,8 +62,8 @@ void test_draw_item(Drawing_t *Drawing,
                        properties_icon.width = -1;
                        properties_icon.height = -1;
                        properties_icon.position = OVER;
-       
                        draw_icon(&properties_icon, &draw_context);
+                       g_free(properties_icon.icon_name);
                }
        }
 
@@ -129,7 +75,7 @@ void send_test_drawing(ProcessList *Process_List,
                        Drawing_t *Drawing,
                        GdkPixmap *Pixmap,
                        gint x, gint y, // y not used here?
-                       gint width,
+                 gint width,
                        gint height) // height won't be used here ?
 {
        int i,j;
@@ -142,20 +88,20 @@ void send_test_drawing(ProcessList *Process_List,
        gint Font_Size;
 
        //icon
-       GdkBitmap *mask = g_new(GdkBitmap, 1);
-       GdkPixmap *icon_pixmap = g_new(GdkPixmap, 1);
-       GdkGC * gc = gdk_gc_new(Pixmap);
-       
+       //GdkBitmap *mask = g_new(GdkBitmap, 1);
+       //GdkPixmap *icon_pixmap = g_new(GdkPixmap, 1);
+       GdkGC * gc;
        // rectangle
        GdkColor color = { 0, 0xffff, 0x0000, 0x0000 };
        
+       //gc = gdk_gc_new(Pixmap);
        /* Sent text data */
-       layout = gtk_widget_create_pango_layout(Drawing->Drawing_Area_V,
-                       NULL);
-       context = pango_layout_get_context(layout);
-       FontDesc = pango_context_get_font_description(context);
-       Font_Size = pango_font_description_get_size(FontDesc);
-       pango_font_description_set_size(FontDesc, Font_Size-3*PANGO_SCALE);
+       //layout = gtk_widget_create_pango_layout(Drawing->Drawing_Area_V,
+       //              NULL);
+       //context = pango_layout_get_context(layout);
+       //FontDesc = pango_context_get_font_description(context);
+       //Font_Size = pango_font_description_get_size(FontDesc);
+       //pango_font_description_set_size(FontDesc, Font_Size-3*PANGO_SCALE);
        
        
 
@@ -176,9 +122,9 @@ void send_test_drawing(ProcessList *Process_List,
                y+(height/2), x + width, y+(height/2),
                Drawing->Drawing_Area_V->style->black_gc);
 
-       pango_layout_set_text(layout, "Test", -1);
-       gdk_draw_layout(Pixmap, Drawing->Drawing_Area_V->style->black_gc,
-                       0, y+height, layout);
+       //pango_layout_set_text(layout, "Test", -1);
+       //gdk_draw_layout(Pixmap, Drawing->Drawing_Area_V->style->black_gc,
+       //              0, y+height, layout);
 
        birth.tv_sec = 14000;
        birth.tv_nsec = 55500;
@@ -209,11 +155,11 @@ void send_test_drawing(ProcessList *Process_List,
                                        &height);
 
        /* Draw rectangle (background color) */
-       gdk_gc_copy(gc, Drawing->Drawing_Area_V->style->black_gc);
-       gdk_gc_set_rgb_fg_color(gc, &color);
-       gdk_draw_rectangle(Pixmap, gc,
-                                       TRUE,
-                                       x, y, width, height);
+       //gdk_gc_copy(gc, Drawing->Drawing_Area_V->style->black_gc);
+       //gdk_gc_set_rgb_fg_color(gc, &color);
+       //gdk_draw_rectangle(Pixmap, gc,
+       //                              TRUE,
+       //                              x, y, width, height);
 
        drawing_draw_line(
                Drawing, Pixmap, x,
@@ -288,7 +234,7 @@ void send_test_drawing(ProcessList *Process_List,
 
 //             }
 //     }
-       
+
        test_draw_item(Drawing,Pixmap);
        
        //gdk_gc_set_clip_origin(Drawing->Drawing_Area_V->style->black_gc, 0, 0);
@@ -302,10 +248,9 @@ void send_test_drawing(ProcessList *Process_List,
 
 
 
-       pango_font_description_set_size(FontDesc, Font_Size);
-       g_free(gc);
-       g_free(layout);
-       //g_free(context);
+       //pango_font_description_set_size(FontDesc, Font_Size);
+       //g_object_unref(layout);
+       //g_object_unref(gc);
 }
 
 void send_test_process(ProcessList *Process_List, Drawing_t *Drawing)
index f5221394147eb3c7b4071977266942b005c79fd1..e959dafc1b1efa2a9664daf3e16a37b64cfcebff 100644 (file)
@@ -276,9 +276,10 @@ gint get_cell_height(GtkTreeView *TreeView)
 {
        gint height;
        GtkTreeViewColumn *Column = gtk_tree_view_get_column(TreeView, 0);
-       GList *Render_List = gtk_tree_view_column_get_cell_renderers(Column);
-       GtkCellRenderer *Renderer = g_list_first(Render_List)->data;
+       //GList *Render_List = gtk_tree_view_column_get_cell_renderers(Column);
+       //GtkCellRenderer *Renderer = g_list_first(Render_List)->data;
        
+       //g_list_free(Render_List);
        gtk_tree_view_column_cell_get_size(Column, NULL, NULL, NULL, NULL, &height);
        //g_critical("cell 0 height : %u",height);
        
@@ -396,6 +397,7 @@ gint processlist_get_process_pixels(        ProcessList *Process_List,
        ProcessInfo Process_Info;
        gint *path_indices;
        GtkTreeRowReference *got_RowRef;
+       GtkTreePath *tree_path;
 
        Process_Info.pid = pid;
        Process_Info.birth = *birth;
@@ -405,10 +407,10 @@ gint processlist_get_process_pixels(      ProcessList *Process_List,
                                        Process_List->Process_Hash,
                                        &Process_Info))
        {
-               path_indices =  gtk_tree_path_get_indices (
-                               gtk_tree_row_reference_get_path(
-                                       (GtkTreeRowReference*)got_RowRef)
-                               );
+               tree_path = gtk_tree_row_reference_get_path(
+                                                                               (GtkTreeRowReference*)got_RowRef);
+               path_indices =  gtk_tree_path_get_indices (tree_path);
+               gtk_tree_path_free(tree_path);
 
                *height = get_cell_height(
                                GTK_TREE_VIEW(Process_List->Process_List_VC));
This page took 0.034897 seconds and 4 git commands to generate.