forked from qt-creator/qt-creator
ProjectExplorer: fix possible crashes
Change-Id: I0b06e31f07ddf9c052f360bb66ac2330cc21d7b6 Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
@@ -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)
|
||||
|
Reference in New Issue
Block a user