Re: Problem with subclassing with Glib::Object::Subclass and Gtk3

Hm. It seems the problem is in Glib::Object::Introspection XS function _invoke_fallback_vfunc:


It can't handle undef parameters. For example, in "screen-changed" handler (I didn't connect any handlers to 
this signal in my class):

void user_function (GtkWidget *widget, GdkScreen *previous_screen, gpointer   user_data)

where "previous_screen" -- the previous screen, or NULL if the widget was not associated with a screen before.

In my case "previous_screen" is undef because it should be NULL in C. But Glib::Object::Introspection 
requires that "previous_screen" should be Gtk3::Gdk::Screen and it fails when "previous_screen" is undef: 
"undef is not of type Gtk3::Gdk::Screen".

09.04.2015, 22:29, "Yuri Myasoedov" <ymyasoedov yandex ru>:

 I have a problem with migration of my code to Gtk3. Just a simple example. I want to subclass from 
Gtk3::Button with Glib::Object::Subclass.
 There is no new signals, no properties and so on... BTW, when I switched to Gtk3, I have to define two 
 signals, PARENT_SET and HIERARCHY_CHANGED. This code just works if I replace Gtk3 to Gtk2. But it doesn't
 when I use Gtk3. I've got a error: "undef is not of type Gtk3::Gdk::Screen at 
/usr/lib/perl5/site_perl/Glib/Object/ line 246."

 What's wrong with it? Can I still use Glib::Object::Subclass for inheritance for Gtk3?


 use strict;
 use warnings;

 package MyButton;

 use Gtk3;

 use Glib::Object::Subclass
     signals => {},
     properties => [],

     my $self = shift;
     return $self;

     my $self = shift;
     warn "PARENT_SET was called\n";

     my $self = shift;
     warn "HIERARCHY_CHANGED was called\n";

 package main;

 use Gtk3 -init;

 my $window = Gtk3::Window->new();
 $window->signal_connect(delete_event => sub { Gtk3->main_quit() });

 my $my_button = MyButton->new(label => "Test");

 [ysm helios tmp]$ perl

 ( Gtk-WARNING **: Theme parsing error: gtk-widgets.css:2:16: Theming engine 'adwaita' not found
 PARENT_SET was called
 undef is not of type Gtk3::Gdk::Screen at /usr/lib/perl5/site_perl/Glib/Object/ line 246.
 gtk-perl-list mailing list
 gtk-perl-list gnome org

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