Re: Glib 1.102 (stable)



On Thu, Dec 15, 2005 at 10:24:53AM -0500, muppet wrote:

On Dec 15, 2005, at 8:53 AM, Sean Dague wrote:

On Mon, Nov 28, 2005 at 09:49:31PM +0100, Torsten Schoenfeld wrote:
On Mon, 2005-11-28 at 21:48 +0100, Torsten Schoenfeld wrote:

http://sourceforge.net/project/showfiles.php? 
group_id=64773&package_id=160888&release_id=353295

This should read

http://sourceforge.net/project/showfiles.php? 
group_id=64773&package_id=91217&release_id=374366

of course.

I'm getting a lot of users of perl-Glib 1.102 reporting segfaults  
(1.101
works fine for them.)  The following is the backtrace I've managed  
to gather
from one of the users:

This looks like you have a perl-derived CellRenderer in your code.   
In frame #5, gtk_tree_view_column_cell_set_cell_data() is calling  
g_object_set_property() on something, most likely using an attribute  
set up when the TreeViewColumn was created.

The first red flag is the value of property_name in frame #4 -- is  
that a garbage string or a unicode string?  I believe that most of  
the code assumes property names will be ASCII.  This questionable  
value appears to have been mapped to a decent property id for the  
call to gperl_type_set_property(), which is in the vtable for perl- 
derived GObjects.  When gperl_type_set_property() discovers there is  
no SET_PROPERTY() in the package and no sub registered as a set  
handler, it falls back to setting a key in the wrapper hash with the  
same name as the property.  However, as you see in the trace, the  
name in frame #2 does not match the property_name in frame #4.

The code in question is actually a derived version of
Gtk2::CellRendererPixText to use stock icons (the code is inline at the end
of the email.)

The property name should be ASCII, but the value could be UTF8.  The
CellRender is used in a buddy list, and with the possibility of names that
are UTF8.

This could be one of two things --- an invalid property name in the  
attribute setup for your treeview, or memory corruption.

Have you been able to reproduce the crash with a subset of your  
code?  At this point, code will be the most helpful thing you can  
provide.

#!/usr/bin/perl -w

# This was taken from a posting on the gtk2-perl mailing list by
# Florian Schaefer <listbox netego de> and patched with the fixes
# subsequently posted by muppet <scott asofyet org>.
# Great stuff!
#
# I probably added a load of bugs when I modified it to use stock icons.

package Gtk2::CellRendererPixText;

use strict;
use warnings;
use Glib qw(G_PARAM_READWRITE);
use Gtk2;
use Glib::Object::Subclass
    "Gtk2::CellRenderer",
    properties => [
                   Glib::ParamSpec->string ('stock_id',
                                            'Text',
                                            'The stock image to display',
                                            "", G_PARAM_READWRITE),
                   Glib::ParamSpec->string ('text',
                                            'Text',
                                            'The text string to display',
                                            "", G_PARAM_READWRITE),
                   ],
    ;


sub INIT_INSTANCE {
  my $self = shift;
}

sub setup_text {
  my ($self, $widget) = @_;
  my $layout = $widget->create_pango_layout ($self->{'text'});
  return ($layout->get_pixel_size, $layout);
}

sub GET_SIZE {
  my ($cell, $widget, $cell_area) = @_;
  my ($x_offset, $y_offset) = (0, 0);

  my ($width, $height) = $cell->setup_text($widget);

  my $stock_id = $cell->{stock_id};
  if ($stock_id) {
    my $pixbuf = $cell->{pixbuf} = $widget->render_icon($stock_id, 'menu');
    my $pw = $pixbuf->get_width;
    my $ph = $pixbuf->get_height;
    $width += $pw;
    $height = $ph if $ph > $height;
  } else {
    delete $cell->{pixbuf};
  }

  return ($x_offset, $y_offset, $width, $height);
}

sub RENDER {
  my ($cell, $window, $widget, $background_area,
      $cell_area, $expose_area, $flags) = @_;

  my $pw = 0;
  my $stock_id = $cell->{stock_id};
  if ($stock_id) {
    my $pixbuf = $cell->{pixbuf} = $widget->render_icon($stock_id, 'menu');
    $pw = $pixbuf->get_width;
    my $ph = $pixbuf->get_height;

    $window->draw_pixbuf(
                         $widget->get_style->fg_gc($widget->state),
                         $pixbuf,
                         0,
                         0,
                         $cell_area->x(),
                         $cell_area->y() + int(($cell_area->height -
                                                $ph)/2),
                         $pw, $ph,
                         "GDK_RGB_DITHER_NONE", 0, 0
                         );
  }

  my ($width, $height, $layout) = $cell->setup_text ($widget);

  $widget->get_style->paint_layout($window,
                                   "normal",
                                   1,
                                   $cell_area,
                                   $widget,
                                   "cellrenderertext",
                                   $cell_area->x + $pw + 1,
                                   $cell_area->y + ($cell_area->height -
                                                    $height) / 2,
                                   $layout
                                   );
}

1;


        -Sean

-- 
__________________________________________________________________

Sean Dague                                       Mid-Hudson Valley
sean at dague dot net                            Linux Users Group
http://dague.net                                 http://mhvlug.org

There is no silver bullet.  Plus, werewolves make better neighbors
than zombies, and they tend to keep the vampire population down.
__________________________________________________________________

Attachment: pgpZ2erEMJRO9.pgp
Description: PGP signature



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