diff options
author | Tobias Hunger <tobias.hunger@qt.io> | 2017-05-09 12:19:13 +0200 |
---|---|---|
committer | Tobias Hunger <tobias.hunger@qt.io> | 2017-05-12 10:33:15 +0000 |
commit | 18537a5594a3bc6d999b6876a187acee9cfa7789 (patch) | |
tree | ae5e6baa4abd4c1340d335b1a08a869eb999533f /src/plugins/resourceeditor | |
parent | f603a115d022e50667d0f2e66c7900dec48eeaf2 (diff) |
ProjectNodes: Sprinkle QTC_ASSERT over code looking at parentFolderNode
Not checking the parentFolderNode triggered a crash elsewhere already, so
double check other uses of parentFolderNode and use QTC_ASSERT to make sure
no nullptr is going to be accessed.
This is necessary now that we have a forest of project trees and no longer
have a sessionnode anymore.
Change-Id: Ibc380c2ec9b12b983e709d2eeb03a8b741fe1058
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
Diffstat (limited to 'src/plugins/resourceeditor')
-rw-r--r-- | src/plugins/resourceeditor/resourceeditorplugin.cpp | 1 | ||||
-rw-r--r-- | src/plugins/resourceeditor/resourcenode.cpp | 5 |
2 files changed, 4 insertions, 2 deletions
diff --git a/src/plugins/resourceeditor/resourceeditorplugin.cpp b/src/plugins/resourceeditor/resourceeditorplugin.cpp index 42a59226b7..75cce17542 100644 --- a/src/plugins/resourceeditor/resourceeditorplugin.cpp +++ b/src/plugins/resourceeditor/resourceeditorplugin.cpp @@ -287,6 +287,7 @@ void ResourceEditorPlugin::removeFileContextMenu() QTC_ASSERT(rfn, return); QString path = rfn->filePath().toString(); FolderNode *parent = rfn->parentFolderNode(); + QTC_ASSERT(parent, return); if (!parent->removeFiles(QStringList() << path)) QMessageBox::warning(Core::ICore::mainWindow(), tr("File Removal Failed"), diff --git a/src/plugins/resourceeditor/resourcenode.cpp b/src/plugins/resourceeditor/resourcenode.cpp index b8fbcc10cb..20f67b2eec 100644 --- a/src/plugins/resourceeditor/resourcenode.cpp +++ b/src/plugins/resourceeditor/resourcenode.cpp @@ -70,8 +70,9 @@ public: { if (type == TypePermissions) return true; - auto newNode = new ResourceTopLevelNode(m_node->filePath(), false, m_node->contents(), - m_node->parentFolderNode()); + FolderNode *parent = m_node->parentFolderNode(); + QTC_ASSERT(parent, return false); + auto newNode = new ResourceTopLevelNode(m_node->filePath(), false, m_node->contents(), parent); m_node->parentFolderNode()->replaceSubtree(m_node, newNode); return true; } |