summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBilal Elmoussaoui <belmouss@redhat.com>2022-03-30 12:16:00 +0200
committerBilal Elmoussaoui <belmouss@redhat.com>2022-03-30 12:21:29 +0200
commit8f9cc63e5a054067f0eb3b8100ab4871da39cc33 (patch)
tree1e978487c19280d6a4a6433c74049c2d855a06c7
parent04c9c6b4284110746089adadc12701b7f3bbf379 (diff)
downloadgtk+-bilelmoussaoui/editable-text.tar.gz
gtk: Handle NULL in Editable.set_textbilelmoussaoui/editable-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
-rw-r--r--gtk/gtkeditable.c12
1 files 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));
}