forked from qt-creator/qt-creator
Merge remote-tracking branch 'origin/3.2'
Conflicts: qtcreator.pri qtcreator.qbs src/plugins/coreplugin/editormanager/editormanager.cpp src/plugins/cppeditor/cppeditor.cpp src/plugins/remotelinux/remotelinuxdebugsupport.cpp src/plugins/texteditor/basetexteditor.cpp Change-Id: I0da7c1cf2506b12d0563795aa8177fc45e97050f
This commit is contained in:
@@ -39,6 +39,9 @@
|
||||
#include <coreplugin/documentmanager.h>
|
||||
#include <coreplugin/icontext.h>
|
||||
#include <coreplugin/id.h>
|
||||
#include <coreplugin/icore.h>
|
||||
#include <coreplugin/iversioncontrol.h>
|
||||
#include <coreplugin/vcsmanager.h>
|
||||
#include <coreplugin/messagemanager.h>
|
||||
#include <coreplugin/progressmanager/progressmanager.h>
|
||||
#include <coreplugin/mimedatabase.h>
|
||||
@@ -68,6 +71,7 @@
|
||||
#include <QCoreApplication>
|
||||
#include <QDir>
|
||||
#include <QFileInfo>
|
||||
#include <QMessageBox>
|
||||
#include <QVariantMap>
|
||||
|
||||
using namespace Core;
|
||||
@@ -130,6 +134,11 @@ QbsProject::~QbsProject()
|
||||
{
|
||||
m_codeModelFuture.cancel();
|
||||
delete m_qbsProjectParser;
|
||||
if (m_qbsUpdateFutureInterface) {
|
||||
m_qbsUpdateFutureInterface->reportCanceled();
|
||||
delete m_qbsUpdateFutureInterface;
|
||||
m_qbsUpdateFutureInterface = 0;
|
||||
}
|
||||
|
||||
// Deleting the root node triggers a few things, make sure rootProjectNode
|
||||
// returns 0 already
|
||||
@@ -223,6 +232,27 @@ private:
|
||||
bool m_wasInDocumentManager;
|
||||
};
|
||||
|
||||
bool QbsProject::ensureWriteableQbsFile(const QString &file)
|
||||
{
|
||||
// Ensure that the file is not read only
|
||||
QFileInfo fi(file);
|
||||
if (!fi.isWritable()) {
|
||||
// Try via vcs manager
|
||||
Core::IVersionControl *versionControl =
|
||||
Core::VcsManager::findVersionControlForDirectory(fi.absolutePath());
|
||||
if (!versionControl || !versionControl->vcsOpen(file)) {
|
||||
bool makeWritable = QFile::setPermissions(file, fi.permissions() | QFile::WriteUser);
|
||||
if (!makeWritable) {
|
||||
QMessageBox::warning(Core::ICore::mainWindow(),
|
||||
tr("Failed!"),
|
||||
tr("Could not write project file %1.").arg(file));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool QbsProject::addFilesToProduct(QbsBaseProjectNode *node, const QStringList &filePaths,
|
||||
const qbs::ProductData &productData, const qbs::GroupData &groupData, QStringList *notAdded)
|
||||
{
|
||||
@@ -230,6 +260,7 @@ bool QbsProject::addFilesToProduct(QbsBaseProjectNode *node, const QStringList &
|
||||
QStringList allPaths = groupData.allFilePaths();
|
||||
const QString productFilePath = productData.location().fileName();
|
||||
ChangeExpector expector(productFilePath, m_qbsDocuments);
|
||||
ensureWriteableQbsFile(productFilePath);
|
||||
foreach (const QString &path, filePaths) {
|
||||
qbs::ErrorInfo err = m_qbsProject.addFiles(productData, groupData, QStringList() << path);
|
||||
if (err.hasError()) {
|
||||
@@ -255,6 +286,7 @@ bool QbsProject::removeFilesFromProduct(QbsBaseProjectNode *node, const QStringL
|
||||
QStringList allPaths = groupData.allFilePaths();
|
||||
const QString productFilePath = productData.location().fileName();
|
||||
ChangeExpector expector(productFilePath, m_qbsDocuments);
|
||||
ensureWriteableQbsFile(productFilePath);
|
||||
foreach (const QString &path, filePaths) {
|
||||
qbs::ErrorInfo err
|
||||
= m_qbsProject.removeFiles(productData, groupData, QStringList() << path);
|
||||
|
||||
Reference in New Issue
Block a user