[Gtk-sharp-list] Problems with DiaCanvas# new items

Mario Fuentes mario@gnome.cl
Tue, 03 Aug 2004 14:17:42 -0400

Hello, i'm working on diacanvas# support for create new items based on
Dia.CanvasItem.  I'm implemented four virtual methods, "update",
"get_shape_iter", "shape_next" and "shape_value".  the three first
methods are ok, but "shape_value" have a problem.
I implemented "shape_value" like this:

DiaShape *
diasharp_canvas_item_base_shape_value (DiaCanvasItem *item,
DiaCanvasIter *iter){
   DiaCanvasItemClass *parent = g_type_class_peek_parent

   if (parent->shape_value)
      return ((*parent->shape_value) (item, iter));

   return NULL;

diasharp_canvas_item_override_shape_value (GType gtype, gpointer
   DiaCanvasItemClass *klass;

   klass = g_type_class_peek (gtype);

   if (!klass)
      klass = g_type_class_ref (gtype);

   ((DiaCanvasItemClass *) klass)->shape_value = callback;

delegate Shape ShapeValueDelegate (IntPtr item, ref CanvasIter iter);

static ShapeValueDelegate ShapeValueCallback;

static Shape ShapeValue_Callback (IntPtr item, ref CanvasIter iter)
	CanvasItem obj = GLib.Object.GetObject (item, false) as CanvasItem;

	return obj.ShapeValueFunc (ref iter);

static extern void diasharp_canvas_item_override_shape_value (GLib.GType
gtype, ShapeValueDelegate callback);

static void OverrideShapeValue (GLib.GType gtype)
	if (ShapeValueCallback == null)
		ShapeValueCallback += new ShapeValueDelegate (ShapeValue_Callback);

	diasharp_canvas_item_override_shape_value (gtype, ShapeValueCallback);

static extern IntPtr dia_canvas_item_base_shape_value (IntPtr raw, ref
Dia.CanvasIter iter);

[GLib.DefaultSignalHandler (Type=typeof(Dia.CanvasItem),
protected virtual Shape ShapeValueFunc (ref CanvasIter iter)
	Console.WriteLine ("protected virtual Shape ShapeValueFunc (ref
CanvasIter iter)");
	IntPtr raw_ret = dia_canvas_item_base_shape_value (Handle, ref iter);
	Shape ret;
	if (raw_ret == IntPtr.Zero)
		ret = null;
		ret = new Dia.Shape(raw_ret);

	return ret;

public class MyItem : CanvasElement {
	protected override Shape ShapeValueFunc (ref CanvasIter iter)
		Console.WriteLine ("ShapeValue");

		if (iter.Data[0] == IntPtr.Zero)
			return null;
		return new Shape (iter.Data[0]);

When override "ShapeValueFunc" method, sample crash with this message:

** ERROR **: file marshal.c: line 2580
(mono_marshal_get_managed_wrapper): assertion failed: ((klass->flags &

All code is in the CVS version of diacanvas# (diacavas-sharp module in
mono anoncvs)

Any idea is welcome, we need diacanvas# for MonoUML project.

Mario Fuentes
<<Se omitio la tildacion, para evitar perdida de informacion>>