Debian Codegraph @

Source/Core/DolphinQt/QtUtils/ClearLayoutRecursively.cpp

raw symbols SCIP
1 // Copyright 2023 Dolphin Emulator Project
2 // SPDX-License-Identifier: GPL-2.0-or-later
3
4 #include "DolphinQt/QtUtils/ClearLayoutRecursively.h"
5
6 #include <QLayout>
7 #include <QLayoutItem>
8 #include <QWidget>
9
10 void ClearLayoutRecursively(QLayout* layout)
11 {
12 while (QLayoutItem* child = layout->takeAt(0))
13 {
14 if (child == nullptr)
15 continue;
16
17 if (child->widget())
18 {
19 layout->removeWidget(child->widget());
20 child->widget()->deleteLater();
21 }
22 else if (child->layout())
23 {
24 ClearLayoutRecursively(child->layout());
25 layout->removeItem(child);
26 }
27 else
28 {
29 layout->removeItem(child);
30 }
31 delete child;
32 }
33 }