New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

listSG/listG toArray() method bug #123

Closed
passenger94 opened this Issue Aug 23, 2015 · 0 comments

Comments

Projects
None yet
1 participant
@passenger94

passenger94 commented Aug 23, 2015

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

@MikeWey MikeWey closed this in 356ff45 Aug 24, 2015

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment