From 669ef44f4f9ee32336b34eaa3b31869ce8a5bfc7 Mon Sep 17 00:00:00 2001
From: lvgenggeng <lvgenggeng@uniontech.com>
Date: Wed, 11 Dec 2024 19:44:05 +0800
Subject: [PATCH 1/1] fix coredump in clearChildLayout function

Signed-off-by: lvgenggeng <lvgenggeng@uniontech.com>
---
 .../private/cattributemanagerwgt.cpp              | 15 +++++----------
 1 file changed, 5 insertions(+), 10 deletions(-)

diff --git a/src/frame/AttributesWidgets/private/cattributemanagerwgt.cpp b/src/frame/AttributesWidgets/private/cattributemanagerwgt.cpp
index e706984..0adaab5 100644
--- a/src/frame/AttributesWidgets/private/cattributemanagerwgt.cpp
+++ b/src/frame/AttributesWidgets/private/cattributemanagerwgt.cpp
@@ -161,18 +161,13 @@ Qt::Alignment CExpWgt::widgetAlignInWindow(const QWidget *w)
 
 void CExpWgt::clearChildLayout()
 {
-    for (int i = 0; i < _pCenterLay->count();) {
-        auto item = _pCenterLay->itemAt(i);
-
-        if (item->layout() != nullptr) {
-            delete item->layout();
-        } else if (item->widget() != nullptr) {
-            if (qobject_cast<CSpline *>(item->widget()) != nullptr) {
-                item->widget()->deleteLater();
-            }
+    while (_pCenterLay->count() > 0) {
+        QLayoutItem *pItem = _pCenterLay->takeAt(0);
+        if (nullptr != pItem) {
+            delete pItem;
         }
-        _pCenterLay->takeAt(i);
     }
+
     foreach (auto p, _splines) {
         p->deleteLater();
     }
-- 
2.20.1

