Handle warnings in allocation-changed callback
-
16-06-2021 - |
Pregunta
I've got a Clutter warning I can't get the rid of.
In my project, I've a custom layout, built by several ClutterConstraint(s), which handles a couple of ClutterBox(es).
One ClutterBox of these contains many ClutterTexture(s), placed within with an handmade layout.
In order to obtain that (handmade layout) I've used g_signal_connect
to hook up the "allocation-changed" notify, and inside his callback I wrote all the placing logic.
The warning that appears in runtime is "Clutter-WARNING **: The actor 'ClutterBox' is currently inside an allocation cycle; calling clutter_actor_queue_relayout() is not recommended"
.
Someone can suggests me how to avoid this warning?
Solución
you cannot change the allocation of a child during the allocation of its parent through the allocation-changed signal - i.e. you cannot change size or position of a child during the allocation of the parent outside of the allocate() virtual function.
if you want to implement a layout management policy for a container, you have to subclass the container and override its allocate() virtual function; alternatively, you should implement a ClutterLayoutManager, and assign it to the actor.
ClutterBox has also been deprecated in Clutter 1.10: ClutterActor now provides the entire API and support for delegates necessary for implementing layout management policies.