clutter/text: Don't query preferred size without allocation

The size request functions query the resource scale, which hits
an assert if headless. The returned sizes are already only used
when clutter_actor_has_allocation() is true, so this doesn't
change the condition for calling either redraw or relayout.

https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/4522

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1956>
This commit is contained in:
Florian Müllner 2021-08-04 19:30:10 +02:00
parent 287c715df6
commit 9252b7c6b4

View File

@ -4797,16 +4797,21 @@ static void
clutter_text_queue_redraw_or_relayout (ClutterText *self) clutter_text_queue_redraw_or_relayout (ClutterText *self)
{ {
ClutterActor *actor = CLUTTER_ACTOR (self); ClutterActor *actor = CLUTTER_ACTOR (self);
gfloat preferred_width; float preferred_width = -1.;
gfloat preferred_height; float preferred_height = -1.;
clutter_text_dirty_cache (self); clutter_text_dirty_cache (self);
if (clutter_actor_has_allocation (actor))
{
/* we're using our private implementations here to avoid the caching done by ClutterActor */ /* we're using our private implementations here to avoid the caching done by ClutterActor */
clutter_text_get_preferred_width (actor, -1, NULL, &preferred_width); clutter_text_get_preferred_width (actor, -1, NULL, &preferred_width);
clutter_text_get_preferred_height (actor, preferred_width, NULL, &preferred_height); clutter_text_get_preferred_height (actor, preferred_width, NULL,
&preferred_height);
}
if (clutter_actor_has_allocation (actor) && if (preferred_width > 0 &&
preferred_height > 0 &&
fabsf (preferred_width - clutter_actor_get_width (actor)) <= 0.001 && fabsf (preferred_width - clutter_actor_get_width (actor)) <= 0.001 &&
fabsf (preferred_height - clutter_actor_get_height (actor)) <= 0.001) fabsf (preferred_height - clutter_actor_get_height (actor)) <= 0.001)
clutter_text_queue_redraw (actor); clutter_text_queue_redraw (actor);