From 22fd0d76760e6ce60a3548d009784ff619f9e810 Mon Sep 17 00:00:00 2001 From: Christian Hergert Date: Mon, 13 May 2019 22:55:14 -0700 Subject: [PATCH] libsysprof-ui: update callgraph when selection changes --- src/libsysprof-ui/sysprof-capture-view.c | 27 +++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/src/libsysprof-ui/sysprof-capture-view.c b/src/libsysprof-ui/sysprof-capture-view.c index 85d86295..e16f32af 100644 --- a/src/libsysprof-ui/sysprof-capture-view.c +++ b/src/libsysprof-ui/sysprof-capture-view.c @@ -398,6 +398,9 @@ sysprof_capture_view_real_load_async (SysprofCaptureView *self, g_assert (reader != NULL); g_assert (!cancellable || G_IS_CANCELLABLE (cancellable)); + g_clear_pointer (&priv->reader, sysprof_capture_reader_unref); + priv->reader = sysprof_capture_reader_ref (reader); + state = g_slice_new0 (LoadAsync); state->reader = sysprof_capture_reader_copy (reader); state->n_active = 0; @@ -419,7 +422,6 @@ sysprof_capture_view_real_load_async (SysprofCaptureView *self, g_set_object (&priv->cancellable, cancellable); } - /* First, discover the the time range for the display */ sysprof_capture_view_scan_async (self, reader, @@ -439,6 +441,21 @@ sysprof_capture_view_real_load_finish (SysprofCaptureView *self, return g_task_propagate_boolean (G_TASK (result), error); } +static void +sysprof_capture_view_selection_changed_cb (SysprofCaptureView *self, + SysprofSelection *selection) +{ + SysprofCaptureViewPrivate *priv = sysprof_capture_view_get_instance_private (self); + + g_assert (SYSPROF_IS_CAPTURE_VIEW (self)); + g_assert (SYSPROF_IS_SELECTION (selection)); + + if (priv->reader == NULL) + return; + + sysprof_capture_view_generate_callgraph_async (self, priv->reader, selection, NULL, NULL, NULL); +} + static void sysprof_capture_view_finalize (GObject *object) { @@ -516,9 +533,17 @@ static void sysprof_capture_view_init (SysprofCaptureView *self) { SysprofCaptureViewPrivate *priv = sysprof_capture_view_get_instance_private (self); + SysprofSelection *selection; gtk_widget_init_template (GTK_WIDGET (self)); + selection = sysprof_visualizer_view_get_selection (priv->visualizer_view); + g_signal_connect_object (selection, + "changed", + G_CALLBACK (sysprof_capture_view_selection_changed_cb), + self, + G_CONNECT_SWAPPED); + gtk_widget_insert_action_group (GTK_WIDGET (self), "zoom", G_ACTION_GROUP (priv->zoom_manager));