forked from qt-creator/qt-creator
Qbs: Fix crash when renaming files
Fix a crash when using file nodes to change the project. The methods used to take const references, with the data living in the nodes of the project tree. Since the methods change the project tree and thus cause the tree to be rebuilt, the original data may get lost. So copy the data instead. All the qbs::*Data classes are using shared data, so the overhead is not too big. Task-number: QTCREATORBUG-18440 Change-Id: I45ca5403a04e17790416dfe15b836f12c732e824 Reviewed-by: Eike Ziller <eike.ziller@qt.io> Reviewed-by: Tim Jenssen <tim.jenssen@qt.io> Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
committed by
Tobias Hunger
parent
6ab1da8b78
commit
56db0df2e6
4
dist/changes-4.3.1.md
vendored
4
dist/changes-4.3.1.md
vendored
@@ -43,6 +43,10 @@ CMake Projects
|
|||||||
* Fixed that building application failed first time and after build error
|
* Fixed that building application failed first time and after build error
|
||||||
when using CMake < 3.7 (QTCREATORBUG-18290, QTCREATORBUG-18382)
|
when using CMake < 3.7 (QTCREATORBUG-18290, QTCREATORBUG-18382)
|
||||||
|
|
||||||
|
Qbs Projects
|
||||||
|
|
||||||
|
* Fixed crash when renaming files (QTCREATORBUG-18440)
|
||||||
|
|
||||||
Autotools Projects
|
Autotools Projects
|
||||||
|
|
||||||
* Fixed regressions in project tree (QTCREATORBUG-18371)
|
* Fixed regressions in project tree (QTCREATORBUG-18371)
|
||||||
|
@@ -237,8 +237,8 @@ bool QbsProject::ensureWriteableQbsFile(const QString &file)
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool QbsProject::addFilesToProduct(const QStringList &filePaths,
|
bool QbsProject::addFilesToProduct(const QStringList &filePaths,
|
||||||
const qbs::ProductData &productData,
|
const qbs::ProductData productData,
|
||||||
const qbs::GroupData &groupData, QStringList *notAdded)
|
const qbs::GroupData groupData, QStringList *notAdded)
|
||||||
{
|
{
|
||||||
QTC_ASSERT(m_qbsProject.isValid(), return false);
|
QTC_ASSERT(m_qbsProject.isValid(), return false);
|
||||||
QStringList allPaths = groupData.allFilePaths();
|
QStringList allPaths = groupData.allFilePaths();
|
||||||
@@ -262,8 +262,8 @@ bool QbsProject::addFilesToProduct(const QStringList &filePaths,
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool QbsProject::removeFilesFromProduct(const QStringList &filePaths,
|
bool QbsProject::removeFilesFromProduct(const QStringList &filePaths,
|
||||||
const qbs::ProductData &productData,
|
const qbs::ProductData productData,
|
||||||
const qbs::GroupData &groupData,
|
const qbs::GroupData groupData,
|
||||||
QStringList *notRemoved)
|
QStringList *notRemoved)
|
||||||
{
|
{
|
||||||
QTC_ASSERT(m_qbsProject.isValid(), return false);
|
QTC_ASSERT(m_qbsProject.isValid(), return false);
|
||||||
@@ -290,8 +290,8 @@ bool QbsProject::removeFilesFromProduct(const QStringList &filePaths,
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool QbsProject::renameFileInProduct(const QString &oldPath, const QString &newPath,
|
bool QbsProject::renameFileInProduct(const QString &oldPath, const QString &newPath,
|
||||||
const qbs::ProductData &productData,
|
const qbs::ProductData productData,
|
||||||
const qbs::GroupData &groupData)
|
const qbs::GroupData groupData)
|
||||||
{
|
{
|
||||||
if (newPath.isEmpty())
|
if (newPath.isEmpty())
|
||||||
return false;
|
return false;
|
||||||
|
@@ -66,14 +66,19 @@ public:
|
|||||||
QStringList filesGeneratedFrom(const QString &sourceFile) const override;
|
QStringList filesGeneratedFrom(const QString &sourceFile) const override;
|
||||||
|
|
||||||
bool isProjectEditable() const;
|
bool isProjectEditable() const;
|
||||||
bool addFilesToProduct(const QStringList &filePaths, const qbs::ProductData &productData,
|
// qbs::ProductData and qbs::GroupData are held by the nodes in the project tree.
|
||||||
const qbs::GroupData &groupData, QStringList *notAdded);
|
// These methods change those trees and invalidate the lot, so pass in copies of
|
||||||
|
// the data we are interested in!
|
||||||
|
// The overhead is not as big as it seems at first glance: These all are handles
|
||||||
|
// for shared data.
|
||||||
|
bool addFilesToProduct(const QStringList &filePaths, const qbs::ProductData productData,
|
||||||
|
const qbs::GroupData groupData, QStringList *notAdded);
|
||||||
bool removeFilesFromProduct(const QStringList &filePaths,
|
bool removeFilesFromProduct(const QStringList &filePaths,
|
||||||
const qbs::ProductData &productData, const qbs::GroupData &groupData,
|
const qbs::ProductData productData, const qbs::GroupData groupData,
|
||||||
QStringList *notRemoved);
|
QStringList *notRemoved);
|
||||||
bool renameFileInProduct(const QString &oldPath,
|
bool renameFileInProduct(const QString &oldPath,
|
||||||
const QString &newPath, const qbs::ProductData &productData,
|
const QString &newPath, const qbs::ProductData productData,
|
||||||
const qbs::GroupData &groupData);
|
const qbs::GroupData groupData);
|
||||||
|
|
||||||
qbs::BuildJob *build(const qbs::BuildOptions &opts, QStringList products, QString &error);
|
qbs::BuildJob *build(const qbs::BuildOptions &opts, QStringList products, QString &error);
|
||||||
qbs::CleanJob *clean(const qbs::CleanOptions &opts);
|
qbs::CleanJob *clean(const qbs::CleanOptions &opts);
|
||||||
|
Reference in New Issue
Block a user