Fix element reshape caching
This commit is contained in:
parent
512e9b51b7
commit
98ab4ee39d
1 changed files with 12 additions and 14 deletions
|
|
@ -9,13 +9,8 @@ namespace psemek::ui
|
|||
|
||||
void element::set_parent(element * parent)
|
||||
{
|
||||
if (parent && reshape_posted_)
|
||||
{
|
||||
parent->root()->reshape_posted_ = true;
|
||||
reshape_posted_ = false;
|
||||
}
|
||||
else if (!parent && parent_)
|
||||
reshape_posted_ |= parent_->root()->reshape_posted_;
|
||||
if (!parent_ && parent && reshape_posted_)
|
||||
parent->post_reshape();
|
||||
|
||||
parent_ = parent;
|
||||
if (loop())
|
||||
|
|
@ -138,16 +133,19 @@ namespace psemek::ui
|
|||
|
||||
void element::post_reshape()
|
||||
{
|
||||
if (root()->reshape_posted_)
|
||||
auto r = root();
|
||||
|
||||
if (r->reshape_posted_)
|
||||
return;
|
||||
|
||||
root()->reshape_posted_ = true;
|
||||
auto weak_self = weak_from_this();
|
||||
post([weak_self]{
|
||||
if (auto self = weak_self.lock())
|
||||
r->reshape_posted_ = true;
|
||||
auto weak_root = r->weak_from_this();
|
||||
post([weak_root]{
|
||||
if (auto root = weak_root.lock())
|
||||
{
|
||||
self->root()->reshape();
|
||||
self->root()->reshape_posted_ = false;
|
||||
root->reshape_posted_ = false;
|
||||
if (!root->parent())
|
||||
root->reshape();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue