From d83e0e74e60db920dfba8d9de746fb161101d578 Mon Sep 17 00:00:00 2001
From: dt <qtc-committer@nokia.com>
Date: Thu, 12 Mar 2009 15:01:01 +0100
Subject: [PATCH] Fixes:    Crash on importing a project

Task:     Reported on irc by roberto
Details:  Initialize the rootProjectNode after the qt4Project is in a
more useable state. Could be that this is now initialized too late. But
that's to be seen.
---
 src/plugins/qt4projectmanager/qt4project.cpp | 20 +++++++++++---------
 1 file changed, 11 insertions(+), 9 deletions(-)

diff --git a/src/plugins/qt4projectmanager/qt4project.cpp b/src/plugins/qt4projectmanager/qt4project.cpp
index 1557bb46127..3549df23a6e 100644
--- a/src/plugins/qt4projectmanager/qt4project.cpp
+++ b/src/plugins/qt4projectmanager/qt4project.cpp
@@ -229,20 +229,13 @@ void Qt4ProjectFile::modified(Core::IFile::ReloadBehavior *)
 Qt4Project::Qt4Project(Qt4Manager *manager, const QString& fileName) :
     m_toolChain(0),
     m_manager(manager),
-    m_rootProjectNode(new Qt4ProFileNode(this, fileName, this)),
+    m_rootProjectNode(0),
     m_nodesWatcher(new Internal::Qt4NodesWatcher(this)),
     m_fileInfo(new Qt4ProjectFile(this, fileName, this)),
     m_isApplication(true),
     m_projectFiles(new Qt4ProjectFiles)
 {
     m_manager->registerProject(this);
-    m_rootProjectNode->registerWatcher(m_nodesWatcher);
-    connect(m_nodesWatcher, SIGNAL(foldersAdded()), this, SLOT(updateFileList()));
-    connect(m_nodesWatcher, SIGNAL(foldersRemoved()), this, SLOT(updateFileList()));
-    connect(m_nodesWatcher, SIGNAL(filesAdded()), this, SLOT(updateFileList()));
-    connect(m_nodesWatcher, SIGNAL(filesRemoved()), this, SLOT(updateFileList()));
-    connect(m_nodesWatcher, SIGNAL(proFileUpdated(Qt4ProjectManager::Internal::Qt4ProFileNode *)),
-            this, SLOT(scheduleUpdateCodeModel()));
 
     connect(qt4ProjectManager()->versionManager(), SIGNAL(defaultQtVersionChanged()),
             this, SLOT(defaultQtVersionChanged()));
@@ -305,6 +298,15 @@ void Qt4Project::restoreSettingsImpl(PersistentSettingsReader &settingsReader)
     foreach (const QString &bc, buildConfigurations())
         qtVersionId(bc);
 
+    m_rootProjectNode = new Qt4ProFileNode(this, m_fileInfo->fileName(), this);
+    m_rootProjectNode->registerWatcher(m_nodesWatcher);
+    connect(m_nodesWatcher, SIGNAL(foldersAdded()), this, SLOT(updateFileList()));
+    connect(m_nodesWatcher, SIGNAL(foldersRemoved()), this, SLOT(updateFileList()));
+    connect(m_nodesWatcher, SIGNAL(filesAdded()), this, SLOT(updateFileList()));
+    connect(m_nodesWatcher, SIGNAL(filesRemoved()), this, SLOT(updateFileList()));
+    connect(m_nodesWatcher, SIGNAL(proFileUpdated(Qt4ProjectManager::Internal::Qt4ProFileNode *)),
+            this, SLOT(scheduleUpdateCodeModel()));
+
     update();
 
     // restored old runconfigurations
@@ -685,7 +687,7 @@ void Qt4Project::addDefaultBuild()
                 insertBuildStep(0, gdbmacrostep);
 
                 GdbMacrosBuildStep *gdbmacrosCleanStep = new GdbMacrosBuildStep(this);
-                gdbmacrosCleanStep ->setValue("clean", true);
+                gdbmacrosCleanStep->setValue("clean", true);
                 insertCleanStep(0, gdbmacrosCleanStep );
                 break;
             }
-- 
GitLab