Maemo: Prepare for possibility of our deploy step disappearing.

Could happen e.g. when RDA is used.
This commit is contained in:
Christian Kandeler
2011-01-11 16:08:51 +01:00
parent d8d038daf4
commit e79f6031da
8 changed files with 52 additions and 36 deletions

View File

@@ -55,8 +55,8 @@
namespace Qt4ProjectManager { namespace Qt4ProjectManager {
namespace Internal { namespace Internal {
MaemoDeployables::MaemoDeployables(const ProjectExplorer::BuildStep *buildStep) MaemoDeployables::MaemoDeployables(const Qt4Target *target)
: m_buildStep(buildStep), m_updateTimer(new QTimer(this)) : m_target(target), m_updateTimer(new QTimer(this))
{ {
QTimer::singleShot(0, this, SLOT(init())); QTimer::singleShot(0, this, SLOT(init()));
m_updateTimer->setInterval(1500); m_updateTimer->setInterval(1500);
@@ -67,7 +67,7 @@ MaemoDeployables::~MaemoDeployables() {}
void MaemoDeployables::init() void MaemoDeployables::init()
{ {
Qt4Project *pro = qt4BuildConfiguration()->qt4Target()->qt4Project(); Qt4Project * const pro = m_target->qt4Project();
connect(pro, SIGNAL(proFileUpdated(Qt4ProjectManager::Internal::Qt4ProFileNode*,bool)), connect(pro, SIGNAL(proFileUpdated(Qt4ProjectManager::Internal::Qt4ProFileNode*,bool)),
m_updateTimer, SLOT(start())); m_updateTimer, SLOT(start()));
@@ -78,16 +78,14 @@ void MaemoDeployables::init()
void MaemoDeployables::createModels() void MaemoDeployables::createModels()
{ {
if (!qt4BuildConfiguration() || !qt4BuildConfiguration()->qt4Target() if (m_target->project()->activeTarget() != m_target)
|| qt4BuildConfiguration()->qt4Target()->project()->activeTarget()->id()
!= QLatin1String(Qt4ProjectManager::Constants::MAEMO_DEVICE_TARGET_ID))
return; return;
const Qt4ProFileNode *const rootNode const Qt4ProFileNode *const rootNode
= qt4BuildConfiguration()->qt4Target()->qt4Project()->rootProjectNode(); = m_target->qt4Project()->rootProjectNode();
if (!rootNode) // Happens on project creation by wizard. if (!rootNode) // Happens on project creation by wizard.
return; return;
m_updateTimer->stop(); m_updateTimer->stop();
disconnect(qt4BuildConfiguration()->qt4Target()->qt4Project(), disconnect(m_target->qt4Project(),
SIGNAL(proFileUpdated(Qt4ProjectManager::Internal::Qt4ProFileNode*,bool)), SIGNAL(proFileUpdated(Qt4ProjectManager::Internal::Qt4ProFileNode*,bool)),
m_updateTimer, SLOT(start())); m_updateTimer, SLOT(start()));
beginResetModel(); beginResetModel();
@@ -119,7 +117,7 @@ void MaemoDeployables::createModels()
} }
endResetModel(); endResetModel();
connect(qt4BuildConfiguration()->qt4Target()->qt4Project(), connect(m_target->qt4Project(),
SIGNAL(proFileUpdated(Qt4ProjectManager::Internal::Qt4ProFileNode*,bool)), SIGNAL(proFileUpdated(Qt4ProjectManager::Internal::Qt4ProFileNode*,bool)),
m_updateTimer, SLOT(start())); m_updateTimer, SLOT(start()));
} }
@@ -201,13 +199,6 @@ QString MaemoDeployables::remoteExecutableFilePath(const QString &localExecutabl
return QString(); return QString();
} }
const Qt4BuildConfiguration *MaemoDeployables::qt4BuildConfiguration() const
{
const Qt4BuildConfiguration * const bc
= qobject_cast<Qt4BuildConfiguration *>(m_buildStep->target()->activeBuildConfiguration());
return bc;
}
int MaemoDeployables::rowCount(const QModelIndex &parent) const int MaemoDeployables::rowCount(const QModelIndex &parent) const
{ {
return parent.isValid() ? 0 : modelCount(); return parent.isValid() ? 0 : modelCount();

View File

@@ -51,10 +51,9 @@
QT_FORWARD_DECLARE_CLASS(QTimer) QT_FORWARD_DECLARE_CLASS(QTimer)
namespace ProjectExplorer { class BuildStep; }
namespace Qt4ProjectManager { namespace Qt4ProjectManager {
class Qt4BuildConfiguration; class Qt4BuildConfiguration;
class Qt4Target;
namespace Internal { namespace Internal {
class Qt4ProFileNode; class Qt4ProFileNode;
@@ -63,7 +62,7 @@ class MaemoDeployables : public QAbstractListModel
{ {
Q_OBJECT Q_OBJECT
public: public:
MaemoDeployables(const ProjectExplorer::BuildStep *buildStep); MaemoDeployables(const Qt4Target *target);
~MaemoDeployables(); ~MaemoDeployables();
void setUnmodified(); void setUnmodified();
bool isModified() const; bool isModified() const;
@@ -72,7 +71,6 @@ public:
QString remoteExecutableFilePath(const QString &localExecutableFilePath) const; QString remoteExecutableFilePath(const QString &localExecutableFilePath) const;
int modelCount() const { return m_listModels.count(); } int modelCount() const { return m_listModels.count(); }
MaemoDeployableListModel *modelAt(int i) const { return m_listModels.at(i); } MaemoDeployableListModel *modelAt(int i) const { return m_listModels.at(i); }
const ProjectExplorer::BuildStep *buildStep() const { return m_buildStep; }
private: private:
typedef QHash<QString, MaemoDeployableListModel::ProFileUpdateSetting> UpdateSettingsMap; typedef QHash<QString, MaemoDeployableListModel::ProFileUpdateSetting> UpdateSettingsMap;
@@ -83,11 +81,10 @@ private:
Q_SLOT void createModels(); Q_SLOT void createModels();
Q_SLOT void init(); Q_SLOT void init();
void createModels(const Qt4ProFileNode *proFileNode); void createModels(const Qt4ProFileNode *proFileNode);
const Qt4BuildConfiguration *qt4BuildConfiguration() const;
QList<MaemoDeployableListModel *> m_listModels; QList<MaemoDeployableListModel *> m_listModels;
UpdateSettingsMap m_updateSettings; UpdateSettingsMap m_updateSettings;
const ProjectExplorer::BuildStep * const m_buildStep; const Qt4Target * const m_target;
QTimer *const m_updateTimer; QTimer *const m_updateTimer;
}; };

View File

@@ -52,6 +52,7 @@
#include <projectexplorer/target.h> #include <projectexplorer/target.h>
#include <qt4projectmanager/qt4buildconfiguration.h> #include <qt4projectmanager/qt4buildconfiguration.h>
#include <qt4projectmanager/qt4target.h>
#include <QtCore/QCoreApplication> #include <QtCore/QCoreApplication>
#include <QtCore/QDir> #include <QtCore/QDir>
@@ -96,7 +97,9 @@ void MaemoDeployStep::ctor()
const QList<DeployConfiguration *> &deployConfigs const QList<DeployConfiguration *> &deployConfigs
= target()->deployConfigurations(); = target()->deployConfigurations();
if (deployConfigs.isEmpty()) { if (deployConfigs.isEmpty()) {
m_deployables = QSharedPointer<MaemoDeployables>(new MaemoDeployables(this)); const Qt4Target * const qt4Target = qobject_cast<Qt4Target *>(target());
Q_ASSERT(qt4Target);
m_deployables = QSharedPointer<MaemoDeployables>(new MaemoDeployables(qt4Target));
} else { } else {
const MaemoDeployStep *const other const MaemoDeployStep *const other
= MaemoGlobal::buildStep<MaemoDeployStep>(deployConfigs.first()); = MaemoGlobal::buildStep<MaemoDeployStep>(deployConfigs.first());

View File

@@ -97,6 +97,8 @@ public:
template<class T> static T *buildStep(const ProjectExplorer::DeployConfiguration *dc) template<class T> static T *buildStep(const ProjectExplorer::DeployConfiguration *dc)
{ {
if (!dc)
return 0;
ProjectExplorer::BuildStepList *bsl = dc->stepList(); ProjectExplorer::BuildStepList *bsl = dc->stepList();
if (!bsl) if (!bsl)
return 0; return 0;

View File

@@ -213,7 +213,8 @@ QString MaemoRunConfiguration::defaultDisplayName()
MaemoDeviceConfig MaemoRunConfiguration::deviceConfig() const MaemoDeviceConfig MaemoRunConfiguration::deviceConfig() const
{ {
return deployStep()->deviceConfigModel()->current(); const MaemoDeployStep * const step = deployStep();
return step ? step->deviceConfigModel()->current() : MaemoDeviceConfig();
} }
const MaemoToolChain *MaemoRunConfiguration::toolchain() const const MaemoToolChain *MaemoRunConfiguration::toolchain() const
@@ -232,11 +233,7 @@ const QString MaemoRunConfiguration::gdbCmd() const
MaemoDeployStep *MaemoRunConfiguration::deployStep() const MaemoDeployStep *MaemoRunConfiguration::deployStep() const
{ {
MaemoDeployStep * const step return MaemoGlobal::buildStep<MaemoDeployStep>(target()->activeDeployConfiguration());
= MaemoGlobal::buildStep<MaemoDeployStep>(target()->activeDeployConfiguration());
Q_ASSERT_X(step, Q_FUNC_INFO,
"Impossible: Maemo build configuration without deploy step.");
return step;
} }
const QString MaemoRunConfiguration::sysRoot() const const QString MaemoRunConfiguration::sysRoot() const
@@ -302,8 +299,10 @@ QString MaemoRunConfiguration::localExecutableFilePath() const
QString MaemoRunConfiguration::remoteExecutableFilePath() const QString MaemoRunConfiguration::remoteExecutableFilePath() const
{ {
return deployStep()->deployables() const MaemoDeployStep * const step = deployStep();
->remoteExecutableFilePath(localExecutableFilePath()); return step
? step->deployables()->remoteExecutableFilePath(localExecutableFilePath())
: QString();
} }
MaemoPortList MaemoRunConfiguration::freePorts() const MaemoPortList MaemoRunConfiguration::freePorts() const
@@ -381,6 +380,7 @@ void MaemoRunConfiguration::handleDeployConfigChanged()
} }
} }
updateDeviceConfigurations(); updateDeviceConfigurations();
updateFactoryState();
} }
QString MaemoRunConfiguration::baseEnvironmentText() const QString MaemoRunConfiguration::baseEnvironmentText() const

View File

@@ -79,7 +79,8 @@ MaemoRunConfigurationWidget::MaemoRunConfigurationWidget(
: QWidget(parent), : QWidget(parent),
m_runConfiguration(runConfiguration), m_runConfiguration(runConfiguration),
m_ignoreChange(false), m_ignoreChange(false),
m_deviceEnvReader(new MaemoDeviceEnvReader(this, runConfiguration)) m_deviceEnvReader(new MaemoDeviceEnvReader(this, runConfiguration)),
m_deployablesConnected(false)
{ {
m_lastActiveBuildConfig = m_runConfiguration->activeQt4BuildConfiguration(); m_lastActiveBuildConfig = m_runConfiguration->activeQt4BuildConfiguration();
QVBoxLayout *mainLayout = new QVBoxLayout; QVBoxLayout *mainLayout = new QVBoxLayout;
@@ -172,9 +173,10 @@ void MaemoRunConfigurationWidget::addGenericWidgets(QVBoxLayout *mainLayout)
SLOT(handleDebuggingTypeChanged())); SLOT(handleDebuggingTypeChanged()));
connect(m_runConfiguration, SIGNAL(targetInformationChanged()), this, connect(m_runConfiguration, SIGNAL(targetInformationChanged()), this,
SLOT(updateTargetInformation())); SLOT(updateTargetInformation()));
connect(m_runConfiguration->deployStep()->deployables().data(), connect(m_runConfiguration->target(),
SIGNAL(modelReset()), this, SLOT(handleDeploySpecsChanged())); SIGNAL(activeDeployConfigurationChanged(ProjectExplorer::DeployConfiguration*)),
handleDeploySpecsChanged(); SLOT(handleActiveDeployConfigurationChanged()));
handleActiveDeployConfigurationChanged();
} }
void MaemoRunConfigurationWidget::addDebuggingWidgets(QVBoxLayout *mainLayout) void MaemoRunConfigurationWidget::addDebuggingWidgets(QVBoxLayout *mainLayout)
@@ -302,6 +304,24 @@ void MaemoRunConfigurationWidget::updateTargetInformation()
->setText(QDir::toNativeSeparators(m_runConfiguration->localExecutableFilePath())); ->setText(QDir::toNativeSeparators(m_runConfiguration->localExecutableFilePath()));
} }
void MaemoRunConfigurationWidget::handleActiveDeployConfigurationChanged()
{
if (m_deployablesConnected)
return;
MaemoDeployStep * const deployStep = m_runConfiguration->deployStep();
if (!deployStep)
return;
connect(deployStep->deployables().data(), SIGNAL(modelReset()),
SLOT(handleDeploySpecsChanged()));
handleDeploySpecsChanged();
m_deployablesConnected = true;
disconnect(m_runConfiguration->target(),
SIGNAL(activeDeployConfigurationChanged(ProjectExplorer::DeployConfiguration*)),
this,
SLOT(handleActiveDeployConfigurationChanged()));
}
void MaemoRunConfigurationWidget::handleDeploySpecsChanged() void MaemoRunConfigurationWidget::handleDeploySpecsChanged()
{ {
m_remoteExecutableLabel->setText(m_runConfiguration->remoteExecutableFilePath()); m_remoteExecutableLabel->setText(m_runConfiguration->remoteExecutableFilePath());

View File

@@ -98,6 +98,7 @@ private slots:
void handleDeploySpecsChanged(); void handleDeploySpecsChanged();
void handleBuildConfigChanged(); void handleBuildConfigChanged();
void handleToolchainChanged(); void handleToolchainChanged();
void handleActiveDeployConfigurationChanged();
private: private:
void addGenericWidgets(QVBoxLayout *mainLayout); void addGenericWidgets(QVBoxLayout *mainLayout);
@@ -127,6 +128,7 @@ private:
MaemoDeviceEnvReader *m_deviceEnvReader; MaemoDeviceEnvReader *m_deviceEnvReader;
ProjectExplorer::EnvironmentWidget *m_environmentWidget; ProjectExplorer::EnvironmentWidget *m_environmentWidget;
Qt4BuildConfiguration *m_lastActiveBuildConfig; Qt4BuildConfiguration *m_lastActiveBuildConfig;
bool m_deployablesConnected;
}; };
} // namespace Internal } // namespace Internal

View File

@@ -163,7 +163,8 @@ bool MaemoRunControlFactory::canRun(RunConfiguration *runConfiguration,
{ {
const MaemoRunConfiguration * const maemoRunConfig const MaemoRunConfiguration * const maemoRunConfig
= qobject_cast<MaemoRunConfiguration *>(runConfiguration); = qobject_cast<MaemoRunConfiguration *>(runConfiguration);
if (!maemoRunConfig || !maemoRunConfig->deviceConfig().isValid() if (!maemoRunConfig
|| !maemoRunConfig->deviceConfig().isValid()
|| !maemoRunConfig->toolchain() || !maemoRunConfig->toolchain()
|| maemoRunConfig->remoteExecutableFilePath().isEmpty()) || maemoRunConfig->remoteExecutableFilePath().isEmpty())
return false; return false;