From c2d27ce85aa913ab0f454c464ccd8785e126f815 Mon Sep 17 00:00:00 2001 From: Christian Hergert Date: Tue, 27 Jun 2023 15:50:42 -0700 Subject: [PATCH] libsysprof-gtk: ignore out-of-sequence data We shouldn't be getting this here, but drop it if we do come across it so that we don't screw up path drawing. --- src/libsysprof-gtk/sysprof-line-layer.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/libsysprof-gtk/sysprof-line-layer.c b/src/libsysprof-gtk/sysprof-line-layer.c index 37c5e81e..b558ad35 100644 --- a/src/libsysprof-gtk/sysprof-line-layer.c +++ b/src/libsysprof-gtk/sysprof-line-layer.c @@ -115,6 +115,12 @@ sysprof_line_layer_snapshot (GtkWidget *widget, float x = floor (x_values[i] * width); float y = floor (y_values[i] * height); + /* Skip if we are getting data incorrectly on the X axis. + * It should have been sorted by this point. + */ + if (x < last_x) + continue; + cairo_curve_to (cr, last_x + ((x - last_x)/2), last_y, @@ -134,6 +140,12 @@ sysprof_line_layer_snapshot (GtkWidget *widget, float x = floor (x_values[i] * width); float y = floor (y_values[i] * height); + /* Skip if we are getting data incorrectly on the X axis. + * It should have been sorted by this point. + */ + if (x < last_x) + continue; + cairo_line_to (cr, x, y); last_x = x;