forked from qt-creator/qt-creator
QtSupport: allow relative paths for the qmake command
This change makes it possible to bake in settings for bundled/shipped Qt versions like we have in the QtDesignStudio.app package. The result is that the installer does not need to write absolute paths to the settings anymore, so it stays like it was signed. A signed package on macOS is more and more necessary and recommended for a while. Especially If the application will touch files in special folders like Download, Documents, or Desktop. Change-Id: I3153ffd4229b34a59bdfe740937c21ee93de3e9b Reviewed-by: Eike Ziller <eike.ziller@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
This commit is contained in:
@@ -336,11 +336,17 @@ bool PersistentSettingsReader::load(const FilePath &fileName)
|
||||
if (fileName.fileSize() == 0) // skip empty files
|
||||
return false;
|
||||
|
||||
m_filePath = fileName.parentDir();
|
||||
ParseContext ctx;
|
||||
m_valueMap = ctx.parse(fileName);
|
||||
return true;
|
||||
}
|
||||
|
||||
FilePath PersistentSettingsReader::filePath()
|
||||
{
|
||||
return m_filePath;
|
||||
}
|
||||
|
||||
/*!
|
||||
\class Utils::PersistentSettingsWriter
|
||||
|
||||
|
||||
@@ -22,9 +22,11 @@ public:
|
||||
QVariant restoreValue(const QString &variable, const QVariant &defaultValue = QVariant()) const;
|
||||
QVariantMap restoreValues() const;
|
||||
bool load(const FilePath &fileName);
|
||||
FilePath filePath();
|
||||
|
||||
private:
|
||||
QMap<QString, QVariant> m_valueMap;
|
||||
FilePath m_filePath;
|
||||
};
|
||||
|
||||
class QTCREATOR_UTILS_EXPORT PersistentSettingsWriter
|
||||
|
||||
@@ -116,7 +116,7 @@ QVariantMap QnxQtVersion::toMap() const
|
||||
return result;
|
||||
}
|
||||
|
||||
void QnxQtVersion::fromMap(const QVariantMap &map)
|
||||
void QnxQtVersion::fromMap(const QVariantMap &map, const Utils::FilePath &)
|
||||
{
|
||||
QtVersion::fromMap(map);
|
||||
setSdpPath(FilePath::fromVariant(map.value(SDP_PATH_KEY)));
|
||||
|
||||
@@ -28,7 +28,7 @@ public:
|
||||
QString cpuDir() const;
|
||||
|
||||
QVariantMap toMap() const override;
|
||||
void fromMap(const QVariantMap &map) override;
|
||||
void fromMap(const QVariantMap &map, const Utils::FilePath &filePath) override;
|
||||
|
||||
ProjectExplorer::Abis detectQtAbis() const override;
|
||||
|
||||
|
||||
@@ -635,7 +635,7 @@ bool QtVersion::hasReleaseBuild() const
|
||||
return !d->m_defaultConfigIsDebug || d->m_defaultConfigIsDebugAndRelease;
|
||||
}
|
||||
|
||||
void QtVersion::fromMap(const QVariantMap &map)
|
||||
void QtVersion::fromMap(const QVariantMap &map, const FilePath &filePath)
|
||||
{
|
||||
d->m_id = map.value(Constants::QTVERSIONID).toInt();
|
||||
if (d->m_id == -1) // this happens on adding from installer, see updateFromInstaller => get a new unique id
|
||||
@@ -660,6 +660,7 @@ void QtVersion::fromMap(const QVariantMap &map)
|
||||
d->m_qmakeCommand = BuildableHelperLibrary::qtChooserToQmakePath(qmake);
|
||||
}
|
||||
}
|
||||
d->m_qmakeCommand = filePath.resolvePath(d->m_qmakeCommand);
|
||||
|
||||
d->m_data.qtSources = FilePath::fromVariant(map.value(QTVERSIONSOURCEPATH));
|
||||
|
||||
@@ -2325,12 +2326,12 @@ bool QtVersionFactory::canRestore(const QString &type)
|
||||
return type == m_supportedType;
|
||||
}
|
||||
|
||||
QtVersion *QtVersionFactory::restore(const QString &type, const QVariantMap &data)
|
||||
QtVersion *QtVersionFactory::restore(const QString &type, const QVariantMap &data, const FilePath &filePath)
|
||||
{
|
||||
QTC_ASSERT(canRestore(type), return nullptr);
|
||||
QTC_ASSERT(m_creator, return nullptr);
|
||||
QtVersion *version = create();
|
||||
version->fromMap(data);
|
||||
version->fromMap(data, filePath);
|
||||
return version;
|
||||
}
|
||||
|
||||
|
||||
@@ -49,7 +49,7 @@ public:
|
||||
|
||||
virtual ~QtVersion();
|
||||
|
||||
virtual void fromMap(const QVariantMap &map);
|
||||
virtual void fromMap(const QVariantMap &map, const Utils::FilePath &filePath = {});
|
||||
virtual bool equals(QtVersion *other);
|
||||
|
||||
bool isAutodetected() const;
|
||||
|
||||
@@ -22,7 +22,7 @@ public:
|
||||
static const QList<QtVersionFactory *> allQtVersionFactories();
|
||||
|
||||
bool canRestore(const QString &type);
|
||||
QtVersion *restore(const QString &type, const QVariantMap &data);
|
||||
QtVersion *restore(const QString &type, const QVariantMap &data, const Utils::FilePath &workingDirectory);
|
||||
|
||||
/// factories with higher priority are asked first to identify
|
||||
/// a qtversion, the priority of the desktop factory is 0 and
|
||||
|
||||
@@ -195,7 +195,7 @@ static bool restoreQtVersions()
|
||||
bool restored = false;
|
||||
for (QtVersionFactory *f : factories) {
|
||||
if (f->canRestore(type)) {
|
||||
if (QtVersion *qtv = f->restore(type, qtversionMap)) {
|
||||
if (QtVersion *qtv = f->restore(type, qtversionMap, reader.filePath())) {
|
||||
if (m_versions.contains(qtv->uniqueId())) {
|
||||
// This shouldn't happen, we are restoring the same id multiple times?
|
||||
qWarning() << "A Qt version with id"<<qtv->uniqueId()<<"already exists";
|
||||
@@ -289,7 +289,7 @@ void QtVersionManager::updateFromInstaller(bool emitSignal)
|
||||
qtversionMap[Constants::QTVERSIONNAME] = v->unexpandedDisplayName();
|
||||
delete v;
|
||||
|
||||
if (QtVersion *qtv = factory->restore(type, qtversionMap)) {
|
||||
if (QtVersion *qtv = factory->restore(type, qtversionMap, reader.filePath())) {
|
||||
Q_ASSERT(qtv->isAutodetected());
|
||||
m_versions.insert(id, qtv);
|
||||
restored = true;
|
||||
@@ -303,7 +303,7 @@ void QtVersionManager::updateFromInstaller(bool emitSignal)
|
||||
// Create a new qtversion
|
||||
if (!restored) { // didn't replace any existing versions
|
||||
qCDebug(log) << " No Qt version found matching" << autoDetectionSource << " => Creating new version";
|
||||
if (QtVersion *qtv = factory->restore(type, qtversionMap)) {
|
||||
if (QtVersion *qtv = factory->restore(type, qtversionMap, reader.filePath())) {
|
||||
Q_ASSERT(qtv->isAutodetected());
|
||||
m_versions.insert(qtv->uniqueId(), qtv);
|
||||
added << qtv->uniqueId();
|
||||
|
||||
Reference in New Issue
Block a user