Fix crash when adding file to sub folder in generic project

The moment the file is added to the project, a reparse is triggered,
which invalidates the tree sub-nodes.
So we need to check if the context node (on which the wizard was opened)
still exists before trying to access it, similar to how we do that in
JsonSummaryPage::findWizardContextNode.

Change-Id: I9154e000a31ea8d5d4ebc66c25528d422c377b94
Fixes: QTCREATORBUG-21342
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
This commit is contained in:
Eike Ziller
2018-10-18 11:33:18 +02:00
parent e06c8672ac
commit 5bc38589d8

View File

@@ -31,6 +31,7 @@
#include "../project.h"
#include "../projectexplorer.h"
#include "../projectexplorerconstants.h"
#include "../projecttree.h"
#include <coreplugin/editormanager/editormanager.h>
#include <coreplugin/messagemanager.h>
@@ -290,7 +291,7 @@ void JsonWizard::accept()
openFiles(m_files);
auto node = static_cast<ProjectExplorer::Node*>(value(ProjectExplorer::Constants::PREFERRED_PROJECT_NODE).value<void*>());
if (node) // PREFERRED_PROJECT_NODE is not set for newly created projects
if (node && ProjectTree::hasNode(node)) // PREFERRED_PROJECT_NODE is not set for newly created projects
openProjectForNode(node);
}