Commit 42061e8c authored by Tim Jenssen's avatar Tim Jenssen
Browse files

ProjectExplorer: fix possible crashes



Change-Id: I0b06e31f07ddf9c052f360bb66ac2330cc21d7b6
Reviewed-by: default avatarhjk <hjk@qt.io>
parent a2c6e284
......@@ -192,6 +192,7 @@ bool FlatModel::setData(const QModelIndex &index, const QVariant &value, int rol
return false;
Node *node = nodeForIndex(index);
QTC_ASSERT(node, return false);
Utils::FileName orgFilePath = node->filePath();
Utils::FileName newFilePath = orgFilePath.parentDir().appendPath(value.toString());
......@@ -328,10 +329,11 @@ QMimeData *FlatModel::mimeData(const QModelIndexList &indexes) const
{
auto data = new Utils::DropMimeData;
foreach (const QModelIndex &index, indexes) {
Node *node = nodeForIndex(index);
if (node->asFileNode())
data->addFile(node->filePath().toString());
data->addValue(QVariant::fromValue(node));
if (Node *node = nodeForIndex(index)) {
if (node->asFileNode())
data->addFile(node->filePath().toString());
data->addValue(QVariant::fromValue(node));
}
}
return data;
}
......
......@@ -407,7 +407,7 @@ void ProjectTreeWidget::showContextMenu(const QPoint &pos)
void ProjectTreeWidget::openItem(const QModelIndex &mainIndex)
{
Node *node = m_model->nodeForIndex(mainIndex);
if (node->nodeType() != NodeType::File)
if (!node || node->nodeType() != NodeType::File)
return;
IEditor *editor = EditorManager::openEditor(node->filePath().toString());
if (editor && node->line() >= 0)
......
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