From 2004f8043aedfa8a0e3d73d1a32790a1e1f2561d Mon Sep 17 00:00:00 2001 From: lisyarus Date: Sat, 19 Feb 2022 16:36:17 +0300 Subject: [PATCH] Don't post ui reshape if one if already posted --- libs/ui/include/psemek/ui/element.hpp | 1 + libs/ui/source/element.cpp | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/libs/ui/include/psemek/ui/element.hpp b/libs/ui/include/psemek/ui/element.hpp index ee057f66..f5ea9058 100644 --- a/libs/ui/include/psemek/ui/element.hpp +++ b/libs/ui/include/psemek/ui/element.hpp @@ -81,6 +81,7 @@ namespace psemek::ui std::shared_ptr own_style_; mutable std::shared_ptr merged_style_; mutable std::shared_ptr merged_own_style_; + bool reshape_posted_ = false; mutable std::vector> delayed_callbacks_; diff --git a/libs/ui/source/element.cpp b/libs/ui/source/element.cpp index 620b186a..db66204f 100644 --- a/libs/ui/source/element.cpp +++ b/libs/ui/source/element.cpp @@ -130,10 +130,17 @@ namespace psemek::ui void element::post_reshape() { + if (root()->reshape_posted_) + return; + + root()->reshape_posted_ = true; auto weak_self = weak_from_this(); post([weak_self]{ if (auto self = weak_self.lock()) + { self->root()->reshape(); + self->root()->reshape_posted_ = false; + } }); }