gtkd-developers / GtkD

GtkD is a D binding and OO wrapper of GTK+ originally created by Antonio Monteiro
http://gtkd.org
Other
322 stars 71 forks source link

listSG/listG toArray() method bug #123

Closed passenger94 closed 9 years ago

passenger94 commented 9 years ago

Hi ladies and gentlemen, thanks for your work ! i think i might have found a bug :

when transforming a listSG of PixbufFormat to an Array, iterating over gives only the first element in the list (tried with each, map, foreach and for) demo app

import  std.algorithm, std.string;
import  gtk.Main, gtk.Window, gtk.Label, gdkpixbuf.Pixbuf;

class ViewWindow : Window
{
  this() {
    super("listSG bug Demo");
    setSizeRequest(400, 300);
    auto label = new Label("");
    label.setLineWrap(true);
    label.setMaxWidthChars(50);
    add(label);

    auto pixbuf = new Pixbuf(Colorspace.RGB, false, 8, 100, 100);
    string[] validexts;

    import gdkpixbuf.PixbufFormat;

    /* I got only the first element of the Array, repeatedly ...
     * in glib.listSG, line 93 : must be "list = list.next();" not "list = next();"
     * most probably the same in glib.ListG, line 106
     * 
     * related to "https://www.youtube.com/watch?t=1483&v=A8Btr8TPJ8c" around 26" ??
    */
    pixbuf.getFormats.toArray!PixbufFormat[1..$].each!( el => validexts ~= el.getExtensions );

    label.setText(format("%s", validexts));
  }
}

resolved by changing list = next(); to list = list.next(); in toArray method of glib.listSG https://github.com/gtkd-developers/GtkD/blob/master/src/glib/ListSG.d#L93

sorry i don't have the time now to do the install everything/pullrequest dance

dmd 2.068, gtkd 3.1.4, ubuntu 14.04, gtk3 3.10 build with dub :

{
    "name": "listsgbug",
    "dependencies": {
        "gtk-d": "~>3.1.4"
    }
}