gnucash stable: gtk_text_buffer_get_text returns a char* which must be g_freed
Christopher Lam
clam at code.gnucash.org
Mon Jun 26 08:37:17 EDT 2023
Updated via https://github.com/Gnucash/gnucash/commit/2f0577fb (commit)
from https://github.com/Gnucash/gnucash/commit/eefaeb53 (commit)
commit 2f0577fb341561c1cf2f464a828ac1036680ea24
Author: Christopher Lam <christopher.lck at gmail.com>
Date: Mon Jun 26 19:59:48 2023 +0800
gtk_text_buffer_get_text returns a char* which must be g_freed
diff --git a/gnucash/gnome-utils/dialog-account.c b/gnucash/gnome-utils/dialog-account.c
index 48856f4da5..c98e10fde5 100644
--- a/gnucash/gnome-utils/dialog-account.c
+++ b/gnucash/gnome-utils/dialog-account.c
@@ -521,10 +521,11 @@ gnc_ui_to_account (AccountWindow *aw)
gtk_text_buffer_get_start_iter (aw->notes_text_buffer, &start);
gtk_text_buffer_get_end_iter (aw->notes_text_buffer, &end);
- string = gtk_text_buffer_get_text (aw->notes_text_buffer, &start, &end, FALSE);
+ char *new_string = gtk_text_buffer_get_text (aw->notes_text_buffer, &start, &end, FALSE);
old_string = xaccAccountGetNotes (account);
- if (null_strcmp (string, old_string) != 0)
- xaccAccountSetNotes (account, string);
+ if (g_strcmp0 (new_string, old_string))
+ xaccAccountSetNotes (account, new_string);
+ g_free (new_string);
flag = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON(aw->opening_balance_button));
if (xaccAccountGetIsOpeningBalance (account) != flag)
diff --git a/gnucash/gnome-utils/gnc-cell-renderer-text-view.c b/gnucash/gnome-utils/gnc-cell-renderer-text-view.c
index 78b3b0ddca..3a0b1e8a29 100644
--- a/gnucash/gnome-utils/gnc-cell-renderer-text-view.c
+++ b/gnucash/gnome-utils/gnc-cell-renderer-text-view.c
@@ -66,7 +66,7 @@ gcrtv_editing_done (GtkCellEditable *editable,
GncCellRendererTextView *cell_tv)
{
gchar *path;
- const gchar *new_text;
+ gchar *new_text;
if (GNC_CELL_VIEW(editable)->focus_out_id > 0)
{
@@ -96,6 +96,8 @@ gcrtv_editing_done (GtkCellEditable *editable,
gtk_cell_editable_remove_widget (GTK_CELL_EDITABLE(editable));
g_signal_emit_by_name (cell_tv, "edited", path, new_text);
+
+ g_free (new_text);
}
static gboolean
diff --git a/gnucash/gnome-utils/gnc-cell-view.c b/gnucash/gnome-utils/gnc-cell-view.c
index 6004c6fef5..d2d64bbaf4 100644
--- a/gnucash/gnome-utils/gnc-cell-view.c
+++ b/gnucash/gnome-utils/gnc-cell-view.c
@@ -260,7 +260,7 @@ gnc_cell_view_set_text (GncCellView *cv, const gchar *text)
-1);
}
-const gchar *
+gchar *
gnc_cell_view_get_text (GncCellView *cv)
{
GtkTextIter siter, eiter;
diff --git a/gnucash/gnome-utils/gnc-cell-view.h b/gnucash/gnome-utils/gnc-cell-view.h
index 601e4cc71f..344481a19c 100644
--- a/gnucash/gnome-utils/gnc-cell-view.h
+++ b/gnucash/gnome-utils/gnc-cell-view.h
@@ -60,6 +60,6 @@ GtkWidget *gnc_cell_view_new (void);
void gnc_cell_view_set_text (GncCellView *cv, const gchar *text);
-const gchar *gnc_cell_view_get_text (GncCellView *cv);
+gchar *gnc_cell_view_get_text (GncCellView *cv);
#endif /* __GNC_CELL_VIEW_H__ */
diff --git a/gnucash/gnome/dialog-customer.c b/gnucash/gnome/dialog-customer.c
index 3fa9778ddd..d327a5e580 100644
--- a/gnucash/gnome/dialog-customer.c
+++ b/gnucash/gnome/dialog-customer.c
@@ -258,6 +258,7 @@ static void gnc_ui_to_customer (CustomerWindow *cw, GncCustomer *cust)
gncCustomerCommitEdit (cust);
gnc_resume_gui_refresh ();
+ g_free (text);
}
static gboolean check_edit_amount (GtkWidget *amount,
diff --git a/gnucash/gnome/dialog-invoice.c b/gnucash/gnome/dialog-invoice.c
index 3359af65a8..ac6ac27bcf 100644
--- a/gnucash/gnome/dialog-invoice.c
+++ b/gnucash/gnome/dialog-invoice.c
@@ -441,6 +441,7 @@ static void gnc_ui_to_invoice (InvoiceWindow *iw, GncInvoice *invoice)
gncInvoiceCommitEdit (invoice);
gnc_resume_gui_refresh ();
+ g_free (text);
}
static gboolean
@@ -1522,6 +1523,7 @@ gnc_invoice_window_leave_notes_cb (GtkWidget *widget, GdkEventFocus *event,
gtk_text_buffer_get_bounds (text_buffer, &start, &end);
text = gtk_text_buffer_get_text (text_buffer, &start, &end, FALSE);
gncInvoiceSetNotes (invoice, text);
+ g_free (text);
return FALSE;
}
diff --git a/gnucash/gnome/dialog-order.c b/gnucash/gnome/dialog-order.c
index 2ca69b3951..c45faaa60b 100644
--- a/gnucash/gnome/dialog-order.c
+++ b/gnucash/gnome/dialog-order.c
@@ -154,6 +154,7 @@ static void gnc_ui_to_order (OrderWindow *ow, GncOrder *order)
gncOrderCommitEdit (order);
gnc_resume_gui_refresh ();
+ g_free (text);
}
static gboolean
diff --git a/gnucash/gnome/dialog-vendor.c b/gnucash/gnome/dialog-vendor.c
index 10b6ab52bf..46b458392d 100644
--- a/gnucash/gnome/dialog-vendor.c
+++ b/gnucash/gnome/dialog-vendor.c
@@ -178,6 +178,7 @@ static void gnc_ui_to_vendor (VendorWindow *vw, GncVendor *vendor)
gncVendorCommitEdit (vendor);
gnc_resume_gui_refresh ();
+ g_free (text);
}
static gboolean check_entry_nonempty (GtkWidget *entry,
Summary of changes:
gnucash/gnome-utils/dialog-account.c | 7 ++++---
gnucash/gnome-utils/gnc-cell-renderer-text-view.c | 4 +++-
gnucash/gnome-utils/gnc-cell-view.c | 2 +-
gnucash/gnome-utils/gnc-cell-view.h | 2 +-
gnucash/gnome/dialog-customer.c | 1 +
gnucash/gnome/dialog-invoice.c | 2 ++
gnucash/gnome/dialog-order.c | 1 +
gnucash/gnome/dialog-vendor.c | 1 +
8 files changed, 14 insertions(+), 6 deletions(-)
More information about the gnucash-changes
mailing list