mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-01-24 14:23:36 -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 "misc.h"
|
||||
#include "util/rsdebug.h"
|
||||
|
||||
// return best userfriendly storage unit (B, KiB, MiB, GiB, TiB)
|
||||
// use Binary prefix standards from IEC 60027-2
|
||||
@ -416,12 +417,17 @@ void misc::clearLayout(QLayout * layout) {
|
||||
|
||||
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();
|
||||
if (auto *spacer = item->spacerItem())
|
||||
if (spacer)
|
||||
delete spacer;
|
||||
|
||||
clearLayout(item->layout());
|
||||
delete item;
|
||||
//delete item;//Auto deleted by Qt.
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user