Re: [Vala] Warning while casting custom classes



Il 23/07/2012 02:02, Nor Jaidi Tuah ha scritto:

When casting to PicassoLine or PicassoRectangle it pop up:
(Picasso:10091): GLib-GObject-WARNING **: invalid cast from
`PicassoPicassoItem' to `PicassoPicassoRectangle' (or PicassoPicassoLine)

Try changing

((PicassoLine) canvas.preview).....

to

(canvas.preview as PicassoLine)....

If that still gives you warnings, try declaring
PicassoItem class as *abstract* so that you don't
accidentally do something like this:

   var type = ItemType.NONE;
   PicassoItem item = new PicassoItem(0, 0, type); // big mistake!
   item.type = ItemType.CIRCLE;   // big mistake!

By the way, I'm sure you don't need ItemType.
Vala supports runtime class check.

hand


_______________________________________________
vala-list mailing list
vala-list gnome org
https://mail.gnome.org/mailman/listinfo/vala-list


Thanks but i already solved this problem, i was casting PicassoItem to PicassoLine without having PicassoLine initialized...



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]