OSDN Git Service

RemoteLinux: Fix possible race condition.
authorChristian Kandeler <christian.kandeler@nokia.com>
Mon, 30 May 2011 14:47:27 +0000 (16:47 +0200)
committerChristian Kandeler <christian.kandeler@nokia.com>
Mon, 30 May 2011 15:38:04 +0000 (17:38 +0200)
When opening a new project, the deployables code can
apparently be run before an active project is set.

Task-number: https://projects.maemo.org/bugzilla/show_bug.cgi?id=251230
Change-Id: Ia8e3067823ee45553364b0e7a867563d008332cd
Reviewed-on: http://codereview.qt.nokia.com/243
Reviewed-by: Daniel Teske <daniel.teske@nokia.com>
src/plugins/remotelinux/maemodeployablelistmodel.cpp
src/plugins/remotelinux/maemodeployablelistmodel.h
src/plugins/remotelinux/maemodeployables.cpp

index b92e128..01e0de3 100644 (file)
@@ -57,9 +57,10 @@ using namespace Qt4ProjectManager;
 namespace RemoteLinux {
 namespace Internal {
 
-MaemoDeployableListModel::MaemoDeployableListModel(const Qt4ProFileNode *proFileNode,
-    ProFileUpdateSetting updateSetting, QObject *parent)
+MaemoDeployableListModel::MaemoDeployableListModel(const Qt4BaseTarget *target,
+    const Qt4ProFileNode *proFileNode, ProFileUpdateSetting updateSetting, QObject *parent)
     : QAbstractTableModel(parent),
+      m_target(target),
       m_projectType(proFileNode->projectType()),
       m_proFilePath(proFileNode->path()),
       m_projectName(proFileNode->displayName()),
@@ -330,14 +331,7 @@ bool MaemoDeployableListModel::addLinesToProFile(const QStringList &lines)
 
 const QtSupport::BaseQtVersion *MaemoDeployableListModel::qtVersion() const
 {
-    const ProjectExplorer::Project *const activeProject
-        = ProjectExplorer::ProjectExplorerPlugin::instance()->session()->startupProject();
-    QTC_ASSERT(activeProject, return 0);
-    const Qt4BaseTarget *const activeTarget
-        = qobject_cast<Qt4BaseTarget *>(activeProject->activeTarget());
-    QTC_ASSERT(activeTarget, return 0);
-    const Qt4BuildConfiguration *const bc
-        = activeTarget->activeBuildConfiguration();
+    const Qt4BuildConfiguration *const bc = m_target->activeBuildConfiguration();
     QTC_ASSERT(bc, return 0);
     return bc->qtVersion();
 }
index c302d8e..a53d4a2 100644 (file)
@@ -46,6 +46,9 @@
 namespace QtSupport {
 class BaseQtVersion;
 }
+namespace Qt4ProjectManager {
+class Qt4BaseTarget;
+}
 
 namespace RemoteLinux {
 namespace Internal {
@@ -58,8 +61,9 @@ public:
         UpdateProFile, DontUpdateProFile, AskToUpdateProFile
     };
 
-    MaemoDeployableListModel(const Qt4ProjectManager::Qt4ProFileNode *proFileNode,
-        ProFileUpdateSetting updateSetting, QObject *parent);
+    MaemoDeployableListModel(const Qt4ProjectManager::Qt4BaseTarget *target,
+        const Qt4ProjectManager::Qt4ProFileNode *proFileNode, ProFileUpdateSetting updateSetting,
+        QObject *parent);
     ~MaemoDeployableListModel();
 
     virtual int rowCount(const QModelIndex &parent = QModelIndex()) const;
@@ -107,6 +111,7 @@ private:
     QString remoteIconDir() const;
     QStringList localLibraryFilePaths() const;
 
+    const Qt4ProjectManager::Qt4BaseTarget * const m_target;
     const Qt4ProjectManager::Qt4ProjectType m_projectType;
     const QString m_proFilePath;
     const QString m_projectName;
index 83be56a..9ff3edc 100644 (file)
@@ -129,7 +129,7 @@ void MaemoDeployables::createModels(const Qt4ProFileNode *proFileNode)
                 ? it.value() : MaemoDeployableListModel::AskToUpdateProFile;
         }
         MaemoDeployableListModel *const newModel
-            = new MaemoDeployableListModel(proFileNode, updateSetting, this);
+            = new MaemoDeployableListModel(m_target, proFileNode, updateSetting, this);
         m_listModels << newModel;
         break;
     }