Re: Bug in pixbuf->copy ?



Torsten Schoenfeld <kaffeetisch gmx de> writes:

    use strict; #!!!

    sub insert_image {
       my ($textbuffer, $file) = @_;
       my $pixbuf = Gtk2::Pixbuf->new_from_file($file) if -f $file and -r _;
       $pixbuf ||= Gtk2::Image->new->render_icon('gtk-missing-image', 
'dialog')->copy;
      
       # ...
    }

This is actually an undocumented and not future-proof way of getting
static variables.  The "glitches" that make it work are described in
[1].  There was also an entry about this on of the p5p digests, but the
original site[2] doesn't seem to have it anymore -- probably to not
further publicize the trick.  Anyway, the Google cache[3] still has it.

well, until state variables are availlable (perl-5.9.x ???), that's
the only way to have static variables, that do be usefull in some
cases.



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