Skip to content

Commit

Permalink
gtk_text_buffer_get_text returns a char* which must be g_freed
Browse files Browse the repository at this point in the history
  • Loading branch information
christopherlam committed Jun 26, 2023
1 parent eefaeb5 commit 2f0577f
Show file tree
Hide file tree
Showing 8 changed files with 14 additions and 6 deletions.
7 changes: 4 additions & 3 deletions gnucash/gnome-utils/dialog-account.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 3 additions & 1 deletion gnucash/gnome-utils/gnc-cell-renderer-text-view.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion gnucash/gnome-utils/gnc-cell-view.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion gnucash/gnome-utils/gnc-cell-view.h
Original file line number Diff line number Diff line change
Expand Up @@ -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__ */
1 change: 1 addition & 0 deletions gnucash/gnome/dialog-customer.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 2 additions & 0 deletions gnucash/gnome/dialog-invoice.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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;
}

Expand Down
1 change: 1 addition & 0 deletions gnucash/gnome/dialog-order.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions gnucash/gnome/dialog-vendor.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 2f0577f

Please sign in to comment.