After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 567688 - signal_chain_from_overridden in size_request class closure
signal_chain_from_overridden in size_request class closure
Status: RESOLVED FIXED
Product: gnome-perl
Classification: Bindings
Component: Gtk2
unspecified
Other Linux
: Normal normal
: ---
Assigned To: gtk2-perl-bugs
gtk2-perl-bugs
Depends on:
Blocks:
 
 
Reported: 2009-01-13 23:42 UTC by Kevin Ryde
Modified: 2009-06-04 23:18 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
doc update and test case (2.65 KB, patch)
2009-06-02 23:19 UTC, Kevin Ryde
committed Details | Review
depend on Glib 1.221 (711 bytes, patch)
2009-06-04 23:18 UTC, Kevin Ryde
none Details | Review

Description Kevin Ryde 2009-01-13 23:42:53 UTC
As noted in the Gtk2::Widget signals pod, chaining up to a superclass size_request doesn't fill in any data.

The program below prints (among other things)

    after chain: 0x0

where I hoped the signal_chain_from_overridden would go to the Gtk2::Label size_request handler and get a desired size from it.  (You can see the desired size by changing $foo to a plain Gtk2::Label per the commented out line in main).

Chasing it down, I believe somewhere deep in signal_chain_from_overridden the Gtk2::Requisition supplied in the perl call is copied, so the pointer going to the g_signal_chain_from_overridden (in a GValue) is not the original and so the width/height stored in it by GtkLabel are never seen.

It made me wonder if most of the time a boxed object should be copied or not copied when passed to a C func.  But certainly in this case it shouldn't, since it's a kind of output location.



package Foo;
use strict;
use warnings;

use Gtk2;
use Glib::Object::Subclass
  'Gtk2::Label',
  signals => { size_request => \&_do_size_request };

sub _do_size_request {
  my ($self, $req) = @_;
  print "this is Foo::_do_size_request\n";
  print "text is '",$self->get_text,"'\n";
  print "before chain: ",$req->width,"x",$req->height,"\n";
  Glib::Object::signal_chain_from_overridden ($self, $req);
  print "after chain: ",$req->width,"x",$req->height,"\n";
}

package main;
use strict;
use warnings;
use Gtk2 '-init';

my $window = Gtk2::Window->new('toplevel');
my $foo = Foo->new();
#
# my $foo = Gtk2::Label->new();
#
$foo->set_text ('hello world');
$window->add ($foo);
$window->show_all;

my $req = $foo->size_request();
print "main: foo size ",$req->width,"x",$req->height,"\n";

Gtk2->main();
Comment 1 Kevin Ryde 2009-06-02 23:17:16 UTC
As noted on the mailing list, the latest change to Glib to have boxed objects not copied fixes this problem.  The change below removes the note in the docs and adds a test case exercising the now-successful chaining, when ready to have a dependency on that new enough Glib.
Comment 2 Kevin Ryde 2009-06-02 23:19:08 UTC
Created attachment 135853 [details] [review]
doc update and test case
Comment 3 Torsten Schoenfeld 2009-06-04 19:26:49 UTC
Ah, sweet.  I love it when bugs fix themselves.

I created a stable branch for Gtk2 so that this can go into master:
<http://git.gnome.org/cgit/perl-Gtk2/commit/?id=07d6735c82898346d412c72f0ce22a56a78ab8f7>
<http://git.gnome.org/cgit/perl-Gtk2/commit/?id=9c0a15933209c4a2a33028c08f884063c68ea6ea>

Thanks for the test case!
Comment 4 Kevin Ryde 2009-06-04 23:18:04 UTC
Created attachment 135993 [details] [review]
depend on Glib 1.221

Don't forget to bump the Glib dependency when ready, since of course the tests fail with 1.220.