Ticket #33: memory-bug.diff

File memory-bug.diff, 3.2 kB (added by Mike Wey, 7 months ago)

Diff for the implementation of the constructor option (wrapper only)

  • demos/cairo/cairo_clock/clock.d

    old new  
    6363         
    6464        // This is where we draw on the window 
    6565         
    66         Drawable dr = getDrawable(); 
     66        Drawable dr = getWindow(); 
    6767         
    6868        int width; 
    6969        int height; 
  • wrap/APILookupGObject.txt

    old new  
    172172        if ( gObject !is  null ) 
    173173        { 
    174174            //writefln("ObjectG.this\n"); 
     175 
     176            //Check if there already is a D object for this gtk struct 
     177            void* ptr = getDObject(gObject); 
     178            if( ptr !is null ) 
     179            { 
     180                this = cast(ObjectG)ptr; 
     181                return; 
     182            } 
     183 
    175184            objectGSetDataFull("GObject",cast(void*)this); 
    176185        } 
    177186    } 
     
    203212        } 
    204213    } 
    205214 
     215    /** 
     216     * Gets a D Object from the objects table of associations. 
     217     * Params: 
     218     *  object = GObject containing the associations. 
     219     * Returns: the D Object if found, or NULL if no such Object exists. 
     220     */ 
     221    public static void* getDObject(GObject* obj) 
     222    { 
     223        //gpointer g_object_get_data(GObject *object, const gchar *key); 
     224        return g_object_get_data(obj, Str.toStringz("GObject")); 
     225    } 
     226 
    206227//debug = objectstore; 
    207228// 
    208229//debug(objectstore) 
     
    380401    { 
    381402        g_object_set( gObject, Str.toStringz(propertyName), value, null); 
    382403    } 
    383      
    384404code: end 
    385405 
    386406outFile: ObjectG 
  • wrap/APILookupGtk.txt

    old new  
    23282328 
    23292329struct: GtkTreeModel 
    23302330class: TreeModel 
     2331extend: GObject 
    23312332prefix: gtk_tree_model_ 
    23322333noprefix: gtk_tree_row_reference_ 
    23332334noprefix: gtk_tree_path_ 
  • wrap/utils/GtkDClass.d

    old new  
    614614                            text ~= " */"; 
    615615                            text ~= "public this ("~gtkStruct~"* "~var~")"~iFaceChar; 
    616616                            text ~= "{"; 
    617                             char[] tabs = "\t\t"; //What is this for? 
    618                             /* Deprecated */ /* 
    619                             text ~= getAssertStructNotNull(var); */ 
    620                             char[][] checkIfNull = [ 
     617 
     618                            char[][] checkIfNull = [ 
    621619                                "if("~var~" is null)", 
    622620                                "{", 
    623621                                "   this = null;", 
    624622                                "   version(Exceptions) throw new Exception(\"Null "~var~" passed to constructor.\");", 
    625623                                "   else return;", 
    626624                                "}" ]; 
     625 
     626                            char[][] checkObject = [ 
     627                                "" 
     628                                "//Check if there already is a D object for this gtk struct", 
     629                                "void* ptr = getDObject(cast(GObject*)"~var~");", 
     630                                "if( ptr !is null )", 
     631                                "{", 
     632                                "   this = cast("~convParms.clss~")ptr;", 
     633                                "   return;", 
     634                                "}" ]; 
     635 
    627636                            text ~= checkIfNull; 
     637                            if ( gtkDParentName.length > 0 && gtkDParentName != "Surface" ) 
     638                                text ~= checkObject; 
     639 
    628640                            if ( parentName.length > 0 ) 
    629641                            { 
    630642                                text ~= "super("~castToParent(var)~");";