Re: [Vala] Warning while casting custom classes




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





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