diff --git a/src/libcalamaresui/utils/qjsonitem.cpp b/src/libcalamaresui/utils/qjsonitem.cpp index 24494f0fd..cdc4b3b13 100644 --- a/src/libcalamaresui/utils/qjsonitem.cpp +++ b/src/libcalamaresui/utils/qjsonitem.cpp @@ -26,11 +26,9 @@ #include "qjsonitem.h" QJsonTreeItem::QJsonTreeItem(QJsonTreeItem *parent) + : mParent( parent ) + , mType( QJsonValue::Type::Null ) { - - mParent = parent; - - } QJsonTreeItem::~QJsonTreeItem() diff --git a/src/libcalamaresui/utils/qjsonmodel.cpp b/src/libcalamaresui/utils/qjsonmodel.cpp index 5ce0cd695..4238bfd6b 100644 --- a/src/libcalamaresui/utils/qjsonmodel.cpp +++ b/src/libcalamaresui/utils/qjsonmodel.cpp @@ -33,14 +33,19 @@ QJsonModel::QJsonModel(QObject *parent) : QAbstractItemModel(parent) + , mRootItem( new QJsonTreeItem ) { - mRootItem = new QJsonTreeItem; mHeaders.append("key"); mHeaders.append("value"); } +QJsonModel::~QJsonModel() +{ + delete mRootItem; +} + bool QJsonModel::load(const QString &fileName) { QFile file(fileName); @@ -66,6 +71,7 @@ bool QJsonModel::loadJson(const QByteArray &json) if (!mDocument.isNull()) { beginResetModel(); + delete mRootItem; if (mDocument.isArray()) { mRootItem = QJsonTreeItem::load(QJsonValue(mDocument.array())); } else {