diff --git a/limereport/scripteditor/lrcompletermodel.cpp b/limereport/scripteditor/lrcompletermodel.cpp index 29c7116..70299f6 100644 --- a/limereport/scripteditor/lrcompletermodel.cpp +++ b/limereport/scripteditor/lrcompletermodel.cpp @@ -22,16 +22,17 @@ QModelIndex CompleterModel::index(int row, int column, const QModelIndex &parent return createIndex(row, column, parentItem->child(row)); } -QModelIndex CompleterModel::parent(const QModelIndex &child) const -{ - if (child.isValid()){ - CompleterItem *childItem = static_cast(child.internalPointer()); - CompleterItem *parentItem = childItem->parent(); - if (parentItem != &m_root) { - return indexFromItem(parentItem); - } +QModelIndex CompleterModel::parent(const QModelIndex &child) const { + if(child.isValid()) { + if(CompleterItem *childItem = static_cast(child.internalPointer()); + childItem) { + CompleterItem *parentItem = childItem->parent(); + if(parentItem != &m_root) { + return indexFromItem(parentItem); + } } - return QModelIndex(); + } + return QModelIndex(); } int CompleterModel::rowCount(const QModelIndex &parent) const diff --git a/limereport/scripteditor/lrcompletermodel.h b/limereport/scripteditor/lrcompletermodel.h index eeab147..9611e5d 100644 --- a/limereport/scripteditor/lrcompletermodel.h +++ b/limereport/scripteditor/lrcompletermodel.h @@ -35,7 +35,7 @@ public: void appendRow(CompleterItem* child); void appendRows(const QList &children); private: - CompleterItem* m_parent; + CompleterItem* m_parent{nullptr}; QVector > m_children; QString m_text; QIcon m_icon;