diff options
author | Tobias Hunger <tobias.hunger@qt.io> | 2017-08-29 14:32:10 +0200 |
---|---|---|
committer | Tobias Hunger <tobias.hunger@qt.io> | 2017-09-01 14:42:34 +0000 |
commit | 60b8712a4283be7dfdfe7d566c57a5ea85ff3be0 (patch) | |
tree | da563cc37f187dd21643a0a3f6be2e3b048f416c /src/plugins/projectexplorer/projectexplorer.cpp | |
parent | 1bcde48da917a8a34173088aa104ad669e14a17d (diff) |
Wizards: Do not crash when adding files to existing projectv4.4.0
Do not crash when adding a file to an existing project that finishes
parsing while the wizard is still open.
Make sure the Node that is passed into the wizard is still valid after
parsing. Provide more information to the wizard so that this can be
checked -- and to find the similar node in the new project tree.
Also avoid a crash when adding existing files.
Do not crash when project parsing finishes while the wizard
summary page is open.
Do not crash when the project gets closed while the summary page
is open.
Do not have the ProjectTree send signals about subTreeChanges if
the node that changed is not part of the ProjectTree. This avoids
an infinite loop when updating the combobox on the summary page.
Add a treeChanged signal to ProjectTree.
Task-number: QTCREATORBUG-18651
Change-Id: Iaed3d0d1f079c09e54389821a11bda596139f35c
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
Diffstat (limited to 'src/plugins/projectexplorer/projectexplorer.cpp')
-rw-r--r-- | src/plugins/projectexplorer/projectexplorer.cpp | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/src/plugins/projectexplorer/projectexplorer.cpp b/src/plugins/projectexplorer/projectexplorer.cpp index f47f2e0510..acd546e09b 100644 --- a/src/plugins/projectexplorer/projectexplorer.cpp +++ b/src/plugins/projectexplorer/projectexplorer.cpp @@ -3046,13 +3046,18 @@ void ProjectExplorerPluginPrivate::updateContextMenuActions() void ProjectExplorerPluginPrivate::addNewFile() { QTC_ASSERT(ProjectTree::currentNode(), return); - QString location = directoryFor(ProjectTree::currentNode()); + Node *currentNode = ProjectTree::currentNode(); + QString location = directoryFor(currentNode); QVariantMap map; - map.insert(QLatin1String(Constants::PREFERRED_PROJECT_NODE), QVariant::fromValue(ProjectTree::currentNode())); - if (ProjectTree::currentProject()) { - QList<Id> profileIds = Utils::transform(ProjectTree::currentProject()->targets(), &Target::id); + // store void pointer to avoid QVariant to use qobject_cast, which might core-dump when trying + // to access meta data on an object that get deleted in the meantime: + map.insert(QLatin1String(Constants::PREFERRED_PROJECT_NODE), QVariant::fromValue(static_cast<void *>(currentNode))); + map.insert(Constants::PREFERRED_PROJECT_NODE_PATH, currentNode->filePath().toString()); + if (Project *p = ProjectTree::currentProject()) { + QList<Id> profileIds = Utils::transform(p->targets(), &Target::id); map.insert(QLatin1String(Constants::PROJECT_KIT_IDS), QVariant::fromValue(profileIds)); + map.insert(Constants::PROJECT_POINTER, QVariant::fromValue(static_cast<void *>(p))); } ICore::showNewItemDialog(tr("New File", "Title of dialog"), Utils::filtered(IWizardFactory::allWizardFactories(), @@ -3121,7 +3126,8 @@ void ProjectExplorerPluginPrivate::addExistingDirectory() void ProjectExplorerPlugin::addExistingFiles(FolderNode *folderNode, const QStringList &filePaths) { - if (!folderNode) // can happen when project is not yet parsed + // can happen when project is not yet parsed or finished parsing while the dialog was open: + if (!folderNode || !ProjectTree::hasNode(folderNode)) return; const QString dir = directoryFor(folderNode); |