In D, how do I pass an empty string? (up to gtkD)

Using D1 with phobos

I have a text input field, an instance gtk.Entry.Entry,

the call setText("")causes a runtime error

Gtk-CRITICAL **: gtk_entry_set_text: assertion `text != NULL' failed

Why? There seems to be a problem with D, I tried this:

string empty = "";
assert (empty != null);
my_entry.setText(empty)

The program terminated with an approval error.

How can I get around this?

+5
source share
3 answers

I do not think that D really distinguishes between an empty string and an empty string. A cheap workaround will be set to Text ("").

[edit] Ignore this. This is a bug in gtkD. in trunk / src / glib / Str.d (thanks to wm4 for looking for it), change line 147 to return ""; (delete.).

+5

assert (empty! is null) assert (empty!= null)

+3

"\0" , , ,

I don’t know if any invisible character got into the text box, but this is based on the assumption that an empty string in C is just \0

+1
source

All Articles