From 99f067ffe3c203fbd9a734aa4b1a1cd96e5fd670 Mon Sep 17 00:00:00 2001 From: Robert Fewell <14uBobIT@gmail.com> Date: Fri, 24 Jan 2025 11:07:23 +0000 Subject: [PATCH] Fix g_object warning for creating schedule from trans When you try and schedule an open transaction like the blank transaction a dialog warns you and prevents doing so. As a result a couple of objects were being unrefed which had not be created so add a test for the objects before being unrefed. --- gnucash/gnome/dialog-sx-from-trans.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/gnucash/gnome/dialog-sx-from-trans.cpp b/gnucash/gnome/dialog-sx-from-trans.cpp index 0136fa27d7..1dd766021a 100644 --- a/gnucash/gnome/dialog-sx-from-trans.cpp +++ b/gnucash/gnome/dialog-sx-from-trans.cpp @@ -623,9 +623,10 @@ sxftd_destroy( GtkWidget *w, gpointer user_data ) xaccSchedXactionDestroy(sxfti->sx); sxfti->sx = NULL; } - - g_object_unref(G_OBJECT(sxfti->dense_cal_model)); - g_object_unref(G_OBJECT(sxfti->example_cal)); + if (sxfti->dense_cal_model) + g_object_unref(G_OBJECT(sxfti->dense_cal_model)); + if (sxfti->example_cal) + g_object_unref(G_OBJECT(sxfti->example_cal)); g_free(sxfti); }