Mercurial > projects > dwt-linux
changeset 207:12feeed18183
Allow Label.setText with null argument.
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Sun, 09 Mar 2008 10:58:49 +0100 |
parents | 3cb84407dc3e |
children | fff9f748b33b |
files | dwt/dwthelper/utils.d dwt/widgets/Label.d |
diffstat | 2 files changed, 14 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/dwt/dwthelper/utils.d Sat Mar 08 23:00:05 2008 +0100 +++ b/dwt/dwthelper/utils.d Sun Mar 09 10:58:49 2008 +0100 @@ -320,6 +320,16 @@ return typeid(char[]).getHash(&src); } +public char* toStringzValidPtr( char[] src ){ + if( src ){ + return src.toStringz(); + } + else{ + static const char[] nullPtr = "\0"; + return nullPtr.ptr; + } +} + static char[] toHex(uint value, bool prefix = true, int radix = 8){ return tango.text.convert.Integer.toString( value,
--- a/dwt/widgets/Label.d Sat Mar 08 23:00:05 2008 +0100 +++ b/dwt/widgets/Label.d Sun Mar 09 10:58:49 2008 +0100 @@ -21,7 +21,7 @@ import dwt.widgets.Composite; import dwt.widgets.ImageList; -import tango.stdc.stringz; +import dwt.dwthelper.utils; /** * Instances of this class represent a non-selectable @@ -567,11 +567,12 @@ */ public void setText (char[] string) { checkWidget (); - if (string is null) error (DWT.ERROR_NULL_ARGUMENT); + // DWT extension: allow null for zero length string + //if (string is null) error (DWT.ERROR_NULL_ARGUMENT); if ((style & DWT.SEPARATOR) !is 0) return; text = string; char [] chars = fixMnemonic (string); - OS.gtk_label_set_text_with_mnemonic (cast(GtkLabel*)labelHandle, toStringz(chars)); + OS.gtk_label_set_text_with_mnemonic (cast(GtkLabel*)labelHandle, chars.toStringzValidPtr()); OS.gtk_widget_hide (imageHandle); OS.gtk_widget_show (labelHandle); }