forked from qt-creator/qt-creator
QmlDesigner: Prevent possible nullptr access
Change-Id: I90f131526f97fa879cf9e6428547e6e8ed9aa936 Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
This commit is contained in:
committed by
Tim Jenssen
parent
b31c408c87
commit
c163240611
@@ -430,9 +430,10 @@ void DocumentManager::findPathToIsoProFile(bool *iconResourceFileAlreadyExists,
|
|||||||
bool DocumentManager::isoProFileSupportsAddingExistingFiles(const QString &resourceFileProPath)
|
bool DocumentManager::isoProFileSupportsAddingExistingFiles(const QString &resourceFileProPath)
|
||||||
{
|
{
|
||||||
ProjectExplorer::Node *node = ProjectExplorer::SessionManager::nodeForFile(Utils::FileName::fromString(resourceFileProPath));
|
ProjectExplorer::Node *node = ProjectExplorer::SessionManager::nodeForFile(Utils::FileName::fromString(resourceFileProPath));
|
||||||
ProjectExplorer::ProjectNode *projectNode = dynamic_cast<ProjectExplorer::ProjectNode*>(node->parentFolderNode());
|
if (!node || !node->parentFolderNode())
|
||||||
|
return false;
|
||||||
if (!projectNode->supportedActions(projectNode).contains(ProjectExplorer::AddExistingFile)) {
|
ProjectExplorer::ProjectNode *projectNode = node->parentFolderNode()->asProjectNode();
|
||||||
|
if (!projectNode || !projectNode->supportedActions(projectNode).contains(ProjectExplorer::AddExistingFile)) {
|
||||||
qCWarning(documentManagerLog) << "Project" << projectNode->displayName() << "does not support adding existing files";
|
qCWarning(documentManagerLog) << "Project" << projectNode->displayName() << "does not support adding existing files";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -443,7 +444,11 @@ bool DocumentManager::isoProFileSupportsAddingExistingFiles(const QString &resou
|
|||||||
bool DocumentManager::addResourceFileToIsoProject(const QString &resourceFileProPath, const QString &resourceFilePath)
|
bool DocumentManager::addResourceFileToIsoProject(const QString &resourceFileProPath, const QString &resourceFilePath)
|
||||||
{
|
{
|
||||||
ProjectExplorer::Node *node = ProjectExplorer::SessionManager::nodeForFile(Utils::FileName::fromString(resourceFileProPath));
|
ProjectExplorer::Node *node = ProjectExplorer::SessionManager::nodeForFile(Utils::FileName::fromString(resourceFileProPath));
|
||||||
ProjectExplorer::ProjectNode *projectNode = dynamic_cast<ProjectExplorer::ProjectNode*>(node->parentFolderNode());
|
if (!node || !node->parentFolderNode())
|
||||||
|
return false;
|
||||||
|
ProjectExplorer::ProjectNode *projectNode = node->parentFolderNode()->asProjectNode();
|
||||||
|
if (!projectNode)
|
||||||
|
return false;
|
||||||
|
|
||||||
if (!projectNode->addFiles(QStringList() << resourceFilePath)) {
|
if (!projectNode->addFiles(QStringList() << resourceFilePath)) {
|
||||||
qCWarning(documentManagerLog) << "Failed to add resource file to" << projectNode->displayName();
|
qCWarning(documentManagerLog) << "Failed to add resource file to" << projectNode->displayName();
|
||||||
|
|||||||
Reference in New Issue
Block a user