diff --git a/dist/changes-4.3.1.md b/dist/changes-4.3.1.md index fa1ac40afbc..018f3a461d8 100644 --- a/dist/changes-4.3.1.md +++ b/dist/changes-4.3.1.md @@ -43,6 +43,10 @@ CMake Projects * Fixed that building application failed first time and after build error when using CMake < 3.7 (QTCREATORBUG-18290, QTCREATORBUG-18382) +Qbs Projects + +* Fixed crash when renaming files (QTCREATORBUG-18440) + Autotools Projects * Fixed regressions in project tree (QTCREATORBUG-18371) diff --git a/src/plugins/qbsprojectmanager/qbsproject.cpp b/src/plugins/qbsprojectmanager/qbsproject.cpp index fe0980e01d1..6496a66d31f 100644 --- a/src/plugins/qbsprojectmanager/qbsproject.cpp +++ b/src/plugins/qbsprojectmanager/qbsproject.cpp @@ -237,8 +237,8 @@ bool QbsProject::ensureWriteableQbsFile(const QString &file) } bool QbsProject::addFilesToProduct(const QStringList &filePaths, - const qbs::ProductData &productData, - const qbs::GroupData &groupData, QStringList *notAdded) + const qbs::ProductData productData, + const qbs::GroupData groupData, QStringList *notAdded) { QTC_ASSERT(m_qbsProject.isValid(), return false); QStringList allPaths = groupData.allFilePaths(); @@ -262,8 +262,8 @@ bool QbsProject::addFilesToProduct(const QStringList &filePaths, } bool QbsProject::removeFilesFromProduct(const QStringList &filePaths, - const qbs::ProductData &productData, - const qbs::GroupData &groupData, + const qbs::ProductData productData, + const qbs::GroupData groupData, QStringList *notRemoved) { 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, - const qbs::ProductData &productData, - const qbs::GroupData &groupData) + const qbs::ProductData productData, + const qbs::GroupData groupData) { if (newPath.isEmpty()) return false; diff --git a/src/plugins/qbsprojectmanager/qbsproject.h b/src/plugins/qbsprojectmanager/qbsproject.h index a13fdf698ae..505d70412a4 100644 --- a/src/plugins/qbsprojectmanager/qbsproject.h +++ b/src/plugins/qbsprojectmanager/qbsproject.h @@ -66,14 +66,19 @@ public: QStringList filesGeneratedFrom(const QString &sourceFile) const override; bool isProjectEditable() const; - bool addFilesToProduct(const QStringList &filePaths, const qbs::ProductData &productData, - const qbs::GroupData &groupData, QStringList *notAdded); + // qbs::ProductData and qbs::GroupData are held by the nodes in the project tree. + // 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, - const qbs::ProductData &productData, const qbs::GroupData &groupData, + const qbs::ProductData productData, const qbs::GroupData groupData, QStringList *notRemoved); bool renameFileInProduct(const QString &oldPath, - const QString &newPath, const qbs::ProductData &productData, - const qbs::GroupData &groupData); + const QString &newPath, const qbs::ProductData productData, + const qbs::GroupData groupData); qbs::BuildJob *build(const qbs::BuildOptions &opts, QStringList products, QString &error); qbs::CleanJob *clean(const qbs::CleanOptions &opts);