From b50093d044324ac9ed0cc39368a35a0733c41483 Mon Sep 17 00:00:00 2001 From: Benjamin Otte Date: Fri, 21 Feb 2020 18:25:05 +0100 Subject: [PATCH] transform: Make sure the identity transform is equal to NULL --- gsk/gsktransform.c | 7 +++++-- testsuite/gsk/transform.c | 13 +++++++++++++ 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/gsk/gsktransform.c b/gsk/gsktransform.c index df6cb63bdd..19aa543b23 100644 --- a/gsk/gsktransform.c +++ b/gsk/gsktransform.c @@ -1683,8 +1683,11 @@ gsk_transform_equal (GskTransform *first, if (first == second) return TRUE; - if (first == NULL || second == NULL) - return FALSE; + if (first == NULL) + return gsk_transform_is_identity (second); + + if (second == NULL) + return gsk_transform_is_identity (first); if (first->transform_class != second->transform_class) return FALSE; diff --git a/testsuite/gsk/transform.c b/testsuite/gsk/transform.c index 605d6f53cd..71ade76a49 100644 --- a/testsuite/gsk/transform.c +++ b/testsuite/gsk/transform.c @@ -332,6 +332,19 @@ test_identity (void) g_free (string); } +static void +test_identity_equal (void) +{ + GskTransform *id = gsk_transform_new (); + + g_assert_true (gsk_transform_equal (NULL, NULL)); + g_assert_true (gsk_transform_equal (id, NULL)); + g_assert_true (gsk_transform_equal (NULL, id)); + g_assert_true (gsk_transform_equal (id, id)); + + gsk_transform_unref (id); +} + static void test_print_parse (void) {