Re: Strange bug

On Thursday, November 20, 2003, at 08:42 AM, Bjarne Steinsbø wrote:

Error message is:
*** unhandled exception in callback:
***   variable is not of type Gtk2::Gdk::Drawable at t line 23.
***  ignoring at t line 31.

Something to do with ..._ornull typemap?

only in a roundabout way.

gtk doesn't define a GType for GdkBitmap, but instead just typedefs it to be the same as GdkDrawable. because of this, the typemap, variant typedefs, and SV macros don't get generated by CodeGen; instead we have to create them by hand.

gdk.typemap adds the typemap for GdkBitmap. the typemap, T_GPERL_GENERIC_WRAPPER, does "Sv$type ($arg)", which, for GdkBitmap_ornull, turns into SvGdkBitmap_ornull (ST (2)).

in gtk2perl.h, you can find the variant typedefs and macros for GdkBitmap. a bug is on line 58.

#define SvGdkBitmap_ornull(sv) (((sv) == &PL_sv_undef) ? NULL : SvGdkBitmap(sv))

should be

#define SvGdkBitmap_ornull(sv) (((sv) && SvTRUE (sv)) ? NULL : SvGdkBitmap(sv))

that may not be *the* bug, but it should help.  let me know.

to finish the GdkBitmap story... since there's no GType for GdkBitmap, we have to do a couple of hacks to round out the object support. the Perl-to-C path uses the standard macros-around-gperl_get_object trick, but without a GType gperl_new_object would bless into the wrong class. so, newSVGdkBitmap and newSVGdkBitmap_noinc are actual functions, implemented in Gtk2/xs/GdkPixmap.xs ... the basic trick is to create the object with gperl_new_object, let it get blessed into the bottommost known GType, and then re-bless it into Gtk2::Gdk::Bitmap, for which we added an @ISA to Gtk2::Gdk::Pixmap in the BOOT section.

as you can see, it's all very straightforward.  *cough*

in general, however, i just avoid the use of GdkBitmaps, because GdkPixbuf is a lot easier, especially when you already have to transfer all the data to the server anyway. you could replace most of that loading code with:

  my $pixbuf = Gtk2::Gdk::Pixbuf->new_from_file ($filename);
  $image->set_from_pixbuf ($pixbuf);

muppet <scott at asofyet dot org>

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