mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-21 05:09:34 -06:00
DolphinQt: Move GraphicsModListWidget::ClearLayoutRecursively() to QtUtils.
This commit is contained in:
33
Source/Core/DolphinQt/QtUtils/ClearLayoutRecursively.cpp
Normal file
33
Source/Core/DolphinQt/QtUtils/ClearLayoutRecursively.cpp
Normal file
@ -0,0 +1,33 @@
|
||||
// Copyright 2023 Dolphin Emulator Project
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
#include "DolphinQt/QtUtils/ClearLayoutRecursively.h"
|
||||
|
||||
#include <QLayout>
|
||||
#include <QLayoutItem>
|
||||
#include <QWidget>
|
||||
|
||||
void ClearLayoutRecursively(QLayout* layout)
|
||||
{
|
||||
while (QLayoutItem* child = layout->takeAt(0))
|
||||
{
|
||||
if (child == nullptr)
|
||||
continue;
|
||||
|
||||
if (child->widget())
|
||||
{
|
||||
layout->removeWidget(child->widget());
|
||||
delete child->widget();
|
||||
}
|
||||
else if (child->layout())
|
||||
{
|
||||
ClearLayoutRecursively(child->layout());
|
||||
layout->removeItem(child);
|
||||
}
|
||||
else
|
||||
{
|
||||
layout->removeItem(child);
|
||||
}
|
||||
delete child;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user