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