Changeset 207:12feeed18183

Show
Ignore:
Timestamp:
03/09/08 05:58:49 (6 months ago)
Author:
Frank Benoit <benoit@tionex.de>
branch:
default
Message:

Allow Label.setText with null argument.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • dwt/dwthelper/utils.d

    r200 r207  
    321321} 
    322322 
     323public char* toStringzValidPtr( char[] src ){ 
     324    if( src ){ 
     325        return src.toStringz(); 
     326    } 
     327    else{ 
     328        static const char[] nullPtr = "\0"; 
     329        return nullPtr.ptr; 
     330    } 
     331} 
     332 
    323333static char[] toHex(uint value, bool prefix = true, int radix = 8){ 
    324334    return tango.text.convert.Integer.toString( 
  • dwt/widgets/Label.d

    r152 r207  
    2222import dwt.widgets.ImageList; 
    2323 
    24 import tango.stdc.stringz
     24import dwt.dwthelper.utils
    2525 
    2626/** 
     
    568568public void setText (char[] string) { 
    569569    checkWidget (); 
    570     if (string is null) error (DWT.ERROR_NULL_ARGUMENT); 
     570    // DWT extension: allow null for zero length string 
     571    //if (string is null) error (DWT.ERROR_NULL_ARGUMENT); 
    571572    if ((style & DWT.SEPARATOR) !is 0) return; 
    572573    text = string; 
    573574    char [] chars = fixMnemonic (string); 
    574     OS.gtk_label_set_text_with_mnemonic (cast(GtkLabel*)labelHandle, toStringz(chars)); 
     575    OS.gtk_label_set_text_with_mnemonic (cast(GtkLabel*)labelHandle, chars.toStringzValidPtr()); 
    575576    OS.gtk_widget_hide (imageHandle); 
    576577    OS.gtk_widget_show (labelHandle);