forked from qt-creator/qt-creator
Maemo: Fix possible crash due to removed project file node.
We must not save a Qt4ProFileNode in our MaemoDeployableListModel, since it might no longer exist when we use it again. Reviewed-by: kh1
This commit is contained in:
@@ -31,8 +31,6 @@
|
||||
|
||||
#include "maemoprofilewrapper.h"
|
||||
|
||||
#include <qt4projectmanager/qt4nodes.h>
|
||||
|
||||
#include <QtCore/QCryptographicHash>
|
||||
#include <QtCore/QFile>
|
||||
#include <QtCore/QFileInfo>
|
||||
@@ -44,11 +42,15 @@ MaemoDeployableListModel::MaemoDeployableListModel(const Qt4ProFileNode *proFile
|
||||
const QSharedPointer<ProFileOption> &proFileOption,
|
||||
ProFileUpdateSetting updateSetting, QObject *parent)
|
||||
: QAbstractTableModel(parent),
|
||||
m_proFileNode(proFileNode),
|
||||
m_projectType(proFileNode->projectType()),
|
||||
m_proFilePath(proFileNode->path()),
|
||||
m_projectName(proFileNode->displayName()),
|
||||
m_targetInfo(proFileNode->targetInformation()),
|
||||
m_modified(false),
|
||||
m_proFileWrapper(new MaemoProFileWrapper(m_proFileNode->path(),
|
||||
m_proFileNode->buildDir(), proFileOption)),
|
||||
m_proFileUpdateSetting(updateSetting), m_hasTargetPath(false)
|
||||
m_proFileWrapper(new MaemoProFileWrapper(m_proFilePath,
|
||||
proFileNode->buildDir(), proFileOption)),
|
||||
m_proFileUpdateSetting(updateSetting),
|
||||
m_hasTargetPath(false)
|
||||
{
|
||||
buildModel();
|
||||
}
|
||||
@@ -63,7 +65,7 @@ bool MaemoDeployableListModel::buildModel()
|
||||
m_hasTargetPath = !installs.targetPath.isEmpty();
|
||||
if (!m_hasTargetPath && m_proFileUpdateSetting == UpdateProFile) {
|
||||
const QString remoteDirSuffix
|
||||
= QLatin1String(m_proFileNode->projectType() == LibraryTemplate
|
||||
= QLatin1String(m_projectType == LibraryTemplate
|
||||
? "/lib" : "/bin");
|
||||
const QString remoteDirMaemo5
|
||||
= QLatin1String("/opt/usr") + remoteDirSuffix;
|
||||
@@ -71,7 +73,7 @@ bool MaemoDeployableListModel::buildModel()
|
||||
= QLatin1String("/usr/local") + remoteDirSuffix;
|
||||
m_deployables.prepend(MaemoDeployable(localExecutableFilePath(),
|
||||
remoteDirMaemo5));
|
||||
QFile projectFile(m_proFileNode->path());
|
||||
QFile projectFile(m_proFilePath);
|
||||
if (!projectFile.open(QIODevice::WriteOnly | QIODevice::Append)) {
|
||||
qWarning("Error updating .pro file.");
|
||||
return false;
|
||||
@@ -203,11 +205,10 @@ QVariant MaemoDeployableListModel::headerData(int section,
|
||||
|
||||
QString MaemoDeployableListModel::localExecutableFilePath() const
|
||||
{
|
||||
const TargetInformation &ti = m_proFileNode->targetInformation();
|
||||
if (!ti.valid)
|
||||
if (!m_targetInfo.valid)
|
||||
return QString();
|
||||
|
||||
const bool isLib = m_proFileNode->projectType() == LibraryTemplate;
|
||||
const bool isLib = m_projectType == LibraryTemplate;
|
||||
bool isStatic = false; // Nonsense init for stupid compilers.
|
||||
QString fileName;
|
||||
if (isLib) {
|
||||
@@ -218,10 +219,10 @@ QString MaemoDeployableListModel::localExecutableFilePath() const
|
||||
|| config.contains(QLatin1String("staticlib"))
|
||||
|| config.contains(QLatin1String("plugin"));
|
||||
}
|
||||
fileName += ti.target;
|
||||
fileName += m_targetInfo.target;
|
||||
if (isLib)
|
||||
fileName += QLatin1String(isStatic ? ".a" : ".so");
|
||||
return QDir::cleanPath(ti.workingDir + '/' + fileName);
|
||||
return QDir::cleanPath(m_targetInfo.workingDir + '/' + fileName);
|
||||
}
|
||||
|
||||
QString MaemoDeployableListModel::remoteExecutableFilePath() const
|
||||
@@ -232,14 +233,9 @@ QString MaemoDeployableListModel::remoteExecutableFilePath() const
|
||||
: QString();
|
||||
}
|
||||
|
||||
QString MaemoDeployableListModel::projectName() const
|
||||
{
|
||||
return m_proFileNode->displayName();
|
||||
}
|
||||
|
||||
QString MaemoDeployableListModel::projectDir() const
|
||||
{
|
||||
return QFileInfo(m_proFileNode->path()).dir().path();
|
||||
return QFileInfo(m_proFilePath).dir().path();
|
||||
}
|
||||
|
||||
void MaemoDeployableListModel::setProFileUpdateSetting(ProFileUpdateSetting updateSetting)
|
||||
|
||||
@@ -32,6 +32,8 @@
|
||||
|
||||
#include "maemodeployable.h"
|
||||
|
||||
#include <qt4projectmanager/qt4nodes.h>
|
||||
|
||||
#include <QtCore/QAbstractTableModel>
|
||||
#include <QtCore/QHash>
|
||||
#include <QtCore/QList>
|
||||
@@ -46,7 +48,6 @@ QT_END_NAMESPACE
|
||||
namespace Qt4ProjectManager {
|
||||
namespace Internal {
|
||||
class MaemoProFileWrapper;
|
||||
class Qt4ProFileNode;
|
||||
|
||||
class MaemoDeployableListModel : public QAbstractTableModel
|
||||
{
|
||||
@@ -70,9 +71,9 @@ public:
|
||||
void setUnModified() { m_modified = false; }
|
||||
QString localExecutableFilePath() const;
|
||||
QString remoteExecutableFilePath() const;
|
||||
QString projectName() const;
|
||||
QString projectName() const { return m_projectName; }
|
||||
QString projectDir() const;
|
||||
const Qt4ProFileNode *proFileNode() const { return m_proFileNode; }
|
||||
QString proFilePath() const { return m_proFilePath; }
|
||||
bool hasTargetPath() const { return m_hasTargetPath; }
|
||||
ProFileUpdateSetting proFileUpdateSetting() const {
|
||||
return m_proFileUpdateSetting;
|
||||
@@ -91,7 +92,10 @@ private:
|
||||
|
||||
bool buildModel();
|
||||
|
||||
const Qt4ProFileNode * const m_proFileNode;
|
||||
const Qt4ProjectType m_projectType;
|
||||
const QString m_proFilePath;
|
||||
const QString m_projectName;
|
||||
const TargetInformation m_targetInfo;
|
||||
QList<MaemoDeployable> m_deployables;
|
||||
mutable bool m_modified;
|
||||
const QScopedPointer<MaemoProFileWrapper> m_proFileWrapper;
|
||||
|
||||
@@ -112,7 +112,7 @@ void MaemoDeployables::createModels()
|
||||
= setting.second
|
||||
? MaemoDeployableListModel::UpdateProFile
|
||||
: MaemoDeployableListModel::DontUpdateProFile;
|
||||
m_updateSettings.insert(setting.first->proFileNode()->path(),
|
||||
m_updateSettings.insert(setting.first->proFilePath(),
|
||||
updateSetting);
|
||||
setting.first->setProFileUpdateSetting(updateSetting);
|
||||
}
|
||||
|
||||
@@ -50,7 +50,7 @@ MaemoProFilesUpdateDialog::MaemoProFilesUpdateDialog(const QList<MaemoDeployable
|
||||
new QTableWidgetItem(tr("Updateable Project Files")));
|
||||
for (int row = 0; row < models.count(); ++row) {
|
||||
QTableWidgetItem *const item
|
||||
= new QTableWidgetItem(models.at(row)->proFileNode()->path());
|
||||
= new QTableWidgetItem(models.at(row)->proFilePath());
|
||||
item->setFlags(Qt::ItemIsUserCheckable | Qt::ItemIsEnabled);
|
||||
item->setCheckState(Qt::Unchecked);
|
||||
ui->tableWidget->setItem(row, 0, item);
|
||||
|
||||
@@ -327,7 +327,7 @@ bool MaemoTemplatesManager::updateDesktopFile(const Qt4Target *target,
|
||||
->deployables();
|
||||
for (int i = 0; i < deployables->modelCount(); ++i) {
|
||||
const MaemoDeployableListModel * const model = deployables->modelAt(i);
|
||||
if (model->proFileNode() == proFileNode) {
|
||||
if (model->proFilePath() == proFileNode->path()) {
|
||||
executable = model->remoteExecutableFilePath();
|
||||
break;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user