From 6cec4cd266bde25f87dad0a059fd98c7381eb8c2 Mon Sep 17 00:00:00 2001 From: compudj Date: Thu, 15 Sep 2005 23:20:39 +0000 Subject: [PATCH] fixes to control flow view GC git-svn-id: http://ltt.polymtl.ca/svn@1202 04897980-b3bd-0310-b5e0-8ef037075253 --- .../poly/lttv/modules/gui/controlflow/cfv.c | 4 +- .../poly/lttv/modules/gui/controlflow/cfv.h | 2 +- .../lttv/modules/gui/controlflow/drawing.c | 104 +++++++++++------- .../lttv/modules/gui/controlflow/drawing.h | 2 + .../lttv/modules/gui/controlflow/eventhooks.c | 8 +- .../modules/gui/controlflow/processlist.c | 3 +- .../gui/lttvwindow/lttvwindow/callbacks.c | 85 +++++++------- .../gui/lttvwindow/lttvwindow/init_module.c | 25 ++--- .../modules/gui/tracecontrol/tracecontrol.c | 20 ++-- 9 files changed, 143 insertions(+), 110 deletions(-) diff --git a/ltt/branches/poly/lttv/modules/gui/controlflow/cfv.c b/ltt/branches/poly/lttv/modules/gui/controlflow/cfv.c index a96336ff..47ad080b 100644 --- a/ltt/branches/poly/lttv/modules/gui/controlflow/cfv.c +++ b/ltt/branches/poly/lttv/modules/gui/controlflow/cfv.c @@ -60,12 +60,14 @@ header_size_allocate(GtkWidget *widget, * @return The widget created. */ ControlFlowData * -guicontrolflow(void) +guicontrolflow(Tab *tab) { GtkWidget *process_list_widget, *drawing_widget, *drawing_area; ControlFlowData* control_flow_data = g_new(ControlFlowData,1) ; + control_flow_data->tab = tab; + control_flow_data->v_adjust = GTK_ADJUSTMENT(gtk_adjustment_new( 0.0, /* Value */ 0.0, /* Lower */ diff --git a/ltt/branches/poly/lttv/modules/gui/controlflow/cfv.h b/ltt/branches/poly/lttv/modules/gui/controlflow/cfv.h index 3e469bab..31c42fdf 100644 --- a/ltt/branches/poly/lttv/modules/gui/controlflow/cfv.h +++ b/ltt/branches/poly/lttv/modules/gui/controlflow/cfv.h @@ -63,7 +63,7 @@ struct _ControlFlowData { } ; /* Control Flow Data constructor */ -ControlFlowData *guicontrolflow(void); +ControlFlowData *guicontrolflow(Tab *tab); void guicontrolflow_destructor_full(ControlFlowData *control_flow_data); void diff --git a/ltt/branches/poly/lttv/modules/gui/controlflow/drawing.c b/ltt/branches/poly/lttv/modules/gui/controlflow/drawing.c index 842313a5..94f81089 100644 --- a/ltt/branches/poly/lttv/modules/gui/controlflow/drawing.c +++ b/ltt/branches/poly/lttv/modules/gui/controlflow/drawing.c @@ -122,6 +122,7 @@ void drawing_data_request(Drawing_t *drawing, if(width < 0) return ; if(height < 0) return ; + Tab *tab = drawing->control_flow_data->tab; TimeWindow time_window = lttvwindow_get_time_window(tab); @@ -627,6 +628,7 @@ configure_event( GtkWidget *widget, GdkEventConfigure *event, drawing->alloc_height = drawing->height + EXTRA_ALLOC; update_pixmap_size(drawing->control_flow_data->process_list, drawing->alloc_width); + update_index_to_pixmap(drawing->control_flow_data->process_list); } //drawing->height = widget->allocation.height; @@ -693,11 +695,12 @@ expose_event( GtkWidget *widget, GdkEventExpose *event, gpointer user_data ) (ControlFlowData*)g_object_get_data( G_OBJECT(widget), "control_flow_data"); +#if 0 if(unlikely(drawing->gc == NULL)) { drawing->gc = gdk_gc_new(drawing->drawing_area->window); gdk_gc_copy(drawing->gc, drawing->drawing_area->style->black_gc); } - +#endif //0 TimeWindow time_window = lttvwindow_get_time_window(control_flow_data->tab); LttTime current_time = @@ -717,11 +720,18 @@ expose_event( GtkWidget *widget, GdkEventExpose *event, gpointer user_data ) event->area.width, event->area.height); #endif //0 drawing->height = processlist_get_height(control_flow_data->process_list); +#if 0 copy_pixmap_to_screen(control_flow_data->process_list, widget->window, widget->style->fg_gc[GTK_WIDGET_STATE (widget)], event->area.x, event->area.y, event->area.width, event->area.height); +#endif //0 + copy_pixmap_to_screen(control_flow_data->process_list, + widget->window, + drawing->gc, + event->area.x, event->area.y, + event->area.width, event->area.height); /* Erase the dotted lines left.. */ @@ -744,7 +754,7 @@ expose_event( GtkWidget *widget, GdkEventExpose *event, gpointer user_data ) drawing->width, &cursor_x); - +#if 0 if(drawing->dotted_gc == NULL) { drawing->dotted_gc = gdk_gc_new(drawing->drawing_area->window); @@ -761,6 +771,7 @@ expose_event( GtkWidget *widget, GdkEventExpose *event, gpointer user_data ) dash_list, 2); } +#endif //0 gint height_tot = MAX(widget->allocation.height, drawing->height); gdk_draw_line(widget->window, drawing->dotted_gc, @@ -907,8 +918,6 @@ Drawing_t *drawing_construct(ControlFlowData *control_flow_data) drawing->pango_layout = gtk_widget_create_pango_layout(drawing->drawing_area, NULL); - drawing->dotted_gc = NULL; - drawing->height = 1; drawing->width = 1; drawing->depth = 0; @@ -1011,6 +1020,50 @@ Drawing_t *drawing_construct(ControlFlowData *control_flow_data) gdk_colormap_alloc_colors(colormap, drawing_colors, NUM_COLORS, FALSE, TRUE, success); + drawing->gc = + gdk_gc_new(GDK_DRAWABLE(main_window_get_widget(control_flow_data->tab)->window)); + drawing->dotted_gc = + gdk_gc_new(GDK_DRAWABLE(main_window_get_widget(control_flow_data->tab)->window)); + + gdk_gc_copy(drawing->gc, + main_window_get_widget(control_flow_data->tab)->style->black_gc); + gdk_gc_copy(drawing->dotted_gc, + main_window_get_widget(control_flow_data->tab)->style->white_gc); + + gint8 dash_list[] = { 1, 2 }; + gdk_gc_set_line_attributes(drawing->dotted_gc, + 1, + GDK_LINE_ON_OFF_DASH, + GDK_CAP_BUTT, + GDK_JOIN_MITER); + gdk_gc_set_dashes(drawing->dotted_gc, + 0, + dash_list, + 2); + + drawing->ruler_gc_butt = + gdk_gc_new(GDK_DRAWABLE(main_window_get_widget(control_flow_data->tab)->window)); + gdk_gc_copy(drawing->ruler_gc_butt, + main_window_get_widget(control_flow_data->tab)->style->black_gc); + drawing->ruler_gc_round = + gdk_gc_new(GDK_DRAWABLE(main_window_get_widget(control_flow_data->tab)->window)); + gdk_gc_copy(drawing->ruler_gc_round, + main_window_get_widget(control_flow_data->tab)->style->black_gc); + + + gdk_gc_set_line_attributes(drawing->ruler_gc_butt, + 2, + GDK_LINE_SOLID, + GDK_CAP_BUTT, + GDK_JOIN_MITER); + + gdk_gc_set_line_attributes(drawing->ruler_gc_round, + 2, + GDK_LINE_SOLID, + GDK_CAP_ROUND, + GDK_JOIN_ROUND); + + return drawing; } @@ -1032,6 +1085,9 @@ void drawing_destroy(Drawing_t *drawing) g_free(drawing->pango_layout); if(drawing->dotted_gc != NULL) gdk_gc_unref(drawing->dotted_gc); + if(drawing->ruler_gc_butt != NULL) gdk_gc_unref(drawing->ruler_gc_butt); + if(drawing->ruler_gc_round != NULL) gdk_gc_unref(drawing->ruler_gc_round); + g_free(drawing); g_info("drawing_destroy end"); } @@ -1274,15 +1330,8 @@ expose_ruler( GtkWidget *widget, GdkEventExpose *event, gpointer user_data ) event->area.width, event->area.height); - GdkGC *gc = gdk_gc_new(drawing->ruler->window); - gdk_gc_copy(gc, drawing->ruler->style->black_gc); - gdk_gc_set_line_attributes(gc, - 2, - GDK_LINE_SOLID, - GDK_CAP_BUTT, - GDK_JOIN_MITER); gdk_draw_line (drawing->ruler->window, - gc, + drawing->ruler_gc_butt, event->area.x, 1, event->area.x + event->area.width, 1); @@ -1304,19 +1353,13 @@ expose_ruler( GtkWidget *widget, GdkEventExpose *event, gpointer user_data ) global_width += ink_rect.width; gdk_draw_layout_with_colors(drawing->ruler->window, - gc, + drawing->ruler_gc_butt, 0, 6, layout, &foreground, &background); - gdk_gc_set_line_attributes(gc, - 2, - GDK_LINE_SOLID, - GDK_CAP_ROUND, - GDK_JOIN_ROUND); - gdk_draw_line (drawing->ruler->window, - gc, + drawing->ruler_gc_round, 1, 1, 1, 7); @@ -1331,19 +1374,13 @@ expose_ruler( GtkWidget *widget, GdkEventExpose *event, gpointer user_data ) if(global_width <= drawing->ruler->allocation.width) { gdk_draw_layout_with_colors(drawing->ruler->window, - gc, + drawing->ruler_gc_butt, drawing->ruler->allocation.width - ink_rect.width, 6, layout, &foreground, &background); - gdk_gc_set_line_attributes(gc, - 2, - GDK_LINE_SOLID, - GDK_CAP_ROUND, - GDK_JOIN_ROUND); - gdk_draw_line (drawing->ruler->window, - gc, + drawing->ruler_gc_butt, drawing->ruler->allocation.width-1, 1, drawing->ruler->allocation.width-1, 7); } @@ -1359,19 +1396,13 @@ expose_ruler( GtkWidget *widget, GdkEventExpose *event, gpointer user_data ) if(global_width <= drawing->ruler->allocation.width) { gdk_draw_layout_with_colors(drawing->ruler->window, - gc, + drawing->ruler_gc_butt, (drawing->ruler->allocation.width - ink_rect.width)/2, 6, layout, &foreground, &background); - gdk_gc_set_line_attributes(gc, - 2, - GDK_LINE_SOLID, - GDK_CAP_ROUND, - GDK_JOIN_ROUND); - gdk_draw_line (drawing->ruler->window, - gc, + drawing->ruler_gc_butt, drawing->ruler->allocation.width/2, 1, drawing->ruler->allocation.width/2, 7); @@ -1380,7 +1411,6 @@ expose_ruler( GtkWidget *widget, GdkEventExpose *event, gpointer user_data ) } - gdk_gc_unref(gc); g_object_unref(layout); return FALSE; diff --git a/ltt/branches/poly/lttv/modules/gui/controlflow/drawing.h b/ltt/branches/poly/lttv/modules/gui/controlflow/drawing.h index 3cf84ab8..9f2b9360 100644 --- a/ltt/branches/poly/lttv/modules/gui/controlflow/drawing.h +++ b/ltt/branches/poly/lttv/modules/gui/controlflow/drawing.h @@ -109,6 +109,8 @@ struct _Drawing_t { LttTime last_start; GdkGC *dotted_gc; GdkGC *gc; + GdkGC *ruler_gc_butt; + GdkGC *ruler_gc_round; /* Position of the horizontal selector, -1 for none */ gint horizontal_sel; diff --git a/ltt/branches/poly/lttv/modules/gui/controlflow/eventhooks.c b/ltt/branches/poly/lttv/modules/gui/controlflow/eventhooks.c index 72986339..e2a42d4f 100644 --- a/ltt/branches/poly/lttv/modules/gui/controlflow/eventhooks.c +++ b/ltt/branches/poly/lttv/modules/gui/controlflow/eventhooks.c @@ -182,7 +182,7 @@ GtkWidget * h_guicontrolflow(Tab *tab) { g_info("h_guicontrolflow, %p", tab); - ControlFlowData *control_flow_data = guicontrolflow() ; + ControlFlowData *control_flow_data = guicontrolflow(tab) ; control_flow_data->tab = tab; @@ -1926,6 +1926,12 @@ gint traceset_notify(void *hook_data, void *call_data) ControlFlowData *control_flow_data = (ControlFlowData*) hook_data; Drawing_t *drawing = control_flow_data->drawing; + if(unlikely(drawing->gc == NULL)) { + return FALSE; + } + if(drawing->dotted_gc == NULL) { + return FALSE; + } drawing_clear(control_flow_data->drawing); processlist_clear(control_flow_data->process_list); diff --git a/ltt/branches/poly/lttv/modules/gui/controlflow/processlist.c b/ltt/branches/poly/lttv/modules/gui/controlflow/processlist.c index 103063ab..ce4c0926 100644 --- a/ltt/branches/poly/lttv/modules/gui/controlflow/processlist.c +++ b/ltt/branches/poly/lttv/modules/gui/controlflow/processlist.c @@ -287,7 +287,8 @@ void copy_pixmap_to_screen(ProcessList *process_list, g_assert(iindex_to_pixmap->len); /* Render the pixmap to the screen */ GdkPixmap *pixmap = - (GdkPixmap*)g_ptr_array_index(process_list->index_to_pixmap, i); + //(GdkPixmap*)g_ptr_array_index(process_list->index_to_pixmap, i); + GDK_PIXMAP(g_ptr_array_index(process_list->index_to_pixmap, i)); gdk_draw_drawable (dest, gc, 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 8571eb25..df02b66d 100644 --- a/ltt/branches/poly/lttv/modules/gui/lttvwindow/lttvwindow/callbacks.c +++ b/ltt/branches/poly/lttv/modules/gui/lttvwindow/lttvwindow/callbacks.c @@ -4025,57 +4025,48 @@ MainWindow *construct_main_window(MainWindow * parent) new_tab = create_tab(new_m_window, parent_tab, notebook, "Traceset"); } else { new_tab = create_tab(new_m_window, NULL, notebook, "Traceset"); - /* First window, use command line trace */ - if(g_init_trace != NULL){ - lttvwindow_add_trace(new_tab, - g_init_trace); + } + /* Insert default viewers */ + { + LttvAttributeType type; + LttvAttributeName name; + LttvAttributeValue value; + LttvAttribute *attribute; + + LttvIAttribute *attributes_global = + LTTV_IATTRIBUTE(lttv_global_attributes()); + + g_assert(attribute = + LTTV_ATTRIBUTE(lttv_iattribute_find_subdir( + LTTV_IATTRIBUTE(attributes_global), + LTTV_VIEWER_CONSTRUCTORS))); + + name = g_quark_from_string("guievents"); + type = lttv_iattribute_get_by_name(LTTV_IATTRIBUTE(attribute), + name, &value); + if(type == LTTV_POINTER) { + lttvwindow_viewer_constructor viewer_constructor = + (lttvwindow_viewer_constructor)*value.v_pointer; + insert_viewer(new_window, viewer_constructor); } - LttvTraceset *traceset = new_tab->traceset_info->traceset; - SetTraceset(new_tab, traceset); - /* Insert default viewers */ - { - LttvAttributeType type; - LttvAttributeName name; - LttvAttributeValue value; - LttvAttribute *attribute; - - LttvIAttribute *attributes_global = - LTTV_IATTRIBUTE(lttv_global_attributes()); - - g_assert(attribute = - LTTV_ATTRIBUTE(lttv_iattribute_find_subdir( - LTTV_IATTRIBUTE(attributes_global), - LTTV_VIEWER_CONSTRUCTORS))); - - name = g_quark_from_string("guievents"); - type = lttv_iattribute_get_by_name(LTTV_IATTRIBUTE(attribute), - name, &value); - if(type == LTTV_POINTER) { - lttvwindow_viewer_constructor viewer_constructor = - (lttvwindow_viewer_constructor)*value.v_pointer; - insert_viewer(new_window, viewer_constructor); - } - - name = g_quark_from_string("guicontrolflow"); - type = lttv_iattribute_get_by_name(LTTV_IATTRIBUTE(attribute), - name, &value); - if(type == LTTV_POINTER) { - lttvwindow_viewer_constructor viewer_constructor = - (lttvwindow_viewer_constructor)*value.v_pointer; - insert_viewer(new_window, viewer_constructor); - } - - name = g_quark_from_string("guistatistics"); - type = lttv_iattribute_get_by_name(LTTV_IATTRIBUTE(attribute), - name, &value); - if(type == LTTV_POINTER) { - lttvwindow_viewer_constructor viewer_constructor = - (lttvwindow_viewer_constructor)*value.v_pointer; - insert_viewer(new_window, viewer_constructor); - } + name = g_quark_from_string("guicontrolflow"); + type = lttv_iattribute_get_by_name(LTTV_IATTRIBUTE(attribute), + name, &value); + if(type == LTTV_POINTER) { + lttvwindow_viewer_constructor viewer_constructor = + (lttvwindow_viewer_constructor)*value.v_pointer; + insert_viewer(new_window, viewer_constructor); + } + name = g_quark_from_string("guistatistics"); + type = lttv_iattribute_get_by_name(LTTV_IATTRIBUTE(attribute), + name, &value); + if(type == LTTV_POINTER) { + lttvwindow_viewer_constructor viewer_constructor = + (lttvwindow_viewer_constructor)*value.v_pointer; + insert_viewer(new_window, viewer_constructor); } } diff --git a/ltt/branches/poly/lttv/modules/gui/lttvwindow/lttvwindow/init_module.c b/ltt/branches/poly/lttv/modules/gui/lttvwindow/lttvwindow/init_module.c index 21a30eed..1ca5cf04 100644 --- a/ltt/branches/poly/lttv/modules/gui/lttvwindow/lttvwindow/init_module.c +++ b/ltt/branches/poly/lttv/modules/gui/lttvwindow/lttvwindow/init_module.c @@ -82,27 +82,17 @@ LttvHooks *main_hooks; /* Initial trace from command line */ -LttvTrace *g_init_trace = NULL; +//LttvTrace *g_init_trace = NULL; static char *a_trace; +static char g_init_trace[PATH_MAX] = ""; void lttv_trace_option(void *hook_data) { LttTrace *trace; - gchar abs_path[PATH_MAX]; - - get_absolute_pathname(a_trace, abs_path); - g_init_trace = lttvwindowtraces_get_trace_by_name(abs_path); - if(g_init_trace == NULL) { - trace = ltt_trace_open(abs_path); - if(trace == NULL) { - g_warning("cannot open trace %s", abs_path); - } else { - g_init_trace = lttv_trace_new(trace); - lttvwindowtraces_add_trace(g_init_trace); - } - } + + get_absolute_pathname(a_trace, g_init_trace); } /***************************************************************************** @@ -130,7 +120,12 @@ static gboolean window_creation_hook(void *hook_data, void *call_data) add_pixmap_directory ("pixmaps"); add_pixmap_directory ("../modules/gui/main/pixmaps"); - construct_main_window(NULL); + /* First window, use command line trace */ + if(strcmp(g_init_trace, "") != 0){ + create_main_window_with_trace(g_init_trace); + } else { + construct_main_window(NULL); + } gtk_main (); diff --git a/ltt/branches/poly/lttv/modules/gui/tracecontrol/tracecontrol.c b/ltt/branches/poly/lttv/modules/gui/tracecontrol/tracecontrol.c index da4df4fb..1193046d 100644 --- a/ltt/branches/poly/lttv/modules/gui/tracecontrol/tracecontrol.c +++ b/ltt/branches/poly/lttv/modules/gui/tracecontrol/tracecontrol.c @@ -45,6 +45,7 @@ #include #include #include +#include #define MAX_ARGS_LEN PATH_MAX * 10 @@ -536,13 +537,18 @@ wait_child: g_info("Waiting for child exit..."); ret = waitpid(pid, &status, 0); - - if(WIFEXITED(status)) - if(WEXITSTATUS(status) != 0) { - retval = WEXITSTATUS(status); - g_warning("An error occured in the su command : %s", - strerror(retval)); - } + + if(ret == -1) { + g_warning("An error occured in wait : %s", + strerror(errno)); + } else { + if(WIFEXITED(status)) + if(WEXITSTATUS(status) != 0) { + retval = WEXITSTATUS(status); + g_warning("An error occured in the su command : %s", + strerror(retval)); + } + } g_info("Child exited."); -- 2.34.1