mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-01-25 23:06:10 -05:00
Merge pull request #1901 from PhenomRetroShare/Fix_ClearLayout
Fix Clear Layout methode.
This commit is contained in:
commit
477f0a8a76
@ -28,6 +28,7 @@
|
|||||||
#include <QFontDialog>
|
#include <QFontDialog>
|
||||||
|
|
||||||
#include "misc.h"
|
#include "misc.h"
|
||||||
|
#include "util/rsdebug.h"
|
||||||
|
|
||||||
// return best userfriendly storage unit (B, KiB, MiB, GiB, TiB)
|
// return best userfriendly storage unit (B, KiB, MiB, GiB, TiB)
|
||||||
// use Binary prefix standards from IEC 60027-2
|
// use Binary prefix standards from IEC 60027-2
|
||||||
@ -416,12 +417,17 @@ void misc::clearLayout(QLayout * layout) {
|
|||||||
|
|
||||||
while (auto item = layout->takeAt(0))
|
while (auto item = layout->takeAt(0))
|
||||||
{
|
{
|
||||||
if (auto *widget = item->widget())
|
//First get all pointers, else item may be deleted when last object removed and get SIGSEGV
|
||||||
|
auto *widget = item->widget();
|
||||||
|
auto *spacer = item->spacerItem();
|
||||||
|
//Then Clear Layout
|
||||||
|
clearLayout(item->layout());
|
||||||
|
//Last clear objects
|
||||||
|
if (widget)
|
||||||
widget->deleteLater();
|
widget->deleteLater();
|
||||||
if (auto *spacer = item->spacerItem())
|
if (spacer)
|
||||||
delete spacer;
|
delete spacer;
|
||||||
|
|
||||||
clearLayout(item->layout());
|
//delete item;//Auto deleted by Qt.
|
||||||
delete item;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user