[gtk/bilelmoussaoui/editable-text] gtk: Handle NULL in Editable.set_text
- From: Bilal Elmoussaoui <bilelmoussaoui src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/bilelmoussaoui/editable-text] gtk: Handle NULL in Editable.set_text
- Date: Wed, 30 Mar 2022 10:21:47 +0000 (UTC)
commit 8f9cc63e5a054067f0eb3b8100ab4871da39cc33
Author: Bilal Elmoussaoui <belmouss redhat com>
Date: Wed Mar 30 12:16:00 2022 +0200
gtk: Handle NULL in Editable.set_text
All the GObject string properties should handle the NULL case.
Fixes a downstream bug at https://github.com/gtk-rs/gtk4-rs/issues/981
gtk/gtkeditable.c | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
---
diff --git a/gtk/gtkeditable.c b/gtk/gtkeditable.c
index a9517e1c1e..7c92409e3b 100644
--- a/gtk/gtkeditable.c
+++ b/gtk/gtkeditable.c
@@ -19,7 +19,7 @@
* Modified by the GTK+ Team and others 1997-2000. See the AUTHORS
* file for a list of people on the GTK+ Team. See the ChangeLog
* files for a list of changes. These files are distributed with
- * GTK+ at ftp://ftp.gtk.org/pub/gtk/.
+ * GTK+ at ftp://ftp.gtk.org/pub/gtk/.
*/
/**
@@ -502,7 +502,7 @@ gtk_editable_insert_text (GtkEditable *editable,
if (length < 0)
length = strlen (text);
-
+
GTK_EDITABLE_GET_IFACE (editable)->do_insert_text (editable, text, length, position);
}
@@ -597,7 +597,7 @@ gtk_editable_get_text (GtkEditable *editable)
/**
* gtk_editable_set_text: (attributes org.gtk.Method.set_property=text)
* @editable: a `GtkEditable`
- * @text: the text to set
+ * @text: (nullable): the text to set
*
* Sets the text in the editable to the given value.
*
@@ -614,7 +614,11 @@ gtk_editable_set_text (GtkEditable *editable,
g_object_freeze_notify (G_OBJECT (editable));
gtk_editable_delete_text (editable, 0, -1);
pos = 0;
- gtk_editable_insert_text (editable, text, -1, &pos);
+
+ if (text == NULL)
+ gtk_editable_insert_text (editable, "", 0, &pos);
+ else
+ gtk_editable_insert_text (editable, text, -1, &pos);
g_object_thaw_notify (G_OBJECT (editable));
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]