diff options
Diffstat (limited to 'src/app.c')
-rw-r--r-- | src/app.c | 50 |
1 files changed, 25 insertions, 25 deletions
@@ -30,6 +30,7 @@ struct _app { GtkWidget *timeline; GtkWidget *statusbar; + gboolean discard_log; GtkWidget *log_tv; GtkTextBuffer *log; GtkTextMark *log_end; @@ -235,6 +236,7 @@ read_allocator (App *app, int fd, guint time) guint magic; guint last; guint n; + guint total; if (! readn (fd, &key, sizeof (key))) return NULL; @@ -330,11 +332,14 @@ read_allocator (App *app, int fd, guint time) return NULL; } + total = 0; At->max_size_alloc = 0; for (n = 0; n < G_N_ELEMENTS (At->size_allocs); n++) { if (At->size_allocs[n] != 0) At->max_size_alloc = n + 1; + total += At->size_allocs[n]; } + g_assert (total == At->n_allocs); At->faults.next = NULL; if (At->faults.tid != 0) { @@ -751,36 +756,18 @@ refresh_clicked (GtkButton *button, App *app) } static void -tree_map_selection_changed (GtkWidget *w, GtkTreeIter *iter, GtkTreeView *tv) +call_graph_select_iter (GtkWidget *w, GtkTreeIter *iter, GtkTreeView *tv) { GtkTreeSelection *selection; GtkTreeModel *model; GtkTreePath *path; - selection = gtk_tree_view_get_selection (tv); - gtk_tree_selection_unselect_all (selection); - model = gtk_tree_view_get_model (tv); - path = gtk_tree_model_get_path (model, iter); - - gtk_tree_view_expand_to_path (tv, path); - gtk_tree_view_scroll_to_cell (tv, path, NULL, FALSE, 0., 0.); - gtk_tree_path_free (path); - - gtk_tree_selection_select_iter (selection, iter); -} - -static void -ring_selection_changed (GtkWidget *w, GtkTreeIter *iter, GtkTreeView *tv) -{ - GtkTreeSelection *selection; - GtkTreeModel *model; - GtkTreePath *path; + call_graph_store_update_tree_model ((CallGraphStore *) model); selection = gtk_tree_view_get_selection (tv); gtk_tree_selection_unselect_all (selection); - model = gtk_tree_view_get_model (tv); path = gtk_tree_model_get_path (model, iter); gtk_tree_view_expand_to_path (tv, path); @@ -820,11 +807,11 @@ main_window_create (App *app) app); g_signal_connect (app->allocations.tree_map, "selected", - G_CALLBACK (tree_map_selection_changed), + G_CALLBACK (call_graph_select_iter), app->allocations.call_graph); g_signal_connect (app->allocations.ring, "selected", - G_CALLBACK (ring_selection_changed), + G_CALLBACK (call_graph_select_iter), app->allocations.call_graph); selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (app->allocation_image.allocators)); @@ -966,6 +953,9 @@ tcp_events_server_cb (GIOChannel *source, procmap_store_new (app->pid)); } + if (app->pid == 0 && app->child_terminated) + call_graph_store_update_tree_model (app->call_graph); + gdk_window_set_cursor (app->window->window, NULL); gnet_tcp_socket_delete (client); @@ -991,6 +981,9 @@ ensure_log (App *app) GtkWidget *w, *sw, *label; GtkTextIter iter; + if (app->discard_log) + return NULL; + if (app->log != NULL) return app->log; @@ -1051,8 +1044,10 @@ tcp_log_client_cb (GIOChannel *source, } } - gtk_text_buffer_get_end_iter (log, &iter); - gtk_text_buffer_insert (log, &iter, buf, ret); + if (log != NULL) { + gtk_text_buffer_get_end_iter (log, &iter); + gtk_text_buffer_insert (log, &iter, buf, ret); + } } while (ret == sizeof (buf)); if (ret <= 0) @@ -1185,6 +1180,7 @@ static void reap_child (GPid pid, gint status, gpointer data) { App *app = data; + gtk_widget_set_sensitive (app->refresh_button, FALSE); app->child_terminated = TRUE; g_spawn_close_pid (pid); @@ -1275,6 +1271,8 @@ int main app.allocators_by_addr.nodes = g_new0 (Allocator *, app.allocators_by_addr.size); + app.discard_log = TRUE; + window = main_window_create (&app); g_signal_connect (window, "delete-event", G_CALLBACK (gtk_main_quit), NULL); gtk_window_present (GTK_WINDOW (window)); @@ -1306,8 +1304,10 @@ int main if (io != NULL) { if (! load_allocators (io, &app)) { g_warning ("Failed to load allocations from '%s'", argv[1]); - } else + } else { + call_graph_store_update_tree_model (app.call_graph); have_allocators = TRUE; + } g_io_channel_unref (io); } if (! have_allocators) { |