mirror of
https://github.com/YGGverse/Yoda.git
synced 2026-03-31 16:45:27 +00:00
use label widget as contain destroy method to free memory on width rule iteration
This commit is contained in:
parent
1ef9c91b64
commit
5b3f0c2497
1 changed files with 9 additions and 6 deletions
|
|
@ -4,8 +4,7 @@ declare(strict_types=1);
|
|||
|
||||
namespace Yggverse\Yoda\Abstract\Model\Gtk\Pango;
|
||||
|
||||
use \PangoLayout;
|
||||
use \GtkDrawingArea;
|
||||
use \GtkLabel;
|
||||
|
||||
class Markup implements \Yggverse\Yoda\Interface\Model\Gtk\Pango\Markup
|
||||
{
|
||||
|
|
@ -143,16 +142,20 @@ class Markup implements \Yggverse\Yoda\Interface\Model\Gtk\Pango\Markup
|
|||
string $markup
|
||||
): ?int
|
||||
{
|
||||
$layout = new PangoLayout( // @TODO cleanup
|
||||
(new GtkDrawingArea)->create_pango_context()
|
||||
$label = new GtkLabel;
|
||||
|
||||
$label->set_use_markup(
|
||||
true
|
||||
);
|
||||
|
||||
$layout->set_markup(
|
||||
$label->set_markup(
|
||||
$markup, -1
|
||||
);
|
||||
|
||||
if ($size = $layout->get_pixel_size())
|
||||
if ($size = $label->get_layout()->get_pixel_size())
|
||||
{
|
||||
$label->destroy();
|
||||
|
||||
return $size['width'];
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue