Commit e79f6031 authored by Christian Kandeler's avatar Christian Kandeler

Maemo: Prepare for possibility of our deploy step disappearing.

Could happen e.g. when RDA is used.
parent d8d038da
......@@ -55,8 +55,8 @@
namespace Qt4ProjectManager {
namespace Internal {
MaemoDeployables::MaemoDeployables(const ProjectExplorer::BuildStep *buildStep)
: m_buildStep(buildStep), m_updateTimer(new QTimer(this))
MaemoDeployables::MaemoDeployables(const Qt4Target *target)
: m_target(target), m_updateTimer(new QTimer(this))
{
QTimer::singleShot(0, this, SLOT(init()));
m_updateTimer->setInterval(1500);
......@@ -67,7 +67,7 @@ MaemoDeployables::~MaemoDeployables() {}
void MaemoDeployables::init()
{
Qt4Project *pro = qt4BuildConfiguration()->qt4Target()->qt4Project();
Qt4Project * const pro = m_target->qt4Project();
connect(pro, SIGNAL(proFileUpdated(Qt4ProjectManager::Internal::Qt4ProFileNode*,bool)),
m_updateTimer, SLOT(start()));
......@@ -78,16 +78,14 @@ void MaemoDeployables::init()
void MaemoDeployables::createModels()
{
if (!qt4BuildConfiguration() || !qt4BuildConfiguration()->qt4Target()
|| qt4BuildConfiguration()->qt4Target()->project()->activeTarget()->id()
!= QLatin1String(Qt4ProjectManager::Constants::MAEMO_DEVICE_TARGET_ID))
if (m_target->project()->activeTarget() != m_target)
return;
const Qt4ProFileNode *const rootNode
= qt4BuildConfiguration()->qt4Target()->qt4Project()->rootProjectNode();
= m_target->qt4Project()->rootProjectNode();
if (!rootNode) // Happens on project creation by wizard.
return;
m_updateTimer->stop();
disconnect(qt4BuildConfiguration()->qt4Target()->qt4Project(),
disconnect(m_target->qt4Project(),
SIGNAL(proFileUpdated(Qt4ProjectManager::Internal::Qt4ProFileNode*,bool)),
m_updateTimer, SLOT(start()));
beginResetModel();
......@@ -119,7 +117,7 @@ void MaemoDeployables::createModels()
}
endResetModel();
connect(qt4BuildConfiguration()->qt4Target()->qt4Project(),
connect(m_target->qt4Project(),
SIGNAL(proFileUpdated(Qt4ProjectManager::Internal::Qt4ProFileNode*,bool)),
m_updateTimer, SLOT(start()));
}
......@@ -201,13 +199,6 @@ QString MaemoDeployables::remoteExecutableFilePath(const QString &localExecutabl
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
{
return parent.isValid() ? 0 : modelCount();
......
......@@ -51,10 +51,9 @@
QT_FORWARD_DECLARE_CLASS(QTimer)
namespace ProjectExplorer { class BuildStep; }
namespace Qt4ProjectManager {
class Qt4BuildConfiguration;
class Qt4Target;
namespace Internal {
class Qt4ProFileNode;
......@@ -63,7 +62,7 @@ class MaemoDeployables : public QAbstractListModel
{
Q_OBJECT
public:
MaemoDeployables(const ProjectExplorer::BuildStep *buildStep);
MaemoDeployables(const Qt4Target *target);
~MaemoDeployables();
void setUnmodified();
bool isModified() const;
......@@ -72,7 +71,6 @@ public:
QString remoteExecutableFilePath(const QString &localExecutableFilePath) const;
int modelCount() const { return m_listModels.count(); }
MaemoDeployableListModel *modelAt(int i) const { return m_listModels.at(i); }
const ProjectExplorer::BuildStep *buildStep() const { return m_buildStep; }
private:
typedef QHash<QString, MaemoDeployableListModel::ProFileUpdateSetting> UpdateSettingsMap;
......@@ -83,11 +81,10 @@ private:
Q_SLOT void createModels();
Q_SLOT void init();
void createModels(const Qt4ProFileNode *proFileNode);
const Qt4BuildConfiguration *qt4BuildConfiguration() const;
QList<MaemoDeployableListModel *> m_listModels;
UpdateSettingsMap m_updateSettings;
const ProjectExplorer::BuildStep * const m_buildStep;
const Qt4Target * const m_target;
QTimer *const m_updateTimer;
};
......
......@@ -52,6 +52,7 @@
#include <projectexplorer/target.h>
#include <qt4projectmanager/qt4buildconfiguration.h>
#include <qt4projectmanager/qt4target.h>
#include <QtCore/QCoreApplication>
#include <QtCore/QDir>
......@@ -96,7 +97,9 @@ void MaemoDeployStep::ctor()
const QList<DeployConfiguration *> &deployConfigs
= target()->deployConfigurations();
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 {
const MaemoDeployStep *const other
= MaemoGlobal::buildStep<MaemoDeployStep>(deployConfigs.first());
......
......@@ -97,6 +97,8 @@ public:
template<class T> static T *buildStep(const ProjectExplorer::DeployConfiguration *dc)
{
if (!dc)
return 0;
ProjectExplorer::BuildStepList *bsl = dc->stepList();
if (!bsl)
return 0;
......
......@@ -213,7 +213,8 @@ QString MaemoRunConfiguration::defaultDisplayName()
MaemoDeviceConfig MaemoRunConfiguration::deviceConfig() const
{
return deployStep()->deviceConfigModel()->current();
const MaemoDeployStep * const step = deployStep();
return step ? step->deviceConfigModel()->current() : MaemoDeviceConfig();
}
const MaemoToolChain *MaemoRunConfiguration::toolchain() const
......@@ -232,11 +233,7 @@ const QString MaemoRunConfiguration::gdbCmd() const
MaemoDeployStep *MaemoRunConfiguration::deployStep() const
{
MaemoDeployStep * const step
= MaemoGlobal::buildStep<MaemoDeployStep>(target()->activeDeployConfiguration());
Q_ASSERT_X(step, Q_FUNC_INFO,
"Impossible: Maemo build configuration without deploy step.");
return step;
return MaemoGlobal::buildStep<MaemoDeployStep>(target()->activeDeployConfiguration());
}
const QString MaemoRunConfiguration::sysRoot() const
......@@ -302,8 +299,10 @@ QString MaemoRunConfiguration::localExecutableFilePath() const
QString MaemoRunConfiguration::remoteExecutableFilePath() const
{
return deployStep()->deployables()
->remoteExecutableFilePath(localExecutableFilePath());
const MaemoDeployStep * const step = deployStep();
return step
? step->deployables()->remoteExecutableFilePath(localExecutableFilePath())
: QString();
}
MaemoPortList MaemoRunConfiguration::freePorts() const
......@@ -381,6 +380,7 @@ void MaemoRunConfiguration::handleDeployConfigChanged()
}
}
updateDeviceConfigurations();
updateFactoryState();
}
QString MaemoRunConfiguration::baseEnvironmentText() const
......
......@@ -79,7 +79,8 @@ MaemoRunConfigurationWidget::MaemoRunConfigurationWidget(
: QWidget(parent),
m_runConfiguration(runConfiguration),
m_ignoreChange(false),
m_deviceEnvReader(new MaemoDeviceEnvReader(this, runConfiguration))
m_deviceEnvReader(new MaemoDeviceEnvReader(this, runConfiguration)),
m_deployablesConnected(false)
{
m_lastActiveBuildConfig = m_runConfiguration->activeQt4BuildConfiguration();
QVBoxLayout *mainLayout = new QVBoxLayout;
......@@ -172,9 +173,10 @@ void MaemoRunConfigurationWidget::addGenericWidgets(QVBoxLayout *mainLayout)
SLOT(handleDebuggingTypeChanged()));
connect(m_runConfiguration, SIGNAL(targetInformationChanged()), this,
SLOT(updateTargetInformation()));
connect(m_runConfiguration->deployStep()->deployables().data(),
SIGNAL(modelReset()), this, SLOT(handleDeploySpecsChanged()));
handleDeploySpecsChanged();
connect(m_runConfiguration->target(),
SIGNAL(activeDeployConfigurationChanged(ProjectExplorer::DeployConfiguration*)),
SLOT(handleActiveDeployConfigurationChanged()));
handleActiveDeployConfigurationChanged();
}
void MaemoRunConfigurationWidget::addDebuggingWidgets(QVBoxLayout *mainLayout)
......@@ -302,6 +304,24 @@ void MaemoRunConfigurationWidget::updateTargetInformation()
->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()
{
m_remoteExecutableLabel->setText(m_runConfiguration->remoteExecutableFilePath());
......
......@@ -98,6 +98,7 @@ private slots:
void handleDeploySpecsChanged();
void handleBuildConfigChanged();
void handleToolchainChanged();
void handleActiveDeployConfigurationChanged();
private:
void addGenericWidgets(QVBoxLayout *mainLayout);
......@@ -127,6 +128,7 @@ private:
MaemoDeviceEnvReader *m_deviceEnvReader;
ProjectExplorer::EnvironmentWidget *m_environmentWidget;
Qt4BuildConfiguration *m_lastActiveBuildConfig;
bool m_deployablesConnected;
};
} // namespace Internal
......
......@@ -163,7 +163,8 @@ bool MaemoRunControlFactory::canRun(RunConfiguration *runConfiguration,
{
const MaemoRunConfiguration * const maemoRunConfig
= qobject_cast<MaemoRunConfiguration *>(runConfiguration);
if (!maemoRunConfig || !maemoRunConfig->deviceConfig().isValid()
if (!maemoRunConfig
|| !maemoRunConfig->deviceConfig().isValid()
|| !maemoRunConfig->toolchain()
|| maemoRunConfig->remoteExecutableFilePath().isEmpty())
return false;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment