Sign up

Yet another

This time in gtk.TextIter.getTags(). This is about as succinct as I can make it:

module tb;

import std.stdio;
import glib.ListSG;
import gtk.Main;
import gtk.MainWindow;
import gtk.Layout;
import gtk.TextTag;
import gtk.TextView;
import gtk.TextBuffer;
import gtk.TextIter;

class Tb : MainWindow
{
    TextView te;
    TextBuffer tb;
    ubyte[] ub;

// **************************************************************************
   private static int nTags(TextIter ti)
   {
      writefln("ti %x", ti.getTextIterStruct());      // reports some non-null value

      ListSG sll = ti.getTags();                      // crashes here

      writefln("sll.length %d", sll.length);
      return sll.length();
   }
// **************************************************************************

    this()
    {
        super("TextIter.getTags() test");
        Layout f = new Layout(null, null);
        f.setSizeRequest(300,200);
        te = new TextView();
        tb = te.getBuffer();
        //tb.addOnChanged(&bufferChanged);
        te.setSizeRequest(290, 200);
        te.setRightMargin(2);
        te.doref();

        f.put(te, 5, 5);
        add(f);
        showAll();
// ***************************************************************************
        TextIter start = new TextIter();
        TextIter end = new TextIter();
        tb.getBounds(start, end);
        // Remove following line and it works OK
        nTags(start);
// ***************************************************************************
    }
}

void main(string[] args)
{
   Main.init(args);
   new Tb();
   Main.run();
}

Re: Yet another

On 11/11/2013 08:50 AM, Steve Teale wrote:

This time in gtk.TextIter.getTags(). This is about as succinct as I can make it:

... code ...

It's actually the next line that crashes, sll is null so sll.length()
segfaults.

Re: Yet another

On Mon, 11 Nov 2013 19:06:55 +0100, Mike Wey wrote:

On 11/11/2013 08:50 AM, Steve Teale wrote:

This time in gtk.TextIter.getTags(). This is about as succinct as I can make it:

... code ...

It's actually the next line that crashes, sll is null so sll.length()
segfaults.

Then how the hell did my original program work I wonder. Must check the GTK2 implementation of ListSG.