From e2c1d2d0ef50c0da24b60fc94529891055cf8043 Mon Sep 17 00:00:00 2001 From: Sophia Hadash Date: Sun, 26 Sep 2021 22:59:14 +0200 Subject: [PATCH 1/2] fix segfault in badge destructor fix margins --- es-core/src/components/BadgesComponent.cpp | 3 +-- es-core/src/components/FlexboxComponent.cpp | 4 ++-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/es-core/src/components/BadgesComponent.cpp b/es-core/src/components/BadgesComponent.cpp index 8adff44a1..e2fd9bfe4 100644 --- a/es-core/src/components/BadgesComponent.cpp +++ b/es-core/src/components/BadgesComponent.cpp @@ -51,8 +51,7 @@ BadgesComponent::BadgesComponent(Window *window) } BadgesComponent::~BadgesComponent() { - mBadgeIcons.clear(); - mImageComponents.clear(); + mChildren.clear(); } diff --git a/es-core/src/components/FlexboxComponent.cpp b/es-core/src/components/FlexboxComponent.cpp index b29159188..6665b2883 100644 --- a/es-core/src/components/FlexboxComponent.cpp +++ b/es-core/src/components/FlexboxComponent.cpp @@ -121,12 +121,12 @@ void FlexboxComponent::computeLayout() float y = anchorY - anchorOriginY * size.y; // Apply item margin. - if ((mDirection == "row" && i % std::max(1, (int) mItemsPerLine) != 0) || + /*if ((mDirection == "row" && i % std::max(1, (int) mItemsPerLine) != 0) || (mDirection == "column" && i >= (int) mItemsPerLine)) x += mItemMargin.x * (directionLine.x >= 0.0f ? 1.0f : -1.0f); if ((mDirection == "column" && i % std::max(1, (int) mItemsPerLine) != 0) || (mDirection == "row" && i >= (int) mItemsPerLine)) - y += mItemMargin.y * (directionLine.y >= 0.0f ? 1.0f : -1.0f); + y += mItemMargin.y * (directionLine.y >= 0.0f ? 1.0f : -1.0f);*/ // Apply alignment if (mAlign == ITEM_ALIGN_END) { From 2b8c95d2efa35337cc11669f2ef0ff4be0c6f999 Mon Sep 17 00:00:00 2001 From: Sophia Hadash Date: Sun, 26 Sep 2021 23:04:09 +0200 Subject: [PATCH 2/2] fix segfault in badge destructor --- es-core/src/GuiComponent.h | 5 +++-- es-core/src/components/BadgesComponent.cpp | 2 ++ es-core/src/resources/TextureResource.h | 2 +- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/es-core/src/GuiComponent.h b/es-core/src/GuiComponent.h index 386b78ef0..2e7efd9a5 100644 --- a/es-core/src/GuiComponent.h +++ b/es-core/src/GuiComponent.h @@ -37,8 +37,9 @@ class Window; class GuiComponent { public: - GuiComponent(Window* window); - virtual ~GuiComponent(); + GuiComponent(Window *window); + + virtual ~GuiComponent() noexcept; virtual void textInput(const std::string& text); diff --git a/es-core/src/components/BadgesComponent.cpp b/es-core/src/components/BadgesComponent.cpp index e2fd9bfe4..1a5b5f341 100644 --- a/es-core/src/components/BadgesComponent.cpp +++ b/es-core/src/components/BadgesComponent.cpp @@ -52,6 +52,8 @@ BadgesComponent::BadgesComponent(Window *window) BadgesComponent::~BadgesComponent() { mChildren.clear(); + mBadgeIcons.clear(); + mImageComponents.clear(); } diff --git a/es-core/src/resources/TextureResource.h b/es-core/src/resources/TextureResource.h index 223d60fcc..bed111536 100644 --- a/es-core/src/resources/TextureResource.h +++ b/es-core/src/resources/TextureResource.h @@ -47,7 +47,7 @@ public: void rasterizeAt(size_t width, size_t height); glm::vec2 getSourceImageSize() const { return mSourceSize; } - virtual ~TextureResource(); + virtual ~TextureResource() noexcept; bool isInitialized() const { return true; } bool isTiled() const;