Skip to content

listSG/listG toArray() method bug #123

Description

@passenger94

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"
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions