RemoteLinux: Fix possible race condition.

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>
This commit is contained in:
Christian Kandeler
2011-05-30 16:47:27 +02:00
parent d627a3ebb1
commit e0f79761f3
3 changed files with 12 additions and 13 deletions

View File

@@ -57,9 +57,10 @@ using namespace Qt4ProjectManager;
namespace RemoteLinux { namespace RemoteLinux {
namespace Internal { namespace Internal {
MaemoDeployableListModel::MaemoDeployableListModel(const Qt4ProFileNode *proFileNode, MaemoDeployableListModel::MaemoDeployableListModel(const Qt4BaseTarget *target,
ProFileUpdateSetting updateSetting, QObject *parent) const Qt4ProFileNode *proFileNode, ProFileUpdateSetting updateSetting, QObject *parent)
: QAbstractTableModel(parent), : QAbstractTableModel(parent),
m_target(target),
m_projectType(proFileNode->projectType()), m_projectType(proFileNode->projectType()),
m_proFilePath(proFileNode->path()), m_proFilePath(proFileNode->path()),
m_projectName(proFileNode->displayName()), m_projectName(proFileNode->displayName()),
@@ -330,14 +331,7 @@ bool MaemoDeployableListModel::addLinesToProFile(const QStringList &lines)
const QtSupport::BaseQtVersion *MaemoDeployableListModel::qtVersion() const const QtSupport::BaseQtVersion *MaemoDeployableListModel::qtVersion() const
{ {
const ProjectExplorer::Project *const activeProject const Qt4BuildConfiguration *const bc = m_target->activeBuildConfiguration();
= 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();
QTC_ASSERT(bc, return 0); QTC_ASSERT(bc, return 0);
return bc->qtVersion(); return bc->qtVersion();
} }

View File

@@ -46,6 +46,9 @@
namespace QtSupport { namespace QtSupport {
class BaseQtVersion; class BaseQtVersion;
} }
namespace Qt4ProjectManager {
class Qt4BaseTarget;
}
namespace RemoteLinux { namespace RemoteLinux {
namespace Internal { namespace Internal {
@@ -58,8 +61,9 @@ public:
UpdateProFile, DontUpdateProFile, AskToUpdateProFile UpdateProFile, DontUpdateProFile, AskToUpdateProFile
}; };
MaemoDeployableListModel(const Qt4ProjectManager::Qt4ProFileNode *proFileNode, MaemoDeployableListModel(const Qt4ProjectManager::Qt4BaseTarget *target,
ProFileUpdateSetting updateSetting, QObject *parent); const Qt4ProjectManager::Qt4ProFileNode *proFileNode, ProFileUpdateSetting updateSetting,
QObject *parent);
~MaemoDeployableListModel(); ~MaemoDeployableListModel();
virtual int rowCount(const QModelIndex &parent = QModelIndex()) const; virtual int rowCount(const QModelIndex &parent = QModelIndex()) const;
@@ -107,6 +111,7 @@ private:
QString remoteIconDir() const; QString remoteIconDir() const;
QStringList localLibraryFilePaths() const; QStringList localLibraryFilePaths() const;
const Qt4ProjectManager::Qt4BaseTarget * const m_target;
const Qt4ProjectManager::Qt4ProjectType m_projectType; const Qt4ProjectManager::Qt4ProjectType m_projectType;
const QString m_proFilePath; const QString m_proFilePath;
const QString m_projectName; const QString m_projectName;

View File

@@ -129,7 +129,7 @@ void MaemoDeployables::createModels(const Qt4ProFileNode *proFileNode)
? it.value() : MaemoDeployableListModel::AskToUpdateProFile; ? it.value() : MaemoDeployableListModel::AskToUpdateProFile;
} }
MaemoDeployableListModel *const newModel MaemoDeployableListModel *const newModel
= new MaemoDeployableListModel(proFileNode, updateSetting, this); = new MaemoDeployableListModel(m_target, proFileNode, updateSetting, this);
m_listModels << newModel; m_listModels << newModel;
break; break;
} }