Sign up

TextBuffer.registerSerializeTagset() segfault.

I have code that works in my GTK2 version. When the crash occurs the TextBuffer is in an as-created state. I attempt to serialize it for use as the last resort in my undo stack:

   ubyte[] serialize()
   {
      TextIter start = new TextIter();
      TextIter end = new TextIter();
      tb.getBounds(start, end);
      GdkAtom atom = tb.registerSerializeTagset(null);
      ubyte[] buffer = tb.serialize(tb, atom, start, end);
      return buffer;
   }

Any thoughts?

Re: TextBuffer.registerSerializeTagset() segfault.

On 11/07/2013 07:02 AM, Steve Teale wrote:

I have code that works in my GTK2 version. When the crash occurs the TextBuffer is in an as-created state. I attempt to serialize it for use as the last resort in my undo stack:

    ubyte[] serialize()
    {
       TextIter start = new TextIter();
       TextIter end = new TextIter();
       tb.getBounds(start, end);
       GdkAtom atom = tb.registerSerializeTagset(null);
       ubyte[] buffer = tb.serialize(tb, atom, start, end);
       return buffer;
    }

Any thoughts?

Not yet, but i'll look into it.

Re: TextBuffer.registerSerializeTagset() segfault.

Not yet, but i'll look into it.

This is about as simple as I can make it:

module tb;

import gtk.Main;
import gtk.MainWindow;
import gtk.Layout;
import gtk.TextView;
import gtk.TextBuffer;
import gtk.TextIter;

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

	this()
	{
		super("TextBuffer 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();
	}

   void serialize()
   {
      TextIter start = new TextIter();
      TextIter end = new TextIter();
      tb.getBounds(start, end);
      GdkAtom atom = tb.registerSerializeTagset(null);
      ub = tb.serialize(tb, atom, start, end);
   }

	void bufferChanged(TextBuffer b)
	{
	   string s = b.getText();
	   // Set up undo checkpoint on space or line end
	   if (!(s[$-1..$] == " " || s[$-1..$] == "\n"))
	      return;
	   serialize();
	}
}

void main(string[] args)
{
	Main.init(args);
	new Tb();
	Main.run();
	// Type something into the TextView. When you type space or enter it will crash
}

Re: TextBuffer.registerSerializeTagset() segfault.

On Fri, 08 Nov 2013 06:19:53 GMT, Steve Teale wrote:

Not yet, but i'll look into it.

This is about as simple as I can make it:

.. code ...

GdkAtom wasn't wrapped correctly, causing the segfaults. Opaque struct vs pointer to opaque struct.

Fixed in https://github.com/gtkd-developers/GtkD/commit/8c725818678731f89127a865cdacfd097df0375b.