0
0
mirror of https://github.com/fralx/LimeReport.git synced 2024-12-23 16:22:58 +03:00

Fix: lrcompletermodel access to null ptr

This commit is contained in:
Dmitry Zagorodnev 2023-02-20 14:29:32 +03:00
parent 56e145ecd8
commit de850125aa
2 changed files with 11 additions and 10 deletions

View File

@ -22,15 +22,16 @@ 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<CompleterItem*>(child.internalPointer());
QModelIndex CompleterModel::parent(const QModelIndex &child) const {
if(child.isValid()) {
if(CompleterItem *childItem = static_cast<CompleterItem *>(child.internalPointer());
childItem) {
CompleterItem *parentItem = childItem->parent();
if (parentItem != &m_root) {
if(parentItem != &m_root) {
return indexFromItem(parentItem);
}
}
}
return QModelIndex();
}

View File

@ -35,7 +35,7 @@ public:
void appendRow(CompleterItem* child);
void appendRows(const QList<CompleterItem *> &children);
private:
CompleterItem* m_parent;
CompleterItem* m_parent{nullptr};
QVector<QSharedPointer<CompleterItem> > m_children;
QString m_text;
QIcon m_icon;