Re: [PHP-GTK-DEV] Undefined method: PangoFontDescription::free()

[email protected] (Elizabeth M Smith) Thu, 30 Jul 2009 15:17:34 -0400
Newsgroups php.gtk.dev
Message-ID <[email protected]>
Jon Dunlap wrote:
> Hello:
> 
> I am using PHP-Gtk2 to develop software to control a motorsports scoreboard. 
> I have the most recent versions of every piece of the puzzle (php-gtk2, GTK+
> bundle) and am running on WinXP 32-bit.
> 
> Upon attempting to use the command $pfd -> free() on a PangoFontDescription
> named $pfd, I encounter the error
> 
> [17-Jul-2009 10:51:10] PHP Fatal error:  Call to undefined method
> PangoFontDescription::free() in D:\Documents and Settings ... on line 58
> 
> This command appears in all PHP-Gtk2 references. 

The docs are incorrect - it is not needed in PHP-GTK and does not exist

Why does it remain
> "undefined" to my compiler?  The static pango_font_descriptions_free() is
> also undefined, and I cannot ref() or unref() my PangoLayouts, either, even
> though they are GObjects.

PHP takes care of all refing, unrefing and freeing for you, you don't
need any memory management calls with PHP-GTK (and they don't exist at
the user level in PHP-GTK)

> The need for these commands stems from an object I have defined, "Textbox",
> which takes as input a width/height array, some text, a font family, and a
> desired maximum font size.  It creates a PangoFontDescription and a
> PangoLayout and then resets the size of the PangoFontDescription downward
> until the PangoLayout fits inside the width and height specified.  The size
> is checked via PangoLayout -> get_pixel_size.  My program crashes after
> several hundred resizings; when the resizing is omitted, my program can
> create tens of thousands of Textboxes without incident.  I surmise that it
> is the font-resize---modify layout---get_pixel_size cycle that is causing
> the crash.

Are you sure?  crashes are often hard to figure out - but I would
suspect a memory problem if you're doing something that memory
intensive.  If you're worried about the memory try unsetting each object
after you're through with it, this will cause PHP-GTK to call free on
the fontdescription.

If you have a small (20 line or less please) reproducing case, feel free
to file a bug, but often in trying to get the reproduce case you'll find
your problem is elsewhere ;)

> Does anyone have an idea for a more efficient/less memory-intensive
> algorithm?  Is there a PHP-Gtk2 command I'm missing?  
> 
> Thanks for any assistance you can provide.
> 
> Jon

Thanks,
Elizabeth Smith