From 298db2ef76e6ea8a8f9b251b100e66c602db45fa Mon Sep 17 00:00:00 2001 From: unelsson Date: Thu, 12 Aug 2021 22:31:37 +0300 Subject: [PATCH] Initialize and check pointer. --- apps/opencs/model/world/commanddispatcher.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/apps/opencs/model/world/commanddispatcher.cpp b/apps/opencs/model/world/commanddispatcher.cpp index f753ec2e31..13e66fd5cd 100644 --- a/apps/opencs/model/world/commanddispatcher.cpp +++ b/apps/opencs/model/world/commanddispatcher.cpp @@ -150,7 +150,7 @@ void CSMWorld::CommandDispatcher::executeModify (QAbstractItemModel *sourceModel std::unique_ptr modifyData; std::unique_ptr modifyCell; - QAbstractItemModel *model; + QAbstractItemModel *model(nullptr); QModelIndex index; if (QAbstractProxyModel *proxy = dynamic_cast (sourceModel)) @@ -160,6 +160,8 @@ void CSMWorld::CommandDispatcher::executeModify (QAbstractItemModel *sourceModel model = proxy->sourceModel(); } + if (!model) return; + int columnId = model->data (index, ColumnBase::Role_ColumnId).toInt(); int stateColumn = dynamic_cast(*model).findColumnIndex(Columns::ColumnId_Modification);