Re: GooCanvas2 set_transform method seg faults



This is certainly related to a bug I encountered and haven't reported yet, so I thought I would mention it now.

This is just using Gtk3, if I create a matrix and rotate it to anything other than 0, calling
$matrix->transform_rectangle($rect) segfault.

And a related bug, creating a matrix with Pango::Matrix->new() cause drawing failures for all widgets, so I had to create it with the identity matrix like this Pango::Matrix->new(xx=>1,xy=>0,yx=>0,yy=>1,x0=>0,y0=>0) which really should be what Pango::Matrix->new() should do by default.

And by the way, thanks to everyone working on these bindings :)

#!/usr/bin/perl
use strict;
use warnings;

use Gtk3 "-init";

my $w=Gtk3::Window->new;
my $da=Gtk3::DrawingArea->new;
$da->signal_connect(draw=>\&draw_cb);
$da->signal_connect(destroy=>sub { Gtk3->main_quit });
$w->add($da);
$w->show_all;


Gtk3->main;


sub draw_cb {
my ($self,$cr)=@_;
my $style= $self->get_style_context;
my $pangocontext= $self->create_pango_context;
my $layout= Pango::Layout->new($pangocontext);
$layout->set_text("this is a test");
my $matrix= Pango::Matrix->new(xx=>1,xy=>0,yx=>0,yy=>1,x0=>0,y0=>0);
#my $matrix= Pango::Matrix->new; #cause drawing failure for all widgets : "invalid matrix (not invertible)"
$matrix->rotate(90);
$layout->get_context->set_matrix($matrix);
my $rect=$layout->get_extents;
warn $matrix->transform_rectangle($rect); #Segmentation fault if rotation is not 0
Gtk3::render_layout($style,$cr,50,50,$layout);
}

On Fri, Nov 13, 2020 at 2:15 AM Shawn Laffan via gtk-perl-list <gtk-perl-list gnome org> wrote:
I'm porting an application from Gtk2/Gnome2::Canvas to Gtk3/GooCanvas2.  Most of the process has gone relatively smoothly, but I have hit segmentation faults when calling the GooCanvas2 transform methods.

Calling the set_transform method on a canvas item results in "ERROR:gperl-i11n-marshal-struct.c:119:sv_to_struct: assertion failed: (package)".

Code to reproduce is below (adapted from the GooCanvas2 module synopsis).  

I've also reported this to RT, but have yet to get a response from the module author.  
https://rt.cpan.org/Public/Bug/Display.html?id=133659


Is this something that can be fixed in the perl bindings?  Or is the issue deeper? 

FWIW, I can reproduce on Windows (Strawberry perl 5.28.0, using PPMs from Sisyphusion.tk), and on Centos (perlbrew 5.30).

Thanks,
Shawn.


====

use strict;
use warnings;
use 5.022;

local $| = 1;

use Gtk3 -init;
use GooCanvas2;
 
my $window = Gtk3::Window->new();
$window->set_default_size(640, 600);
$window->signal_connect('destroy' => sub {Gtk3->main_quit()});
 
my $scrolled_win = Gtk3::ScrolledWindow->new();
$scrolled_win->set_shadow_type('in');
 
my $canvas = GooCanvas2::Canvas->new();
$canvas->set_size_request(600,450);
$canvas->set_bounds(0,0,1000,1000);
$scrolled_win->add($canvas);
 
my $root = $canvas->get_root_item();

my $rect_item = GooCanvas2::CanvasRect->new(
    'parent' => $root,
    'x' => 100,
    'y' => 100,
    'width' => 300,
    'height' => 400,
    'line_width' => 10.0,
    'radius-x' => 20.0,
    'radius-y' => 10.0,
    'stroke-color' => 'yellow',
    'fill-color' => 'red',
);
 

my $mx = Cairo::Matrix->init (1, 0, 0, 1, 1, 1);

#  this fails
my $tfm = eval {
    $rect_item->set_transform ($mx);
};
say $@ if $@;

say 'Getting transform';
my (@tt) = eval {
    $rect_item->get_transform;
};
say $@ if $@;

say join ' ', map {$_ // 'undef'} @tt;
 
# Connect a signal handler for the rectangle item.
$rect_item->signal_connect('button_press_event' => \&on_rect_button_press);
 
$window->add($scrolled_win);
$window->show_all;
 
# Pass control to the Gtk3 main event loop
Gtk3->main();
 
# This handles button presses in item views.
#We simply output a message to the console
sub on_rect_button_press {
    my ($item, $target, $event) = @_;
    print "rect item received button press event \n";
    return 1;
}

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


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