Commit 2044c834 authored by Tobias Hunger's avatar Tobias Hunger Committed by Tim Jenssen

Modeling: Fix potential nullptr access

Change-Id: I9b8fa7de10e7fbe089c9bdde6d9f42c427ca8f82
Reviewed-by: Tim Jenssen's avatarTim Jenssen <tim.jenssen@qt.io>
parent 2ce647f8
......@@ -307,13 +307,7 @@ void TreeModel::ItemUpdater::updateRelationLabel(const MRelation *relation)
m_item->setText(label);
}
TreeModel::TreeModel(QObject *parent)
: QStandardItemModel(parent),
m_modelController(0),
m_stereotypeController(0),
m_styleController(0),
m_rootItem(0),
m_busyState(NotBusy)
TreeModel::TreeModel(QObject *parent) : QStandardItemModel(parent)
{
connect(this, &QAbstractItemModel::dataChanged,
this, &TreeModel::onModelDataChanged);
......@@ -481,8 +475,8 @@ void TreeModel::onEndResetModel()
{
QMT_CHECK(m_busyState == ResetModel);
clear();
MPackage *rootPackage = m_modelController->rootPackage();
if (m_modelController && rootPackage) {
MPackage *rootPackage = m_modelController ? m_modelController->rootPackage() : nullptr;
if (rootPackage) {
m_rootItem = createItem(rootPackage);
appendRow(m_rootItem);
createChildren(rootPackage, m_rootItem);
......
......@@ -134,13 +134,13 @@ private:
MoveRelation
};
ModelController *m_modelController;
StereotypeController *m_stereotypeController;
StyleController *m_styleController;
ModelItem *m_rootItem;
ModelController *m_modelController = nullptr;
StereotypeController *m_stereotypeController = nullptr;
StyleController *m_styleController = nullptr;
ModelItem *m_rootItem = nullptr;
QHash<const MObject *, ModelItem *> m_objectToItemMap;
QHash<ModelItem *, const MObject *> m_itemToObjectMap;
Busy m_busyState;
Busy m_busyState = NotBusy;
};
} // namespace qmt
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment