# HG changeset patch # User Frank Benoit # Date 1205057037 -3600 # Node ID 772f75da6a52a46e1aa11f93ae54c563bfeacd1a # Parent 69c0e2fa46b94cd8a261ce2ddf903c69de9ec2c3 Allow null argument for Label.setText diff -r 69c0e2fa46b9 -r 772f75da6a52 dwt/dwthelper/utils.d --- a/dwt/dwthelper/utils.d Sat Mar 08 14:00:55 2008 +0100 +++ b/dwt/dwthelper/utils.d Sun Mar 09 11:03:57 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, diff -r 69c0e2fa46b9 -r 772f75da6a52 dwt/widgets/Label.d --- a/dwt/widgets/Label.d Sat Mar 08 14:00:55 2008 +0100 +++ b/dwt/widgets/Label.d Sun Mar 09 11:03:57 2008 +0100 @@ -394,7 +394,8 @@ */ 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; /* * Feature in Windows. For some reason, SetWindowText() for @@ -402,7 +403,7 @@ * has not changed. The fix is to check for this case and do * nothing. */ - if (string==/*eq*/text) return; + if (string.equals(text)) return; text = string; if (image is null || !IMAGE_AND_TEXT) { int oldBits = OS.GetWindowLong (handle, OS.GWL_STYLE), newBits = oldBits; @@ -419,7 +420,7 @@ if (oldBits !is newBits) OS.SetWindowLong (handle, OS.GWL_STYLE, newBits); } string = Display.withCrLf (string); - TCHAR* buffer = StrToTCHARz (/+getCodePage (),+/ string); + TCHAR* buffer = StrToTCHARz ( getCodePage (), string); OS.SetWindowText (handle, buffer); /* * Bug in Windows. For some reason, the HBRUSH that