diff options
author | crupest <crupest@outlook.com> | 2022-03-10 19:07:28 +0800 |
---|---|---|
committer | crupest <crupest@outlook.com> | 2022-03-10 19:07:28 +0800 |
commit | a9558215aef3b0ad67dc73788305e1b46bc872b5 (patch) | |
tree | f35839c8f47c372e2a9bb248c113bc4ea334c827 | |
parent | d790505c3c0c829b6831ae8db2fd4e75d018e2c1 (diff) | |
download | cru-a9558215aef3b0ad67dc73788305e1b46bc872b5.tar.gz cru-a9558215aef3b0ad67dc73788305e1b46bc872b5.tar.bz2 cru-a9558215aef3b0ad67dc73788305e1b46bc872b5.zip |
...
-rw-r--r-- | include/cru/ui/controls/LayoutControl.h | 2 | ||||
-rw-r--r-- | include/cru/ui/controls/SingleChildControl.h | 2 | ||||
-rw-r--r-- | src/ui/host/WindowHost.cpp | 9 |
3 files changed, 7 insertions, 6 deletions
diff --git a/include/cru/ui/controls/LayoutControl.h b/include/cru/ui/controls/LayoutControl.h index 2ea6ef67..78cc4806 100644 --- a/include/cru/ui/controls/LayoutControl.h +++ b/include/cru/ui/controls/LayoutControl.h @@ -14,7 +14,7 @@ class LayoutControl : public Control { LayoutControl(LayoutControl&& other) = delete; LayoutControl& operator=(const LayoutControl& other) = delete; LayoutControl& operator=(LayoutControl&& other) = delete; - ~LayoutControl() override = default; + ~LayoutControl() override { ClearChildren(); } public: const std::vector<Control*>& GetChildren() const { return children_; } diff --git a/include/cru/ui/controls/SingleChildControl.h b/include/cru/ui/controls/SingleChildControl.h index e733c825..b2e58c5f 100644 --- a/include/cru/ui/controls/SingleChildControl.h +++ b/include/cru/ui/controls/SingleChildControl.h @@ -13,7 +13,7 @@ class SingleChildControl : public Control { CRU_DELETE_COPY(SingleChildControl) CRU_DELETE_MOVE(SingleChildControl) - ~SingleChildControl() override {} + ~SingleChildControl() override { SetChild(nullptr); } Control* GetChild() const { return child_; } void SetChild(Control* child) { diff --git a/src/ui/host/WindowHost.cpp b/src/ui/host/WindowHost.cpp index 42d0945f..f4a9a928 100644 --- a/src/ui/host/WindowHost.cpp +++ b/src/ui/host/WindowHost.cpp @@ -150,10 +150,12 @@ std::unique_ptr<platform::gui::INativeWindow> WindowHost::CreateNativeWindow() { return std::unique_ptr<INativeWindow>(native_window); } -void WindowHost::InvalidatePaint() { layout_paint_cycler_->InvalidatePaint(); } +void WindowHost::InvalidatePaint() { + if (layout_paint_cycler_) layout_paint_cycler_->InvalidatePaint(); +} void WindowHost::InvalidateLayout() { - layout_paint_cycler_->InvalidateLayout(); + if (layout_paint_cycler_) layout_paint_cycler_->InvalidateLayout(); } bool WindowHost::IsLayoutPreferToFillWindow() const { @@ -190,8 +192,7 @@ void WindowHost::RelayoutWithSize(const Size& available_size, for (auto& action : after_layout_stable_action_) action(); after_layout_event_.Raise(AfterLayoutEventArgs{}); after_layout_stable_action_.clear(); - if constexpr (debug_flags::layout) - CRU_LOG_DEBUG(u"A relayout is finished."); + if constexpr (debug_flags::layout) CRU_LOG_DEBUG(u"A relayout is finished."); } void WindowHost::Repaint() { |