forked from qt-creator/qt-creator
add/unify i/o error handling
lots of use of Utils::FileSaver and Utils::FileReader Task-number: QTCREATORBUG-1619
This commit is contained in:
@@ -489,10 +489,9 @@ bool PluginSpecPrivate::read(const QString &fileName)
|
||||
errorString = "";
|
||||
dependencies.clear();
|
||||
QFile file(fileName);
|
||||
if (!file.exists())
|
||||
return reportError(tr("File does not exist: %1").arg(file.fileName()));
|
||||
if (!file.open(QIODevice::ReadOnly))
|
||||
return reportError(tr("Could not open file for read: %1").arg(file.fileName()));
|
||||
return reportError(tr("Could not open file %1 for read: %2")
|
||||
.arg(QDir::toNativeSeparators(file.fileName()), file.errorString()));
|
||||
QFileInfo fileInfo(file);
|
||||
location = fileInfo.absolutePath();
|
||||
filePath = fileInfo.absoluteFilePath();
|
||||
|
||||
@@ -41,6 +41,7 @@
|
||||
#include "sshkeyexchange_p.h"
|
||||
|
||||
#include <utils/qtcassert.h>
|
||||
#include <utils/fileutils.h>
|
||||
|
||||
#include <botan/exceptn.h>
|
||||
#include <botan/init.h>
|
||||
@@ -410,18 +411,12 @@ void SshConnectionPrivate::handleServiceAcceptPacket()
|
||||
m_sendFacility.sendUserAuthByPwdRequestPacket(m_connParams.userName.toUtf8(),
|
||||
SshCapabilities::SshConnectionService, m_connParams.password.toUtf8());
|
||||
} else {
|
||||
QFile privKeyFile(m_connParams.privateKeyFile);
|
||||
bool couldOpen = privKeyFile.open(QIODevice::ReadOnly);
|
||||
QByteArray contents;
|
||||
if (couldOpen)
|
||||
contents = privKeyFile.readAll();
|
||||
if (!couldOpen || privKeyFile.error() != QFile::NoError) {
|
||||
Utils::FileReader reader;
|
||||
if (!reader.fetch(m_connParams.privateKeyFile))
|
||||
throw SshClientException(SshKeyFileError,
|
||||
tr("Could not read private key file: %1")
|
||||
.arg(privKeyFile.errorString()));
|
||||
}
|
||||
tr("Private key error: %1").arg(reader.errorString()));
|
||||
|
||||
m_sendFacility.createAuthenticationKey(contents);
|
||||
m_sendFacility.createAuthenticationKey(reader.data());
|
||||
m_sendFacility.sendUserAuthByKeyRequestPacket(m_connParams.userName.toUtf8(),
|
||||
SshCapabilities::SshConnectionService);
|
||||
}
|
||||
|
||||
@@ -39,6 +39,8 @@
|
||||
|
||||
#include <utils/qtcassert.h>
|
||||
|
||||
#include <utils/fileutils.h>
|
||||
|
||||
#include <QtCore/QFile>
|
||||
#include <QtCore/QXmlStreamAttributes>
|
||||
#include <QtCore/QXmlStreamWriter>
|
||||
@@ -134,12 +136,10 @@ bool CommandsFile::exportCommands(const QList<ShortcutItem *> &items)
|
||||
{
|
||||
const UniqueIDManager *idmanager = UniqueIDManager::instance();
|
||||
|
||||
QFile file(m_filename);
|
||||
if (!file.open(QIODevice::WriteOnly|QIODevice::Text))
|
||||
return false;
|
||||
|
||||
Utils::FileSaver saver(m_filename, QIODevice::Text);
|
||||
if (!saver.hasError()) {
|
||||
const Context ctx;
|
||||
QXmlStreamWriter w(&file);
|
||||
QXmlStreamWriter w(saver.file());
|
||||
w.setAutoFormatting(true);
|
||||
w.setAutoFormattingIndent(1); // Historical, used to be QDom.
|
||||
w.writeStartDocument();
|
||||
@@ -163,8 +163,10 @@ bool CommandsFile::exportCommands(const QList<ShortcutItem *> &items)
|
||||
}
|
||||
w.writeEndElement();
|
||||
w.writeEndDocument();
|
||||
file.close();
|
||||
return true;
|
||||
|
||||
saver.setResult(&w);
|
||||
}
|
||||
return saver.finalize();
|
||||
}
|
||||
|
||||
} // namespace Internal
|
||||
|
||||
@@ -42,6 +42,7 @@
|
||||
#include <utils/filewizarddialog.h>
|
||||
#include <utils/qtcassert.h>
|
||||
#include <utils/stringutils.h>
|
||||
#include <utils/fileutils.h>
|
||||
|
||||
#include <QtCore/QDir>
|
||||
#include <QtCore/QFile>
|
||||
@@ -179,23 +180,15 @@ bool GeneratedFile::write(QString *errorMessage) const
|
||||
return false;
|
||||
}
|
||||
}
|
||||
// Write out
|
||||
QFile file(m_d->path);
|
||||
|
||||
// Write out
|
||||
QIODevice::OpenMode flags = QIODevice::WriteOnly|QIODevice::Truncate;
|
||||
if (!isBinary())
|
||||
flags |= QIODevice::Text;
|
||||
|
||||
if (!file.open(flags)) {
|
||||
*errorMessage = BaseFileWizard::tr("Unable to open %1 for writing: %2").arg(m_d->path, file.errorString());
|
||||
return false;
|
||||
}
|
||||
if (file.write(m_d->contents) == -1) {
|
||||
*errorMessage = BaseFileWizard::tr("Error while writing to %1: %2").arg(m_d->path, file.errorString());
|
||||
return false;
|
||||
}
|
||||
file.close();
|
||||
return true;
|
||||
Utils::FileSaver saver(m_d->path, flags);
|
||||
saver.write(m_d->contents);
|
||||
return saver.finalize(errorMessage);
|
||||
}
|
||||
|
||||
GeneratedFile::Attributes GeneratedFile::attributes() const
|
||||
|
||||
@@ -43,6 +43,7 @@
|
||||
#include <utils/qtcassert.h>
|
||||
#include <utils/stringutils.h>
|
||||
#include <utils/environment.h>
|
||||
#include <utils/fileutils.h>
|
||||
|
||||
#include <QtCore/QXmlStreamReader>
|
||||
#include <QtCore/QXmlStreamWriter>
|
||||
@@ -432,21 +433,15 @@ ExternalTool * ExternalTool::createFromXml(const QByteArray &xml, QString *error
|
||||
|
||||
ExternalTool * ExternalTool::createFromFile(const QString &fileName, QString *errorMessage, const QString &locale)
|
||||
{
|
||||
QFileInfo info(fileName);
|
||||
QFile file(info.absoluteFilePath());
|
||||
if (!file.open(QIODevice::ReadOnly)) {
|
||||
if (errorMessage)
|
||||
*errorMessage = tr("Could not open tool specification %1 for reading: %2").
|
||||
arg(fileName, file.errorString());
|
||||
QString absFileName = QFileInfo(fileName).absoluteFilePath();
|
||||
Utils::FileReader reader;
|
||||
if (!reader.fetch(absFileName, errorMessage))
|
||||
return 0;
|
||||
}
|
||||
const QByteArray &bytes = file.readAll();
|
||||
file.close();
|
||||
ExternalTool *tool = ExternalTool::createFromXml(bytes, errorMessage, locale);
|
||||
ExternalTool *tool = ExternalTool::createFromXml(reader.data(), errorMessage, locale);
|
||||
if (!tool) {
|
||||
return 0;
|
||||
}
|
||||
tool->m_fileName = file.fileName();
|
||||
tool->m_fileName = absFileName;
|
||||
return tool;
|
||||
}
|
||||
|
||||
@@ -467,14 +462,9 @@ bool ExternalTool::save(QString *errorMessage) const
|
||||
{
|
||||
if (m_fileName.isEmpty())
|
||||
return false;
|
||||
QFile file(m_fileName);
|
||||
if (!file.open(QIODevice::WriteOnly)) {
|
||||
if (errorMessage)
|
||||
*errorMessage = tr("Could not write tool specification %1: %2").
|
||||
arg(m_fileName, file.errorString());
|
||||
return false;
|
||||
}
|
||||
QXmlStreamWriter out(&file);
|
||||
Utils::FileSaver saver(m_fileName);
|
||||
if (!saver.hasError()) {
|
||||
QXmlStreamWriter out(saver.file());
|
||||
out.setAutoFormatting(true);
|
||||
out.writeStartDocument(QLatin1String("1.0"));
|
||||
out.writeComment(QString::fromLatin1("Written on %1 by Qt Creator %2")
|
||||
@@ -502,8 +492,10 @@ bool ExternalTool::save(QString *errorMessage) const
|
||||
out.writeEndElement();
|
||||
|
||||
out.writeEndDocument();
|
||||
file.close();
|
||||
return true;
|
||||
|
||||
saver.setResult(&out);
|
||||
}
|
||||
return saver.finalize(errorMessage);
|
||||
}
|
||||
|
||||
bool ExternalTool::operator==(const ExternalTool &other) const
|
||||
|
||||
@@ -52,6 +52,7 @@
|
||||
#include <coreplugin/icore.h>
|
||||
#include <coreplugin/messagemanager.h>
|
||||
#include <utils/qtcassert.h>
|
||||
#include <utils/fileutils.h>
|
||||
#include <texteditor/basetexteditor.h>
|
||||
|
||||
#include <QtCore/QtPlugin>
|
||||
@@ -277,23 +278,6 @@ static inline QString tempFilePattern(const QString &prefix, const QString &exte
|
||||
return pattern;
|
||||
}
|
||||
|
||||
typedef QSharedPointer<QTemporaryFile> TemporaryFilePtr;
|
||||
|
||||
// Write an a temporary file.
|
||||
TemporaryFilePtr writeTemporaryFile(const QString &namePattern,
|
||||
const QString &contents,
|
||||
QString *errorMessage)
|
||||
{
|
||||
TemporaryFilePtr tempFile(new QTemporaryFile(namePattern));
|
||||
if (!tempFile->open()) {
|
||||
*errorMessage = QString::fromLatin1("Unable to open temporary file %1").arg(tempFile->errorString());
|
||||
return TemporaryFilePtr();
|
||||
}
|
||||
tempFile->write(contents.toUtf8());
|
||||
tempFile->close();
|
||||
return tempFile;
|
||||
}
|
||||
|
||||
void CodepasterPlugin::finishFetch(const QString &titleDescription,
|
||||
const QString &content,
|
||||
bool error)
|
||||
@@ -313,23 +297,21 @@ void CodepasterPlugin::finishFetch(const QString &titleDescription,
|
||||
// for the user and also to be able to tell a patch or diff in the VCS plugins
|
||||
// by looking at the file name of FileManager::currentFile() without expensive checking.
|
||||
// Default to "txt".
|
||||
QByteArray byteContent = content.toUtf8();
|
||||
QString suffix;
|
||||
if (const Core::MimeType mimeType = Core::ICore::instance()->mimeDatabase()->findByData(content.toUtf8()))
|
||||
if (const Core::MimeType mimeType = Core::ICore::instance()->mimeDatabase()->findByData(byteContent))
|
||||
suffix = mimeType.preferredSuffix();
|
||||
if (suffix.isEmpty())
|
||||
suffix = QLatin1String("txt");
|
||||
const QString filePrefix = filePrefixFromTitle(titleDescription);
|
||||
QString errorMessage;
|
||||
TemporaryFilePtr tempFile = writeTemporaryFile(tempFilePattern(filePrefix, suffix), content, &errorMessage);
|
||||
if (tempFile.isNull()) {
|
||||
messageManager->printToOutputPane(errorMessage);
|
||||
Utils::TempFileSaver saver(tempFilePattern(filePrefix, suffix));
|
||||
saver.setAutoRemove(false);
|
||||
saver.write(byteContent);
|
||||
if (!saver.finalize()) {
|
||||
messageManager->printToOutputPane(saver.errorString());
|
||||
return;
|
||||
}
|
||||
// Keep the file and store in list of files to be removed.
|
||||
tempFile->setAutoRemove(false);
|
||||
const QString fileName = tempFile->fileName();
|
||||
// Discard to temporary file to make sure it is closed and no changes are triggered.
|
||||
tempFile = TemporaryFilePtr();
|
||||
const QString fileName = saver.fileName();
|
||||
m_fetchedSnippets.push_back(fileName);
|
||||
// Open editor with title.
|
||||
Core::IEditor* editor = EditorManager::instance()->openEditor(fileName, QString(), EditorManager::ModeSwitch);
|
||||
|
||||
@@ -38,6 +38,7 @@
|
||||
#include <coreplugin/messageoutputwindow.h>
|
||||
|
||||
#include <utils/qtcassert.h>
|
||||
#include <utils/fileutils.h>
|
||||
|
||||
#include <QtCore/QXmlStreamReader>
|
||||
#include <QtCore/QXmlStreamAttribute>
|
||||
@@ -195,15 +196,11 @@ void FileShareProtocol::paste(const QString &text,
|
||||
const QString &description)
|
||||
{
|
||||
// Write out temp XML file
|
||||
QTemporaryFile tempFile(m_settings->path + QLatin1Char('/') + QLatin1String(tempPatternC));
|
||||
tempFile.setAutoRemove(false);
|
||||
if (!tempFile.open()) {
|
||||
const QString msg = tr("Unable to open a file for writing in %1: %2").arg(m_settings->path, tempFile.errorString());
|
||||
Core::ICore::instance()->messageManager()->printToOutputPanePopup(msg);
|
||||
return;
|
||||
}
|
||||
Utils::TempFileSaver saver(m_settings->path + QLatin1Char('/') + QLatin1String(tempPatternC));
|
||||
saver.setAutoRemove(false);
|
||||
if (!saver.hasError()) {
|
||||
// Flat text sections embedded into pasterElement
|
||||
QXmlStreamWriter writer(&tempFile);
|
||||
QXmlStreamWriter writer(saver.file());
|
||||
writer.writeStartDocument();
|
||||
writer.writeStartElement(QLatin1String(pasterElementC));
|
||||
|
||||
@@ -213,9 +210,15 @@ void FileShareProtocol::paste(const QString &text,
|
||||
|
||||
writer.writeEndElement();
|
||||
writer.writeEndDocument();
|
||||
tempFile.close();
|
||||
|
||||
const QString msg = tr("Pasted: %1").arg(tempFile.fileName());
|
||||
saver.setResult(&writer);
|
||||
}
|
||||
if (!saver.finalize()) {
|
||||
Core::ICore::instance()->messageManager()->printToOutputPanePopup(saver.errorString());
|
||||
return;
|
||||
}
|
||||
|
||||
const QString msg = tr("Pasted: %1").arg(saver.fileName());
|
||||
Core::ICore::instance()->messageManager()->printToOutputPanePopup(msg);
|
||||
}
|
||||
} // namespace CodePaster
|
||||
|
||||
@@ -41,6 +41,8 @@
|
||||
|
||||
#include <extensionsystem/pluginmanager.h>
|
||||
|
||||
#include <utils/fileutils.h>
|
||||
|
||||
#include <QtCore/QSettings>
|
||||
#include <QtCore/QDebug>
|
||||
#include <QtCore/QFile>
|
||||
@@ -301,25 +303,18 @@ void CppFileSettingsWidget::setSettings(const CppFileSettings &s)
|
||||
void CppFileSettingsWidget::slotEdit()
|
||||
{
|
||||
QString path = licenseTemplatePath();
|
||||
// Edit existing file with C++
|
||||
if (!path.isEmpty()) {
|
||||
Core::EditorManager::instance()->openEditor(path, QLatin1String(CppEditor::Constants::CPPEDITOR_ID),
|
||||
Core::EditorManager::ModeSwitch);
|
||||
return;
|
||||
}
|
||||
if (path.isEmpty()) {
|
||||
// Pick a file name and write new template, edit with C++
|
||||
path = QFileDialog::getSaveFileName(this, tr("Choose Location for New License Template File"));
|
||||
if (path.isEmpty())
|
||||
return;
|
||||
QFile file(path);
|
||||
if (!file.open(QIODevice::WriteOnly|QIODevice::Text|QIODevice::Truncate)) {
|
||||
QMessageBox::warning(this, tr("Template write error"),
|
||||
tr("Cannot write to %1: %2").arg(path, file.errorString()));
|
||||
Utils::FileSaver saver(path, QIODevice::Text);
|
||||
saver.write(tr(licenseTemplateTemplate).toUtf8());
|
||||
if (!saver.finalize(this))
|
||||
return;
|
||||
}
|
||||
file.write(tr(licenseTemplateTemplate).toUtf8());
|
||||
file.close();
|
||||
setLicenseTemplatePath(path);
|
||||
}
|
||||
// Edit (now) existing file with C++
|
||||
Core::EditorManager::instance()->openEditor(path, QLatin1String(CppEditor::Constants::CPPEDITOR_ID),
|
||||
Core::EditorManager::ModeSwitch);
|
||||
}
|
||||
|
||||
@@ -38,6 +38,7 @@
|
||||
#include <find/searchresultwindow.h>
|
||||
#include <extensionsystem/pluginmanager.h>
|
||||
#include <utils/filesearch.h>
|
||||
#include <utils/fileutils.h>
|
||||
#include <coreplugin/progressmanager/progressmanager.h>
|
||||
#include <coreplugin/progressmanager/futureprogress.h>
|
||||
#include <coreplugin/editormanager/editormanager.h>
|
||||
@@ -76,11 +77,11 @@ static QString getSource(const QString &fileName,
|
||||
if (workingCopy.contains(fileName)) {
|
||||
return workingCopy.source(fileName);
|
||||
} else {
|
||||
QFile file(fileName);
|
||||
if (! file.open(QFile::ReadOnly))
|
||||
Utils::FileReader reader;
|
||||
if (!reader.fetch(fileName)) // ### FIXME error reporting
|
||||
return QString();
|
||||
|
||||
return QTextStream(&file).readAll(); // ### FIXME
|
||||
return QString::fromLocal8Bit(reader.data()); // ### FIXME encoding
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -60,6 +60,7 @@
|
||||
#include <coreplugin/editormanager/editormanager.h>
|
||||
#include <coreplugin/vcsmanager.h>
|
||||
#include <utils/stringutils.h>
|
||||
#include <utils/fileutils.h>
|
||||
#include <utils/qtcassert.h>
|
||||
|
||||
#include <QtCore/QDebug>
|
||||
@@ -68,7 +69,6 @@
|
||||
#include <QtCore/QFileInfo>
|
||||
#include <QtCore/QTextCodec>
|
||||
#include <QtCore/QtPlugin>
|
||||
#include <QtCore/QTemporaryFile>
|
||||
#include <QtGui/QAction>
|
||||
#include <QtGui/QMainWindow>
|
||||
#include <QtGui/QMenu>
|
||||
@@ -805,19 +805,17 @@ void CVSPlugin::startCommit(const QString &workingDir, const QStringList &files)
|
||||
m_commitRepository = workingDir;
|
||||
|
||||
// Create a new submit change file containing the submit template
|
||||
QTemporaryFile changeTmpFile;
|
||||
changeTmpFile.setAutoRemove(false);
|
||||
if (!changeTmpFile.open()) {
|
||||
VCSBase::VCSBaseOutputWindow::instance()->appendError(tr("Cannot create temporary file: %1").arg(changeTmpFile.errorString()));
|
||||
return;
|
||||
}
|
||||
Utils::TempFileSaver saver;
|
||||
saver.setAutoRemove(false);
|
||||
// TODO: Retrieve submit template from
|
||||
const QString submitTemplate;
|
||||
m_commitMessageFileName = changeTmpFile.fileName();
|
||||
// Create a submit
|
||||
changeTmpFile.write(submitTemplate.toUtf8());
|
||||
changeTmpFile.flush();
|
||||
changeTmpFile.close();
|
||||
saver.write(submitTemplate.toUtf8());
|
||||
if (!saver.finalize()) {
|
||||
VCSBase::VCSBaseOutputWindow::instance()->appendError(saver.errorString());
|
||||
return;
|
||||
}
|
||||
m_commitMessageFileName = saver.fileName();
|
||||
// Create a submit editor and set file list
|
||||
CVSSubmitEditor *editor = openCVSSubmitEditor(m_commitMessageFileName);
|
||||
editor->setCheckScriptWorkingDirectory(m_commitRepository);
|
||||
|
||||
@@ -106,6 +106,7 @@
|
||||
#include <utils/styledbar.h>
|
||||
#include <utils/proxyaction.h>
|
||||
#include <utils/statuslabel.h>
|
||||
#include <utils/fileutils.h>
|
||||
|
||||
#include <qml/scriptconsole.h>
|
||||
|
||||
@@ -2100,13 +2101,15 @@ void DebuggerPluginPrivate::dumpLog()
|
||||
tr("Save Debugger Log"), QDir::tempPath());
|
||||
if (fileName.isEmpty())
|
||||
return;
|
||||
QFile file(fileName);
|
||||
if (!file.open(QIODevice::WriteOnly))
|
||||
return;
|
||||
QTextStream ts(&file);
|
||||
Utils::FileSaver saver(fileName);
|
||||
if (!saver.hasError()) {
|
||||
QTextStream ts(saver.file());
|
||||
ts << m_logWindow->inputContents();
|
||||
ts << "\n\n=======================================\n\n";
|
||||
ts << m_logWindow->combinedContents();
|
||||
saver.setResult(&ts);
|
||||
}
|
||||
saver.finalize(mainWindow());
|
||||
}
|
||||
|
||||
/*! Activates the previous mode when the current mode is the debug mode. */
|
||||
|
||||
@@ -44,6 +44,7 @@
|
||||
|
||||
#include <utils/qtcassert.h>
|
||||
#include <utils/savedaction.h>
|
||||
#include <utils/fileutils.h>
|
||||
|
||||
#include <QtCore/QFile>
|
||||
#include <QtCore/QFileInfo>
|
||||
@@ -1085,11 +1086,8 @@ void GdbEngine::tryLoadDebuggingHelpersClassic()
|
||||
PRECONDITION;
|
||||
if (m_gdbAdapter->dumperHandling() == AbstractGdbAdapter::DumperNotAvailable) {
|
||||
// Load at least gdb macro based dumpers.
|
||||
QFile file(_(":/gdb/gdbmacros.txt"));
|
||||
file.open(QIODevice::ReadOnly);
|
||||
QByteArray contents = file.readAll();
|
||||
m_debuggingHelperState = DebuggingHelperLoadTried;
|
||||
postCommand(contents);
|
||||
postCommand(Utils::FileReader::fetchQrc(_(":/gdb/gdbmacros.txt")));
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -57,6 +57,7 @@
|
||||
#include <find/basetextfind.h>
|
||||
|
||||
#include <utils/savedaction.h>
|
||||
#include <utils/fileutils.h>
|
||||
|
||||
namespace Debugger {
|
||||
namespace Internal {
|
||||
@@ -501,16 +502,10 @@ bool LogWindow::writeLogContents(const QPlainTextEdit *editor, QWidget *parent)
|
||||
const QString fileName = QFileDialog::getSaveFileName(parent, tr("Log File"));
|
||||
if (fileName.isEmpty())
|
||||
break;
|
||||
QFile file(fileName);
|
||||
if (file.open(QIODevice::WriteOnly|QIODevice::Text|QIODevice::Truncate)) {
|
||||
file.write(editor->toPlainText().toUtf8());
|
||||
file.close();
|
||||
Utils::FileSaver saver(fileName, QIODevice::Text);
|
||||
saver.write(editor->toPlainText().toUtf8());
|
||||
if (saver.finalize(parent))
|
||||
success = true;
|
||||
} else {
|
||||
QMessageBox::warning(parent, tr("Write Failure"),
|
||||
tr("Unable to write log contents to '%1': %2").
|
||||
arg(fileName, file.errorString()));
|
||||
}
|
||||
}
|
||||
return success;
|
||||
}
|
||||
|
||||
@@ -60,6 +60,7 @@
|
||||
#include <projectexplorer/projectexplorer.h>
|
||||
#include <projectexplorer/session.h>
|
||||
#include <utils/qtcassert.h>
|
||||
#include <utils/fileutils.h>
|
||||
|
||||
#include <QtDesigner/QDesignerFormWindowInterface>
|
||||
#include <QtDesigner/QDesignerFormEditorInterface>
|
||||
@@ -488,9 +489,9 @@ static Document::Ptr getParsedDocument(const QString &fileName, CppModelManagerI
|
||||
if (workingCopy.contains(fileName)) {
|
||||
src = workingCopy.source(fileName);
|
||||
} else {
|
||||
QFile file(fileName);
|
||||
if (file.open(QFile::ReadOnly))
|
||||
src = QTextStream(&file).readAll(); // ### FIXME
|
||||
Utils::FileReader reader;
|
||||
if (reader.fetch(fileName)) // ### FIXME error reporting
|
||||
src = QString::fromLocal8Bit(reader.data()); // ### FIXME encoding
|
||||
}
|
||||
|
||||
QByteArray source = snapshot.preprocessedCode(src, fileName);
|
||||
|
||||
@@ -45,6 +45,7 @@
|
||||
#include <extensionsystem/pluginmanager.h>
|
||||
#include <utils/pathchooser.h>
|
||||
#include <utils/qtcassert.h>
|
||||
#include <utils/fileutils.h>
|
||||
#include <coreplugin/icore.h>
|
||||
#include <coreplugin/icontext.h>
|
||||
|
||||
@@ -141,15 +142,15 @@ static QStringList readLines(const QString &absoluteFileName)
|
||||
bool GenericProject::saveRawFileList(const QStringList &rawFileList)
|
||||
{
|
||||
// Make sure we can open the file for writing
|
||||
QFile file(filesFileName());
|
||||
if (!file.open(QIODevice::WriteOnly | QIODevice::Text))
|
||||
return false;
|
||||
|
||||
QTextStream stream(&file);
|
||||
Utils::FileSaver saver(filesFileName(), QIODevice::Text);
|
||||
if (!saver.hasError()) {
|
||||
QTextStream stream(saver.file());
|
||||
foreach (const QString &filePath, rawFileList)
|
||||
stream << filePath << QLatin1Char('\n');
|
||||
|
||||
file.close();
|
||||
saver.setResult(&stream);
|
||||
}
|
||||
if (!saver.finalize(Core::ICore::instance()->mainWindow()))
|
||||
return false;
|
||||
refresh(GenericProject::Files);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -55,6 +55,7 @@
|
||||
#include <utils/qtcprocess.h>
|
||||
#include <utils/synchronousprocess.h>
|
||||
#include <utils/environment.h>
|
||||
#include <utils/fileutils.h>
|
||||
#include <vcsbase/vcsbaseeditor.h>
|
||||
#include <vcsbase/vcsbaseoutputwindow.h>
|
||||
#include <vcsbase/vcsbaseplugin.h>
|
||||
@@ -1784,9 +1785,10 @@ bool GitClient::getCommitData(const QString &workingDirectory,
|
||||
// Read description
|
||||
const QString descriptionFile = gitDir.absoluteFilePath(QLatin1String("description"));
|
||||
if (QFileInfo(descriptionFile).isFile()) {
|
||||
QFile file(descriptionFile);
|
||||
if (file.open(QIODevice::ReadOnly|QIODevice::Text))
|
||||
commitData->panelInfo.description = commandOutputFromLocal8Bit(file.readAll()).trimmed();
|
||||
Utils::FileReader reader;
|
||||
if (!reader.fetch(descriptionFile, QIODevice::Text, errorMessage))
|
||||
return false;
|
||||
commitData->panelInfo.description = commandOutputFromLocal8Bit(reader.data()).trimmed();
|
||||
}
|
||||
|
||||
// Run status. Note that it has exitcode 1 if there are no added files.
|
||||
@@ -1868,14 +1870,10 @@ bool GitClient::getCommitData(const QString &workingDirectory,
|
||||
const QFileInfo templateFileInfo(templateFilename);
|
||||
if (templateFileInfo.isRelative())
|
||||
templateFilename = repoDirectory + QLatin1Char('/') + templateFilename;
|
||||
QFile templateFile(templateFilename);
|
||||
if (templateFile.open(QIODevice::ReadOnly|QIODevice::Text)) {
|
||||
*commitTemplate = QString::fromLocal8Bit(templateFile.readAll());
|
||||
} else {
|
||||
qWarning("Unable to read commit template %s: %s",
|
||||
qPrintable(templateFilename),
|
||||
qPrintable(templateFile.errorString()));
|
||||
}
|
||||
Utils::FileReader reader;
|
||||
if (!reader.fetch(templateFilename, QIODevice::Text, errorMessage))
|
||||
return false;
|
||||
*commitTemplate = QString::fromLocal8Bit(reader.data());
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
||||
@@ -58,6 +58,7 @@
|
||||
|
||||
#include <utils/qtcassert.h>
|
||||
#include <utils/parameteraction.h>
|
||||
#include <utils/fileutils.h>
|
||||
|
||||
#include <vcsbase/basevcseditorfactory.h>
|
||||
#include <vcsbase/vcsbaseeditor.h>
|
||||
@@ -693,18 +694,15 @@ void GitPlugin::startCommit(bool amend)
|
||||
qDebug() << Q_FUNC_INFO << data << commitTemplate;
|
||||
|
||||
// Start new temp file with message template
|
||||
QTemporaryFile changeTmpFile;
|
||||
changeTmpFile.setAutoRemove(false);
|
||||
if (!changeTmpFile.open()) {
|
||||
VCSBase::VCSBaseOutputWindow::instance()->append(tr("Cannot create temporary file: %1").arg(changeTmpFile.errorString()));
|
||||
Utils::TempFileSaver saver;
|
||||
// Keep the file alive, else it removes self and forgets its name
|
||||
saver.setAutoRemove(false);
|
||||
saver.write(commitTemplate.toLocal8Bit());
|
||||
if (!saver.finalize()) {
|
||||
VCSBase::VCSBaseOutputWindow::instance()->append(saver.errorString());
|
||||
return;
|
||||
}
|
||||
m_commitMessageFileName = changeTmpFile.fileName();
|
||||
changeTmpFile.write(commitTemplate.toLocal8Bit());
|
||||
changeTmpFile.flush();
|
||||
// Keep the file alive, else it removes self and forgets
|
||||
// its name
|
||||
changeTmpFile.close();
|
||||
m_commitMessageFileName = saver.fileName();
|
||||
openSubmitEditor(m_commitMessageFileName, data, amend);
|
||||
}
|
||||
|
||||
|
||||
@@ -43,6 +43,8 @@
|
||||
#include <coreplugin/helpmanager.h>
|
||||
#include <coreplugin/icore.h>
|
||||
|
||||
#include <utils/fileutils.h>
|
||||
|
||||
#include <QtCore/QCoreApplication>
|
||||
#include <QtCore/QSettings>
|
||||
#include <QtCore/QTextStream>
|
||||
@@ -267,10 +269,15 @@ void GeneralSettingsPage::exportBookmarks()
|
||||
if (!fileName.endsWith(suffix))
|
||||
fileName.append(suffix);
|
||||
|
||||
QFile file(fileName);
|
||||
if (file.open(QIODevice::WriteOnly)) {
|
||||
Utils::FileSaver saver(fileName);
|
||||
if (!saver.hasError()) {
|
||||
XbelWriter writer(LocalHelpManager::bookmarkManager().treeBookmarkModel());
|
||||
writer.writeToFile(&file);
|
||||
writer.writeToFile(saver.file());
|
||||
saver.setResult(&writer);
|
||||
}
|
||||
if (!saver.finalize()) {
|
||||
m_ui->errorLabel->setVisible(true);
|
||||
m_ui->errorLabel->setText(saver.errorString());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -34,13 +34,18 @@
|
||||
#include "helpconstants.h"
|
||||
#include "localhelpmanager.h"
|
||||
|
||||
#include <coreplugin/icore.h>
|
||||
|
||||
#include <utils/fileutils.h>
|
||||
|
||||
#include <QtCore/QFileInfo>
|
||||
#include <QtCore/QStringBuilder>
|
||||
#include <QtCore/QTemporaryFile>
|
||||
#include <QtCore/QDir>
|
||||
#include <QtCore/QUrl>
|
||||
|
||||
#include <QtGui/QApplication>
|
||||
#include <QtGui/QDesktopServices>
|
||||
#include <QtGui/QMainWindow>
|
||||
#include <QtGui/QMouseEvent>
|
||||
|
||||
#include <QtHelp/QHelpEngine>
|
||||
@@ -131,19 +136,12 @@ bool HelpViewer::launchWithExternalApp(const QUrl &url)
|
||||
|
||||
const QString& path = resolvedUrl.path();
|
||||
if (!canOpenPage(path)) {
|
||||
QTemporaryFile tmpTmpFile;
|
||||
if (!tmpTmpFile.open())
|
||||
return false;
|
||||
|
||||
const QString &extension = QFileInfo(path).completeSuffix();
|
||||
QFile actualTmpFile(tmpTmpFile.fileName() % QLatin1String(".")
|
||||
% extension);
|
||||
if (!actualTmpFile.open(QIODevice::ReadWrite | QIODevice::Truncate))
|
||||
return false;
|
||||
|
||||
actualTmpFile.write(helpEngine.fileData(resolvedUrl));
|
||||
actualTmpFile.close();
|
||||
return QDesktopServices::openUrl(QUrl(actualTmpFile.fileName()));
|
||||
Utils::TempFileSaver saver(QDir::tempPath()
|
||||
+ QLatin1String("/qtchelp_XXXXXX.") + QFileInfo(path).completeSuffix());
|
||||
if (!saver.hasError())
|
||||
saver.write(helpEngine.fileData(resolvedUrl));
|
||||
if (saver.finalize(Core::ICore::instance()->mainWindow()))
|
||||
return QDesktopServices::openUrl(QUrl(saver.fileName()));
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
||||
@@ -35,6 +35,8 @@
|
||||
|
||||
#include <coreplugin/coreconstants.h>
|
||||
|
||||
#include <utils/fileutils.h>
|
||||
|
||||
#include <QtCore/QFileInfo>
|
||||
#include <QtCore/QDataStream>
|
||||
|
||||
@@ -101,10 +103,10 @@ Macro& Macro::operator=(const Macro &other)
|
||||
return *this;
|
||||
}
|
||||
|
||||
void Macro::load(QString fileName)
|
||||
bool Macro::load(QString fileName)
|
||||
{
|
||||
if (d->events.count())
|
||||
return; // the macro is not empty
|
||||
return true; // the macro is not empty
|
||||
|
||||
// Take the current filename if the parameter is null
|
||||
if (fileName.isNull())
|
||||
@@ -123,10 +125,12 @@ void Macro::load(QString fileName)
|
||||
macroEvent.load(stream);
|
||||
append(macroEvent);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void Macro::loadHeader(const QString &fileName)
|
||||
bool Macro::loadHeader(const QString &fileName)
|
||||
{
|
||||
d->fileName = fileName;
|
||||
QFile file(fileName);
|
||||
@@ -134,21 +138,27 @@ void Macro::loadHeader(const QString &fileName)
|
||||
QDataStream stream(&file);
|
||||
stream >> d->version;
|
||||
stream >> d->description;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void Macro::save(const QString &fileName)
|
||||
bool Macro::save(const QString &fileName, QWidget *parent)
|
||||
{
|
||||
QFile file(fileName);
|
||||
if (file.open(QFile::WriteOnly)) {
|
||||
QDataStream stream(&file);
|
||||
Utils::FileSaver saver(fileName);
|
||||
if (!saver.hasError()) {
|
||||
QDataStream stream(saver.file());
|
||||
stream << d->version;
|
||||
stream << d->description;
|
||||
foreach (const MacroEvent &event, d->events) {
|
||||
event.save(stream);
|
||||
}
|
||||
d->fileName = fileName;
|
||||
saver.setResult(&stream);
|
||||
}
|
||||
if (!saver.finalize(parent))
|
||||
return false;
|
||||
d->fileName = fileName;
|
||||
return true;
|
||||
}
|
||||
|
||||
QString Macro::displayName() const
|
||||
|
||||
@@ -38,6 +38,10 @@
|
||||
#include <QtCore/QList>
|
||||
#include <QtCore/QString>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
class QWidget;
|
||||
QT_END_NAMESPACE
|
||||
|
||||
namespace Macros {
|
||||
|
||||
class MacroEvent;
|
||||
@@ -50,9 +54,9 @@ public:
|
||||
~Macro();
|
||||
Macro& operator=(const Macro& other);
|
||||
|
||||
void load(QString fileName = QString());
|
||||
void loadHeader(const QString &fileName);
|
||||
void save(const QString &fileName);
|
||||
bool load(QString fileName = QString());
|
||||
bool loadHeader(const QString &fileName);
|
||||
bool save(const QString &fileName, QWidget *parent);
|
||||
|
||||
const QString &description() const;
|
||||
void setDescription(const QString &text);
|
||||
|
||||
@@ -152,8 +152,10 @@ void MacroManager::MacroManagerPrivate::initialize()
|
||||
foreach (const QString &name, files) {
|
||||
QString fileName = dir.absolutePath() + '/' + name;
|
||||
Macro *macro = new Macro;
|
||||
macro->loadHeader(fileName);
|
||||
if (macro->loadHeader(fileName))
|
||||
addMacro(macro);
|
||||
else
|
||||
delete macro;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -190,9 +192,10 @@ void MacroManager::MacroManagerPrivate::removeMacro(const QString &name)
|
||||
|
||||
void MacroManager::MacroManagerPrivate::changeMacroDescription(Macro *macro, const QString &description)
|
||||
{
|
||||
macro->load();
|
||||
if (!macro->load())
|
||||
return;
|
||||
macro->setDescription(description);
|
||||
macro->save(macro->fileName());
|
||||
macro->save(macro->fileName(), Core::ICore::instance()->mainWindow());
|
||||
|
||||
// Change shortcut what's this
|
||||
Core::ICore *core = Core::ICore::instance();
|
||||
@@ -205,9 +208,10 @@ void MacroManager::MacroManagerPrivate::changeMacroDescription(Macro *macro, con
|
||||
|
||||
bool MacroManager::MacroManagerPrivate::executeMacro(Macro *macro)
|
||||
{
|
||||
macro->load();
|
||||
bool error = false;
|
||||
bool error = !macro->load();
|
||||
foreach (const MacroEvent ¯oEvent, macro->events()) {
|
||||
if (error)
|
||||
break;
|
||||
foreach (IMacroHandler *handler, handlers) {
|
||||
if (handler->canExecuteEvent(macroEvent)) {
|
||||
if (!handler->executeEvent(macroEvent))
|
||||
@@ -215,8 +219,6 @@ bool MacroManager::MacroManagerPrivate::executeMacro(Macro *macro)
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (error)
|
||||
break;
|
||||
}
|
||||
|
||||
if (error) {
|
||||
@@ -246,7 +248,7 @@ void MacroManager::MacroManagerPrivate::showSaveDialog()
|
||||
QString fileName = q->macrosDirectory() + '/' + dialog.name()
|
||||
+ '.' + Constants::M_EXTENSION;
|
||||
currentMacro->setDescription(dialog.description());
|
||||
currentMacro->save(fileName);
|
||||
currentMacro->save(fileName, mainWindow);
|
||||
addMacro(currentMacro);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -45,6 +45,7 @@
|
||||
#include <projectexplorer/projectnodes.h>
|
||||
|
||||
#include <utils/pathchooser.h>
|
||||
#include <utils/fileutils.h>
|
||||
#include <utils/qtcassert.h>
|
||||
|
||||
#include <QtCore/QFile>
|
||||
@@ -187,13 +188,12 @@ void SuppressionDialog::accept()
|
||||
QTC_ASSERT(!path.isEmpty(), return);
|
||||
QTC_ASSERT(!m_ui->suppressionEdit->toPlainText().trimmed().isEmpty(), return);
|
||||
|
||||
QFile file(path);
|
||||
bool opened = file.open(QIODevice::WriteOnly | QIODevice::Append);
|
||||
QTC_ASSERT(opened, return);
|
||||
|
||||
QTextStream stream(&file);
|
||||
Utils::FileSaver saver(path, QIODevice::Append);
|
||||
QTextStream stream(saver.file());
|
||||
stream << m_ui->suppressionEdit->toPlainText();
|
||||
file.close();
|
||||
saver.setResult(&stream);
|
||||
if (!saver.finalize(this))
|
||||
return;
|
||||
|
||||
// add file to project (if there is a project that contains this file on the file system)
|
||||
ProjectExplorer::SessionManager *session = ProjectExplorer::ProjectExplorerPlugin::instance()->session();
|
||||
|
||||
@@ -39,6 +39,7 @@
|
||||
#include <vcsbase/vcsbaseeditorparameterwidget.h>
|
||||
#include <vcsbase/vcsjobrunner.h>
|
||||
#include <utils/synchronousprocess.h>
|
||||
#include <utils/fileutils.h>
|
||||
#include <utils/qtcassert.h>
|
||||
|
||||
#include <QtCore/QDir>
|
||||
@@ -105,10 +106,12 @@ bool MercurialClient::synchronousClone(const QString &workingDir,
|
||||
}
|
||||
|
||||
// By now, there is no hgrc file -> create it
|
||||
QFile hgrc(workingDirectory.path()+"/.hg/hgrc");
|
||||
hgrc.open(QIODevice::WriteOnly);
|
||||
hgrc.write(QString("[paths]\ndefault = %1\n").arg(dstLocation).toUtf8());
|
||||
hgrc.close();
|
||||
Utils::FileSaver saver(workingDirectory.path()+"/.hg/hgrc");
|
||||
saver.write(QString("[paths]\ndefault = %1\n").arg(dstLocation).toUtf8());
|
||||
if (!saver.finalize()) {
|
||||
VCSBase::VCSBaseOutputWindow::instance()->appendError(saver.errorString());
|
||||
return false;
|
||||
}
|
||||
|
||||
// And last update repository
|
||||
arguments.clear();
|
||||
|
||||
@@ -55,6 +55,7 @@
|
||||
#include <utils/qtcassert.h>
|
||||
#include <utils/synchronousprocess.h>
|
||||
#include <utils/parameteraction.h>
|
||||
#include <utils/fileutils.h>
|
||||
#include <vcsbase/basevcseditorfactory.h>
|
||||
#include <vcsbase/basevcssubmiteditorfactory.h>
|
||||
#include <vcsbase/vcsbaseeditor.h>
|
||||
@@ -66,7 +67,6 @@
|
||||
#include <QtCore/QDir>
|
||||
#include <QtCore/QFileInfo>
|
||||
#include <QtCore/QSettings>
|
||||
#include <QtCore/QTemporaryFile>
|
||||
#include <QtCore/QTextCodec>
|
||||
|
||||
#include <QtGui/QAction>
|
||||
@@ -625,13 +625,6 @@ void PerforcePlugin::startSubmitProject()
|
||||
const VCSBase::VCSBasePluginState state = currentState();
|
||||
QTC_ASSERT(state.hasProject(), return)
|
||||
|
||||
QTemporaryFile changeTmpFile;
|
||||
changeTmpFile.setAutoRemove(false);
|
||||
if (!changeTmpFile.open()) {
|
||||
VCSBase::VCSBaseOutputWindow::instance()->appendError(tr("Cannot create temporary file."));
|
||||
cleanCommitMessageFile();
|
||||
return;
|
||||
}
|
||||
// Revert all unchanged files.
|
||||
if (!revertProject(state.currentProjectTopLevel(), perforceRelativeProjectDirectory(state), true))
|
||||
return;
|
||||
@@ -646,9 +639,15 @@ void PerforcePlugin::startSubmitProject()
|
||||
return;
|
||||
}
|
||||
|
||||
m_commitMessageFileName = changeTmpFile.fileName();
|
||||
changeTmpFile.write(result.stdOut.toAscii());
|
||||
changeTmpFile.close();
|
||||
Utils::TempFileSaver saver;
|
||||
saver.setAutoRemove(false);
|
||||
saver.write(result.stdOut.toAscii());
|
||||
if (!saver.finalize()) {
|
||||
VCSBase::VCSBaseOutputWindow::instance()->appendError(saver.errorString());
|
||||
cleanCommitMessageFile();
|
||||
return;
|
||||
}
|
||||
m_commitMessageFileName = saver.fileName();
|
||||
|
||||
args.clear();
|
||||
args << QLatin1String("fstat");
|
||||
@@ -949,11 +948,12 @@ bool PerforcePlugin::vcsMove(const QString &workingDir, const QString &from, con
|
||||
}
|
||||
|
||||
// Write extra args to temporary file
|
||||
QSharedPointer<QTemporaryFile>
|
||||
PerforcePlugin::createTemporaryArgumentFile(const QStringList &extraArgs) const
|
||||
QSharedPointer<Utils::TempFileSaver>
|
||||
PerforcePlugin::createTemporaryArgumentFile(const QStringList &extraArgs,
|
||||
QString *errorString) const
|
||||
{
|
||||
if (extraArgs.isEmpty())
|
||||
return QSharedPointer<QTemporaryFile>();
|
||||
return QSharedPointer<Utils::TempFileSaver>();
|
||||
// create pattern
|
||||
if (m_tempFilePattern.isEmpty()) {
|
||||
m_tempFilePattern = QDir::tempPath();
|
||||
@@ -961,20 +961,16 @@ QSharedPointer<QTemporaryFile>
|
||||
m_tempFilePattern += QDir::separator();
|
||||
m_tempFilePattern += QLatin1String("qtc_p4_XXXXXX.args");
|
||||
}
|
||||
QSharedPointer<QTemporaryFile> rc(new QTemporaryFile(m_tempFilePattern));
|
||||
QSharedPointer<Utils::TempFileSaver> rc(new Utils::TempFileSaver(m_tempFilePattern));
|
||||
rc->setAutoRemove(true);
|
||||
if (!rc->open()) {
|
||||
qWarning("Could not create temporary file: %s. Appending all file names to command line.",
|
||||
qPrintable(rc->errorString()));
|
||||
return QSharedPointer<QTemporaryFile>();
|
||||
}
|
||||
const int last = extraArgs.size() - 1;
|
||||
for (int i = 0; i <= last; i++) {
|
||||
rc->write(extraArgs.at(i).toLocal8Bit());
|
||||
if (i != last)
|
||||
rc->write("\n");
|
||||
rc->write("\n", 1);
|
||||
}
|
||||
rc->close();
|
||||
if (!rc->finalize(errorString))
|
||||
return QSharedPointer<Utils::TempFileSaver>();
|
||||
return rc;
|
||||
}
|
||||
|
||||
@@ -1153,9 +1149,16 @@ PerforceResponse PerforcePlugin::runP4Cmd(const QString &workingDir,
|
||||
return invalidConfigResponse;
|
||||
}
|
||||
QStringList actualArgs = m_settings.commonP4Arguments(workingDir);
|
||||
QSharedPointer<QTemporaryFile> tempFile = createTemporaryArgumentFile(extraArgs);
|
||||
if (!tempFile.isNull())
|
||||
QString errorMessage;
|
||||
QSharedPointer<Utils::TempFileSaver> tempFile = createTemporaryArgumentFile(extraArgs, &errorMessage);
|
||||
if (!tempFile.isNull()) {
|
||||
actualArgs << QLatin1String("-x") << tempFile->fileName();
|
||||
} else if (!errorMessage.isEmpty()) {
|
||||
PerforceResponse tempFailResponse;
|
||||
tempFailResponse.error = true;
|
||||
tempFailResponse.message = errorMessage;
|
||||
return tempFailResponse;
|
||||
}
|
||||
actualArgs.append(args);
|
||||
|
||||
if (flags & CommandToWindow)
|
||||
@@ -1372,19 +1375,17 @@ bool PerforcePlugin::submitEditorAboutToClose(VCSBase::VCSBaseSubmitEditor *subm
|
||||
return true;
|
||||
}
|
||||
// Pipe file into p4 submit -i
|
||||
QFile commitMessageFile(m_commitMessageFileName);
|
||||
if (!commitMessageFile.open(QIODevice::ReadOnly|QIODevice::Text)) {
|
||||
VCSBase::VCSBaseOutputWindow::instance()->appendError(tr("Cannot open temporary file."));
|
||||
Utils::FileReader reader;
|
||||
if (!reader.fetch(m_commitMessageFileName, QIODevice::Text)) {
|
||||
VCSBase::VCSBaseOutputWindow::instance()->appendError(reader.errorString());
|
||||
return false;
|
||||
}
|
||||
|
||||
const QByteArray changeDescription = commitMessageFile.readAll();
|
||||
commitMessageFile.close();
|
||||
QStringList submitArgs;
|
||||
submitArgs << QLatin1String("submit") << QLatin1String("-i");
|
||||
const PerforceResponse submitResponse = runP4Cmd(m_settings.topLevelSymLinkTarget(), submitArgs,
|
||||
LongTimeOut|RunFullySynchronous|CommandToWindow|StdErrToWindow|ErrorToWindow|ShowBusyCursor,
|
||||
QStringList(), changeDescription);
|
||||
QStringList(), reader.data());
|
||||
if (submitResponse.error) {
|
||||
VCSBase::VCSBaseOutputWindow::instance()->appendError(tr("p4 submit failed: %1").arg(submitResponse.message));
|
||||
return false;
|
||||
|
||||
@@ -54,6 +54,7 @@ QT_END_NAMESPACE
|
||||
|
||||
namespace Utils {
|
||||
class ParameterAction;
|
||||
class TempFileSaver;
|
||||
}
|
||||
|
||||
namespace Locator {
|
||||
@@ -190,7 +191,8 @@ private:
|
||||
bool enableAnnotationContextMenu = false);
|
||||
void cleanCommitMessageFile();
|
||||
bool isCommitEditorOpen() const;
|
||||
QSharedPointer<QTemporaryFile> createTemporaryArgumentFile(const QStringList &extraArgs) const;
|
||||
QSharedPointer<Utils::TempFileSaver> createTemporaryArgumentFile(const QStringList &extraArgs,
|
||||
QString *errorString) const;
|
||||
void getTopLevel();
|
||||
QString pendingChangesData();
|
||||
|
||||
|
||||
@@ -40,6 +40,7 @@
|
||||
#include <coreplugin/icore.h>
|
||||
#include <coreplugin/messagemanager.h>
|
||||
#include <extensionsystem/pluginmanager.h>
|
||||
#include <utils/fileutils.h>
|
||||
#include <utils/qtcassert.h>
|
||||
|
||||
#include <QtCore/QDebug>
|
||||
@@ -182,23 +183,19 @@ static inline bool createFile(Internal::CustomWizardFile cwFile,
|
||||
// Read contents of source file
|
||||
const QFile::OpenMode openMode
|
||||
= cwFile.binary ? QIODevice::ReadOnly : (QIODevice::ReadOnly|QIODevice::Text);
|
||||
QFile file(sourcePath);
|
||||
if (!file.open(openMode)) {
|
||||
*errorMessage = QString::fromLatin1("Cannot open %1: %2").arg(sourcePath, file.errorString());
|
||||
Utils::FileReader reader;
|
||||
if (!reader.fetch(sourcePath, openMode, errorMessage))
|
||||
return false;
|
||||
}
|
||||
const QByteArray contentData = file.readAll();
|
||||
file.close();
|
||||
|
||||
Core::GeneratedFile generatedFile;
|
||||
generatedFile.setPath(targetPath);
|
||||
if (cwFile.binary) {
|
||||
// Binary file: Set data.
|
||||
generatedFile.setBinary(true);
|
||||
generatedFile.setBinaryContents(contentData);
|
||||
generatedFile.setBinaryContents(reader.data());
|
||||
} else {
|
||||
// Template file: Preprocess.
|
||||
const QString contentsIn = QString::fromLocal8Bit(contentData);
|
||||
const QString contentsIn = QString::fromLocal8Bit(reader.data());
|
||||
generatedFile.setContents(Internal::CustomWizardContext::processFile(fm, contentsIn));
|
||||
}
|
||||
|
||||
|
||||
@@ -39,6 +39,7 @@
|
||||
#include <projectexplorer/projectexplorer.h>
|
||||
#include <projectexplorer/projectexplorersettings.h>
|
||||
|
||||
#include <utils/fileutils.h>
|
||||
#include <utils/qtcprocess.h>
|
||||
#include <utils/qtcassert.h>
|
||||
#include <utils/synchronousprocess.h>
|
||||
@@ -176,16 +177,11 @@ static QByteArray msvcPredefinedMacros(const Utils::Environment &env)
|
||||
"#define __ptr32\n"
|
||||
"#define __ptr64\n";
|
||||
|
||||
QString tmpFilePath;
|
||||
{
|
||||
// QTemporaryFile is buggy and will not unlock the file for cl.exe
|
||||
QTemporaryFile tmpFile(QDir::tempPath()+"/envtestXXXXXX.cpp");
|
||||
tmpFile.setAutoRemove(false);
|
||||
if (!tmpFile.open())
|
||||
Utils::TempFileSaver saver(QDir::tempPath()+"/envtestXXXXXX.cpp");
|
||||
saver.write(msvcCompilationFile());
|
||||
if (!saver.finalize()) {
|
||||
qWarning("%s: %s", Q_FUNC_INFO, qPrintable(saver.errorString()));
|
||||
return predefinedMacros;
|
||||
tmpFilePath = QFileInfo(tmpFile).canonicalFilePath();
|
||||
tmpFile.write(msvcCompilationFile());
|
||||
tmpFile.close();
|
||||
}
|
||||
QProcess cpp;
|
||||
cpp.setEnvironment(env.toStringList());
|
||||
@@ -197,7 +193,7 @@ static QByteArray msvcPredefinedMacros(const Utils::Environment &env)
|
||||
return predefinedMacros;
|
||||
}
|
||||
|
||||
arguments << QLatin1String("/EP") << QDir::toNativeSeparators(tmpFilePath);
|
||||
arguments << QLatin1String("/EP") << QDir::toNativeSeparators(saver.fileName());
|
||||
cpp.start(binary, arguments);
|
||||
if (!cpp.waitForStarted()) {
|
||||
qWarning("%s: Cannot start '%s': %s", Q_FUNC_INFO, qPrintable(binary),
|
||||
@@ -231,7 +227,6 @@ static QByteArray msvcPredefinedMacros(const Utils::Environment &env)
|
||||
predefinedMacros += '\n';
|
||||
}
|
||||
}
|
||||
QFile::remove(tmpFilePath);
|
||||
if (debug)
|
||||
qDebug() << "msvcPredefinedMacros" << predefinedMacros;
|
||||
return predefinedMacros;
|
||||
@@ -269,13 +264,7 @@ static Utils::Environment msvcReadEnvironmentSetting(const QString &varsBat,
|
||||
return result;
|
||||
|
||||
const QString tempOutputFileName = QDir::tempPath() + QLatin1String("\\qtcreator-msvc-environment.txt");
|
||||
QTemporaryFile tf(QDir::tempPath() + "\\XXXXXX.bat");
|
||||
tf.setAutoRemove(true);
|
||||
if (!tf.open())
|
||||
return result;
|
||||
|
||||
const QString filename = tf.fileName();
|
||||
|
||||
Utils::TempFileSaver saver(QDir::tempPath() + "\\XXXXXX.bat");
|
||||
QByteArray call = "call ";
|
||||
call += Utils::QtcProcess::quoteArg(varsBat).toLocal8Bit();
|
||||
if (!args.isEmpty()) {
|
||||
@@ -283,19 +272,21 @@ static Utils::Environment msvcReadEnvironmentSetting(const QString &varsBat,
|
||||
call += args.toLocal8Bit();
|
||||
}
|
||||
call += "\r\n";
|
||||
tf.write(call);
|
||||
saver.write(call);
|
||||
const QByteArray redirect = "set > " + Utils::QtcProcess::quoteArg(
|
||||
QDir::toNativeSeparators(tempOutputFileName)).toLocal8Bit() + "\r\n";
|
||||
tf.write(redirect);
|
||||
tf.flush();
|
||||
tf.waitForBytesWritten(30000);
|
||||
saver.write(redirect);
|
||||
if (!saver.finalize()) {
|
||||
qWarning("%s: %s", Q_FUNC_INFO, qPrintable(saver.errorString()));
|
||||
return result;
|
||||
}
|
||||
|
||||
Utils::QtcProcess run;
|
||||
run.setEnvironment(env);
|
||||
const QString cmdPath = QString::fromLocal8Bit(qgetenv("COMSPEC"));
|
||||
// Windows SDK setup scripts require command line switches for environment expansion.
|
||||
QString cmdArguments = QLatin1String(" /E:ON /V:ON /c \"");
|
||||
cmdArguments += QDir::toNativeSeparators(filename);
|
||||
cmdArguments += QDir::toNativeSeparators(saver.fileName());
|
||||
cmdArguments += QLatin1Char('"');
|
||||
run.setCommand(cmdPath, cmdArguments);
|
||||
if (debug)
|
||||
@@ -313,7 +304,6 @@ static Utils::Environment msvcReadEnvironmentSetting(const QString &varsBat,
|
||||
Utils::SynchronousProcess::stopProcess(run);
|
||||
return result;
|
||||
}
|
||||
tf.close();
|
||||
|
||||
QFile varsFile(tempOutputFileName);
|
||||
if (!varsFile.open(QIODevice::ReadOnly|QIODevice::Text))
|
||||
|
||||
@@ -34,6 +34,8 @@
|
||||
|
||||
#include <coreplugin/coreconstants.h>
|
||||
|
||||
#include <utils/fileutils.h>
|
||||
|
||||
#include <QtCore/QDebug>
|
||||
#include <QtCore/QFile>
|
||||
#include <QtCore/QVariant>
|
||||
@@ -376,14 +378,13 @@ void PersistentSettingsWriter::saveValue(const QString & variable, const QVarian
|
||||
m_valueMap.insert(variable, value);
|
||||
}
|
||||
|
||||
bool PersistentSettingsWriter::save(const QString & fileName, const QString &docType) const
|
||||
bool PersistentSettingsWriter::save(const QString & fileName, const QString &docType,
|
||||
QWidget *parent) const
|
||||
{
|
||||
QFile file(fileName);
|
||||
if (!file.open(QIODevice::WriteOnly|QIODevice::Text))
|
||||
return false;
|
||||
|
||||
Utils::FileSaver saver(fileName, QIODevice::Text);
|
||||
if (!saver.hasError()) {
|
||||
const Context ctx;
|
||||
QXmlStreamWriter w(&file);
|
||||
QXmlStreamWriter w(saver.file());
|
||||
w.setAutoFormatting(true);
|
||||
w.setAutoFormattingIndent(1); // Historical, used to be QDom.
|
||||
w.writeStartDocument();
|
||||
@@ -400,7 +401,9 @@ bool PersistentSettingsWriter::save(const QString & fileName, const QString &doc
|
||||
w.writeEndElement();
|
||||
}
|
||||
w.writeEndDocument();
|
||||
file.close();
|
||||
return true;
|
||||
|
||||
saver.setResult(&w);
|
||||
}
|
||||
return saver.finalize(parent);
|
||||
}
|
||||
} // namespace ProjectExplorer
|
||||
|
||||
@@ -38,6 +38,10 @@
|
||||
#include <QtCore/QMap>
|
||||
#include <QtCore/QVariant>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
class QWidget;
|
||||
QT_END_NAMESPACE
|
||||
|
||||
namespace ProjectExplorer {
|
||||
|
||||
class PROJECTEXPLORER_EXPORT PersistentSettingsReader
|
||||
@@ -57,7 +61,7 @@ class PROJECTEXPLORER_EXPORT PersistentSettingsWriter
|
||||
public:
|
||||
PersistentSettingsWriter();
|
||||
void saveValue(const QString & variable, const QVariant &value);
|
||||
bool save(const QString & fileName, const QString & docType) const;
|
||||
bool save(const QString &fileName, const QString &docType, QWidget *parent) const;
|
||||
|
||||
private:
|
||||
QMap<QString, QVariant> m_valueMap;
|
||||
|
||||
@@ -279,7 +279,7 @@ bool SessionFile::save()
|
||||
writer.saveValue("valueKeys", keys);
|
||||
|
||||
|
||||
if (writer.save(m_fileName, "QtCreatorSession"))
|
||||
if (writer.save(m_fileName, "QtCreatorSession", Core::ICore::instance()->mainWindow()))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
|
||||
@@ -42,6 +42,7 @@
|
||||
#include <QtCore/QCoreApplication>
|
||||
#include <QtCore/QDir>
|
||||
#include <QtCore/QSettings>
|
||||
#include <QtGui/QMainWindow>
|
||||
|
||||
static const char *const TOOLCHAIN_DATA_KEY = "ToolChain.";
|
||||
static const char *const TOOLCHAIN_COUNT_KEY = "ToolChain.Count";
|
||||
@@ -150,7 +151,7 @@ void ToolChainManager::saveToolChains()
|
||||
}
|
||||
}
|
||||
writer.saveValue(QLatin1String(TOOLCHAIN_COUNT_KEY), count);
|
||||
writer.save(settingsFileName(), "QtCreatorToolChains");
|
||||
writer.save(settingsFileName(), "QtCreatorToolChains", Core::ICore::instance()->mainWindow());
|
||||
|
||||
// Do not save default debuggers! Those are set by the SDK!
|
||||
}
|
||||
|
||||
@@ -527,7 +527,7 @@ bool UserFileAccessor::saveSettings(Project *project, const QVariantMap &map)
|
||||
|
||||
QString fileName = project->property(USERFILE_PROP).toString();
|
||||
return writer.save(fileName.isEmpty() ? fileNameFor(project->file()->fileName()) : fileName,
|
||||
"QtCreatorProject");
|
||||
"QtCreatorProject", Core::ICore::instance()->mainWindow());
|
||||
}
|
||||
|
||||
void UserFileAccessor::addVersionHandler(UserFileVersionHandler *handler)
|
||||
|
||||
@@ -49,16 +49,15 @@
|
||||
#include <formeditorview.h>
|
||||
#include <lineeditaction.h>
|
||||
|
||||
#include <utils/fileutils.h>
|
||||
|
||||
namespace QmlDesigner {
|
||||
|
||||
FormEditorWidget::FormEditorWidget(FormEditorView *view)
|
||||
: QWidget(),
|
||||
m_formEditorView(view)
|
||||
{
|
||||
QFile file(":/qmldesigner/formeditorstylesheet.css");
|
||||
file.open(QFile::ReadOnly);
|
||||
QString styleSheet = QLatin1String(file.readAll());
|
||||
setStyleSheet(styleSheet);
|
||||
setStyleSheet(QLatin1String(Utils::FileReader::fetchQrc(":/qmldesigner/formeditorstylesheet.css")));
|
||||
|
||||
QVBoxLayout *fillLayout = new QVBoxLayout(this);
|
||||
fillLayout->setMargin(0);
|
||||
@@ -152,11 +151,8 @@ FormEditorWidget::FormEditorWidget(FormEditorView *view)
|
||||
m_graphicsView = new FormEditorGraphicsView(this);
|
||||
fillLayout->addWidget(m_graphicsView.data());
|
||||
|
||||
{
|
||||
QFile file(":/qmldesigner/scrollbar.css");
|
||||
file.open(QFile::ReadOnly);
|
||||
m_graphicsView.data()->setStyleSheet(file.readAll());
|
||||
}
|
||||
m_graphicsView.data()->setStyleSheet(
|
||||
QLatin1String(Utils::FileReader::fetchQrc(":/qmldesigner/scrollbar.css")));
|
||||
|
||||
QList<QAction*> lowerActions;
|
||||
|
||||
|
||||
@@ -57,6 +57,8 @@
|
||||
#include <variantproperty.h>
|
||||
#include <rewritingexception.h>
|
||||
|
||||
#include <utils/fileutils.h>
|
||||
|
||||
#include <QtCore/QCoreApplication>
|
||||
#include <QtCore/QDir>
|
||||
#include <QtCore/QFile>
|
||||
@@ -768,27 +770,17 @@ bool DesignDocumentController::save(QWidget *parent)
|
||||
saveAs(parent);
|
||||
return true;
|
||||
}
|
||||
QFile file(m_d->fileName);
|
||||
if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) {
|
||||
showError(tr("Cannot write file: \"%1\".").arg(m_d->fileName), parent);
|
||||
Utils::FileSaver saver(m_d->fileName, QIODevice::Text);
|
||||
if (m_d->model)
|
||||
saver.write(m_d->textEdit->toPlainText().toLatin1());
|
||||
if (!saver.finalize()) {
|
||||
showError(saver.errorString(), parent);
|
||||
return false;
|
||||
}
|
||||
|
||||
QString errorMessage;
|
||||
bool result = save(&file, &errorMessage);
|
||||
if (!result)
|
||||
showError(errorMessage, parent);
|
||||
return result;
|
||||
}
|
||||
|
||||
bool DesignDocumentController::save(QIODevice *device, QString * /*errorMessage*/)
|
||||
{
|
||||
if (m_d->model) {
|
||||
QByteArray data = m_d->textEdit->toPlainText().toLatin1();
|
||||
device->write(data);
|
||||
if (m_d->model)
|
||||
m_d->textEdit->setPlainText(m_d->textEdit->toPlainText()); // clear undo/redo history
|
||||
}
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -136,7 +136,6 @@ private:
|
||||
void attachNodeInstanceView();
|
||||
QWidget *centralWidget() const;
|
||||
class DesignDocumentControllerPrivate *m_d;
|
||||
bool save(QIODevice *device, QString *errorMessage);
|
||||
};
|
||||
|
||||
} // namespace QmlDesigner
|
||||
|
||||
@@ -33,6 +33,7 @@
|
||||
#include "itemlibrarywidget.h"
|
||||
|
||||
#include <utils/filterlineedit.h>
|
||||
#include <utils/fileutils.h>
|
||||
#include <coreplugin/coreconstants.h>
|
||||
#include "itemlibrarycomponents.h"
|
||||
#include "itemlibrarymodel.h"
|
||||
@@ -227,19 +228,9 @@ ItemLibraryWidget::ItemLibraryWidget(QWidget *parent) :
|
||||
setSearchFilter(QString());
|
||||
|
||||
/* style sheets */
|
||||
{
|
||||
QFile file(":/qmldesigner/stylesheet.css");
|
||||
file.open(QFile::ReadOnly);
|
||||
QString styleSheet = QLatin1String(file.readAll());
|
||||
setStyleSheet(styleSheet);
|
||||
}
|
||||
|
||||
{
|
||||
QFile file(":/qmldesigner/scrollbar.css");
|
||||
file.open(QFile::ReadOnly);
|
||||
QString styleSheet = QLatin1String(file.readAll());
|
||||
m_d->m_resourcesView->setStyleSheet(styleSheet);
|
||||
}
|
||||
setStyleSheet(QLatin1String(Utils::FileReader::fetchQrc(":/qmldesigner/stylesheet.css")));
|
||||
m_d->m_resourcesView->setStyleSheet(
|
||||
QLatin1String(Utils::FileReader::fetchQrc(":/qmldesigner/scrollbar.css")));
|
||||
}
|
||||
|
||||
ItemLibraryWidget::~ItemLibraryWidget()
|
||||
|
||||
@@ -33,11 +33,12 @@
|
||||
#include <QtGui/QBoxLayout>
|
||||
#include <QtGui/QTreeView>
|
||||
#include <QtGui/QHeaderView>
|
||||
#include <QFile>
|
||||
#include <model.h>
|
||||
|
||||
#include "navigatorwidget.h"
|
||||
|
||||
#include <utils/fileutils.h>
|
||||
|
||||
|
||||
namespace QmlDesigner {
|
||||
|
||||
@@ -63,17 +64,9 @@ NavigatorWidget::NavigatorWidget(QWidget* parent) :
|
||||
|
||||
setWindowTitle(tr("Navigator", "Title of navigator view"));
|
||||
|
||||
{
|
||||
QFile file(":/qmldesigner/stylesheet.css");
|
||||
file.open(QFile::ReadOnly);
|
||||
setStyleSheet(file.readAll());
|
||||
}
|
||||
|
||||
{
|
||||
QFile file(":/qmldesigner/scrollbar.css");
|
||||
file.open(QFile::ReadOnly);
|
||||
m_treeView->setStyleSheet(file.readAll());
|
||||
}
|
||||
setStyleSheet(QLatin1String(Utils::FileReader::fetchQrc(":/qmldesigner/stylesheet.css")));
|
||||
m_treeView->setStyleSheet(
|
||||
QLatin1String(Utils::FileReader::fetchQrc(":/qmldesigner/scrollbar.css")));
|
||||
}
|
||||
|
||||
NavigatorWidget::~NavigatorWidget()
|
||||
|
||||
@@ -31,6 +31,7 @@
|
||||
**************************************************************************/
|
||||
|
||||
#include "basicwidgets.h"
|
||||
#include <utils/fileutils.h>
|
||||
#include <qlayoutobject.h>
|
||||
#include <QDeclarativeContext>
|
||||
#include <QDeclarativeEngine>
|
||||
@@ -442,13 +443,11 @@ public:
|
||||
fileName = (QLatin1Char(':') + _styleSheetFile.toLocalFile().split(QLatin1Char(':')).last()); //try if it is a resource
|
||||
else
|
||||
fileName = (_styleSheetFile.toLocalFile());
|
||||
QFile file(fileName);
|
||||
if (file.open(QIODevice::ReadOnly)) {
|
||||
QString styleSheet(file.readAll());
|
||||
q->setStyleSheet(styleSheet);
|
||||
} else {
|
||||
qWarning() << QString::fromLatin1("setStyleSheetFile: %1: %2").arg(fileName, file.errorString());
|
||||
}
|
||||
Utils::FileReader reader;
|
||||
if (reader.fetch(fileName))
|
||||
q->setStyleSheet(QString::fromLatin1(reader.data()));
|
||||
else
|
||||
qWarning() << QString::fromLatin1("setStyleSheetFile: %1").arg(reader.errorString());
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -59,6 +59,8 @@
|
||||
#include "propertyeditortransaction.h"
|
||||
#include "originwidget.h"
|
||||
|
||||
#include <utils/fileutils.h>
|
||||
|
||||
#include <QtCore/QCoreApplication>
|
||||
#include <QtCore/QDir>
|
||||
#include <QtCore/QFileSystemWatcher>
|
||||
@@ -278,10 +280,8 @@ PropertyEditor::PropertyEditor(QWidget *parent) :
|
||||
m_updateShortcut = new QShortcut(QKeySequence("F5"), m_stackedWidget);
|
||||
connect(m_updateShortcut, SIGNAL(activated()), this, SLOT(reloadQml()));
|
||||
|
||||
QFile file(":/qmldesigner/stylesheet.css");
|
||||
file.open(QFile::ReadOnly);
|
||||
QString styleSheet = QLatin1String(file.readAll());
|
||||
m_stackedWidget->setStyleSheet(styleSheet);
|
||||
m_stackedWidget->setStyleSheet(
|
||||
QLatin1String(Utils::FileReader::fetchQrc(":/qmldesigner/stylesheet.css")));
|
||||
m_stackedWidget->setMinimumWidth(300);
|
||||
m_stackedWidget->move(0, 0);
|
||||
connect(m_stackedWidget, SIGNAL(resized()), this, SLOT(updateSize()));
|
||||
|
||||
@@ -56,6 +56,7 @@
|
||||
#include <extensionsystem/pluginmanager.h>
|
||||
|
||||
#include <utils/parameteraction.h>
|
||||
#include <utils/fileutils.h>
|
||||
#include <utils/qtcassert.h>
|
||||
|
||||
#include <QtCore/QSettings>
|
||||
@@ -634,17 +635,10 @@ void DesignModeWidget::setup()
|
||||
}
|
||||
|
||||
if (navigationView.widget)
|
||||
{
|
||||
QFile file(":/qmldesigner/stylesheet.css");
|
||||
file.open(QFile::ReadOnly);
|
||||
QFile file2(":/qmldesigner/scrollbar.css");
|
||||
file2.open(QFile::ReadOnly);
|
||||
|
||||
QString labelStyle = QLatin1String("QLabel { background-color: #4f4f4f; }");
|
||||
|
||||
QString styleSheet = file.readAll() + file2.readAll() + labelStyle;
|
||||
navigationView.widget->setStyleSheet(styleSheet);
|
||||
}
|
||||
navigationView.widget->setStyleSheet(QLatin1String(
|
||||
Utils::FileReader::fetchQrc(":/qmldesigner/stylesheet.css")
|
||||
+ Utils::FileReader::fetchQrc(":/qmldesigner/scrollbar.css")
|
||||
+ "QLabel { background-color: #4f4f4f; }"));
|
||||
}
|
||||
|
||||
m_nodeInstanceView = new NodeInstanceView(this);
|
||||
|
||||
@@ -32,6 +32,8 @@
|
||||
|
||||
#include "styledoutputpaneplaceholder.h"
|
||||
|
||||
#include <utils/fileutils.h>
|
||||
|
||||
#include <QtCore/QChildEvent>
|
||||
#include <QtCore/QFile>
|
||||
#include <QtGui/QTabWidget>
|
||||
@@ -40,13 +42,9 @@
|
||||
|
||||
StyledOutputpanePlaceHolder::StyledOutputpanePlaceHolder(Core::IMode *mode, QSplitter *parent) : Core::OutputPanePlaceHolder(mode, parent)
|
||||
{
|
||||
QFile file(":/qmldesigner/outputpane-style.css");
|
||||
file.open(QFile::ReadOnly);
|
||||
QFile file2(":/qmldesigner/scrollbar.css");
|
||||
file2.open(QFile::ReadOnly);
|
||||
m_customStylesheet = file.readAll() + file2.readAll();
|
||||
file.close();
|
||||
file2.close();
|
||||
m_customStylesheet = QString::fromLatin1(
|
||||
Utils::FileReader::fetchQrc(":/qmldesigner/outputpane-style.css")
|
||||
+ Utils::FileReader::fetchQrc(":/qmldesigner/scrollbar.css"));
|
||||
}
|
||||
|
||||
void StyledOutputpanePlaceHolder::childEvent(QChildEvent *event)
|
||||
|
||||
@@ -38,6 +38,7 @@
|
||||
#include <projectexplorer/projectexplorer.h>
|
||||
#include <coreplugin/messagemanager.h>
|
||||
#include <utils/filesystemwatcher.h>
|
||||
#include <utils/fileutils.h>
|
||||
|
||||
#include <QtCore/QDir>
|
||||
|
||||
@@ -235,19 +236,15 @@ void PluginDumper::dump(const Plugin &plugin)
|
||||
return;
|
||||
|
||||
const QString &path = plugin.predumpedQmlTypesFilePath();
|
||||
QFile libraryQmlTypesFile(path);
|
||||
if (!libraryQmlTypesFile.open(QFile::ReadOnly | QFile::Text)) {
|
||||
libraryInfo.setDumpStatus(LibraryInfo::DumpError,
|
||||
tr("Could not open file '%1' for reading.").arg(path));
|
||||
Utils::FileReader reader;
|
||||
if (!reader.fetch(path, QFile::Text)) {
|
||||
libraryInfo.setDumpStatus(LibraryInfo::DumpError, reader.errorString());
|
||||
m_modelManager->updateLibraryInfo(plugin.qmldirPath, libraryInfo);
|
||||
return;
|
||||
}
|
||||
|
||||
const QByteArray qmlTypeDescriptions = libraryQmlTypesFile.readAll();
|
||||
libraryQmlTypesFile.close();
|
||||
|
||||
QString error;
|
||||
const QList<FakeMetaObject::ConstPtr> objectsList = parseHelper(qmlTypeDescriptions, &error);
|
||||
const QList<FakeMetaObject::ConstPtr> objectsList = parseHelper(reader.data(), &error);
|
||||
|
||||
if (error.isEmpty()) {
|
||||
libraryInfo.setMetaObjects(objectsList);
|
||||
|
||||
@@ -44,6 +44,7 @@
|
||||
#include <qt4projectmanager/qmldumptool.h>
|
||||
#include <qt4projectmanager/qtversionmanager.h>
|
||||
#include <qmljs/qmljsmodelmanagerinterface.h>
|
||||
#include <utils/fileutils.h>
|
||||
|
||||
#include <utils/filesystemwatcher.h>
|
||||
|
||||
@@ -99,10 +100,10 @@ void QmlProject::parseProject(RefreshOptions options)
|
||||
if (options & ProjectFile)
|
||||
delete m_projectItem.data();
|
||||
if (!m_projectItem) {
|
||||
QFile file(m_fileName);
|
||||
if (file.open(QFile::ReadOnly)) {
|
||||
Utils::FileReader reader;
|
||||
if (reader.fetch(m_fileName)) {
|
||||
QDeclarativeComponent *component = new QDeclarativeComponent(&m_engine, this);
|
||||
component->setData(file.readAll(), QUrl::fromLocalFile(m_fileName));
|
||||
component->setData(reader.data(), QUrl::fromLocalFile(m_fileName));
|
||||
if (component->isReady()
|
||||
&& qobject_cast<QmlProjectItem*>(component->create())) {
|
||||
m_projectItem = qobject_cast<QmlProjectItem*>(component->create());
|
||||
@@ -113,7 +114,7 @@ void QmlProject::parseProject(RefreshOptions options)
|
||||
messageManager->printToOutputPane(component->errorString(), true);
|
||||
}
|
||||
} else {
|
||||
messageManager->printToOutputPane(tr("Error while loading project file %1.").arg(m_fileName), true);
|
||||
messageManager->printToOutputPane(tr("QML project: %1").arg(reader.errorString()), true);
|
||||
}
|
||||
}
|
||||
if (m_projectItem) {
|
||||
|
||||
@@ -35,6 +35,8 @@
|
||||
|
||||
#include <coreplugin/basefilewizard.h>
|
||||
|
||||
#include <utils/fileutils.h>
|
||||
|
||||
#include <cpptools/abstracteditorsupport.h>
|
||||
|
||||
#include <QtCore/QFileInfo>
|
||||
@@ -60,14 +62,11 @@ struct ProjectContents {
|
||||
static inline Core::GeneratedFile generateIconFile(const QString &source, const QString &target, QString *errorMessage)
|
||||
{
|
||||
// Read out source
|
||||
QFile iconFile(source);
|
||||
if (!iconFile.open(QIODevice::ReadOnly)) {
|
||||
*errorMessage = PluginGenerator::tr("Cannot open icon file %1.").arg(source);
|
||||
Utils::FileReader reader;
|
||||
if (!reader.fetch(source, errorMessage))
|
||||
return Core::GeneratedFile();
|
||||
}
|
||||
const QByteArray iconData = iconFile.readAll();
|
||||
Core::GeneratedFile rc(target);
|
||||
rc.setBinaryContents(iconData);
|
||||
rc.setBinaryContents(reader.data());
|
||||
rc.setBinary(true);
|
||||
return rc;
|
||||
}
|
||||
@@ -307,13 +306,11 @@ QString PluginGenerator::processTemplate(const QString &tmpl,
|
||||
const SubstitutionMap &substMap,
|
||||
QString *errorMessage)
|
||||
{
|
||||
QFile tpl(tmpl);
|
||||
if (!tpl.open(QIODevice::ReadOnly|QIODevice::Text)) {
|
||||
*errorMessage = tr("Cannot open %1: %2").arg(tmpl, tpl.errorString());
|
||||
Utils::FileReader reader;
|
||||
if (!reader.fetch(tmpl, errorMessage))
|
||||
return QString();
|
||||
}
|
||||
|
||||
QString cont = QString::fromUtf8(tpl.readAll());
|
||||
QString cont = QString::fromUtf8(reader.data());
|
||||
const QChar atChar = QLatin1Char('@');
|
||||
int offset = 0;
|
||||
for (;;) {
|
||||
|
||||
@@ -40,6 +40,7 @@
|
||||
#include "maemodeviceconfigurations.h"
|
||||
#include "maemokeydeployer.h"
|
||||
|
||||
#include <utils/fileutils.h>
|
||||
#include <utils/ssh/sshkeygenerator.h>
|
||||
|
||||
#include <QtCore/QDir>
|
||||
@@ -421,13 +422,10 @@ private:
|
||||
|
||||
bool saveFile(const QString &filePath, const QByteArray &data)
|
||||
{
|
||||
QFile file(filePath);
|
||||
const bool canOpen = file.open(QIODevice::WriteOnly);
|
||||
if (canOpen)
|
||||
file.write(data);
|
||||
if (!canOpen || file.error() != QFile::NoError) {
|
||||
QMessageBox::critical(this, tr("Could Not Save File"),
|
||||
tr("Failed to save key file %1: %2").arg(filePath, file.errorString()));
|
||||
Utils::FileSaver saver(filePath);
|
||||
saver.write(data);
|
||||
if (!saver.finalize()) {
|
||||
QMessageBox::critical(this, tr("Could Not Save Key File"), saver.errorString());
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
||||
@@ -32,6 +32,7 @@
|
||||
#include "maemokeydeployer.h"
|
||||
|
||||
#include <utils/ssh/sshremoteprocessrunner.h>
|
||||
#include <utils/fileutils.h>
|
||||
|
||||
#include <QtCore/QFile>
|
||||
|
||||
@@ -56,13 +57,9 @@ void MaemoKeyDeployer::deployPublicKey(const SshConnectionParameters &sshParams,
|
||||
cleanup();
|
||||
m_deployProcess = SshRemoteProcessRunner::create(sshParams);
|
||||
|
||||
QFile keyFile(keyFilePath);
|
||||
QByteArray key;
|
||||
const bool keyFileAccessible = keyFile.open(QIODevice::ReadOnly);
|
||||
if (keyFileAccessible)
|
||||
key = keyFile.readAll();
|
||||
if (!keyFileAccessible || keyFile.error() != QFile::NoError) {
|
||||
emit error(tr("Could not read public key file '%1'.").arg(keyFilePath));
|
||||
Utils::FileReader reader;
|
||||
if (!reader.fetch(keyFilePath)) {
|
||||
emit error(tr("Public key error: %1").arg(reader.errorString()));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -72,7 +69,7 @@ void MaemoKeyDeployer::deployPublicKey(const SshConnectionParameters &sshParams,
|
||||
SLOT(handleKeyUploadFinished(int)));
|
||||
const QByteArray command = "test -d .ssh "
|
||||
"|| mkdir .ssh && chmod 0700 .ssh && echo '"
|
||||
+ key + "' >> .ssh/authorized_keys && chmod 0600 .ssh/authorized_keys";
|
||||
+ reader.data() + "' >> .ssh/authorized_keys && chmod 0600 .ssh/authorized_keys";
|
||||
m_deployProcess->run(command);
|
||||
}
|
||||
|
||||
|
||||
@@ -34,6 +34,7 @@
|
||||
#include "maemodeviceconfigurations.h"
|
||||
|
||||
#include <utils/ssh/sshkeygenerator.h>
|
||||
#include <utils/fileutils.h>
|
||||
|
||||
#include <QtCore/QDir>
|
||||
#include <QtGui/QApplication>
|
||||
@@ -124,17 +125,10 @@ void MaemoSshConfigDialog::saveKey(bool publicKey)
|
||||
if (fileName.isEmpty())
|
||||
return;
|
||||
|
||||
QFile file(fileName);
|
||||
const bool canOpen = file.open(QIODevice::WriteOnly);
|
||||
if (canOpen)
|
||||
file.write(publicKey
|
||||
Utils::FileSaver saver(fileName);
|
||||
saver.write(publicKey
|
||||
? m_keyGenerator->publicKey()
|
||||
: m_keyGenerator->privateKey());
|
||||
if (!canOpen || file.error() != QFile::NoError) {
|
||||
QMessageBox::critical(this, tr("Error writing file"),
|
||||
tr("Could not write file '%1':\n %2")
|
||||
.arg(fileName, file.errorString()));
|
||||
} else if (!publicKey) {
|
||||
if (saver.finalize(this) && !publicKey)
|
||||
emit privateKeyGenerated(fileName);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -47,6 +47,7 @@
|
||||
#include <projectexplorer/projectnodes.h>
|
||||
#include <projectexplorer/toolchain.h>
|
||||
#include <qt4projectmanager/qt4project.h>
|
||||
#include <utils/fileutils.h>
|
||||
|
||||
#include <utils/filesystemwatcher.h>
|
||||
|
||||
@@ -965,10 +966,6 @@ AbstractQt4MaemoTarget::ActionStatus AbstractRpmBasedQt4MaemoTarget::createSpeci
|
||||
{
|
||||
if (QFileInfo(specFilePath()).exists())
|
||||
return NoActionRequired;
|
||||
QSharedPointer<QFile> specFile
|
||||
= openFile(specFilePath(), QIODevice::WriteOnly, 0);
|
||||
if (!specFile)
|
||||
return ActionFailed;
|
||||
QByteArray initialContent(
|
||||
"Name: %%name%%\n"
|
||||
"Summary: <insert short description here>\n"
|
||||
@@ -1010,8 +1007,9 @@ AbstractQt4MaemoTarget::ActionStatus AbstractRpmBasedQt4MaemoTarget::createSpeci
|
||||
"# Add post-uninstall scripts here."
|
||||
);
|
||||
initialContent.replace("%%name%%", project()->displayName().toUtf8());
|
||||
return specFile->write(initialContent) == initialContent.count()
|
||||
? ActionSuccessful : ActionFailed;
|
||||
Utils::FileSaver saver(specFilePath());
|
||||
saver.write(initialContent);
|
||||
return saver.finalize() ? ActionSuccessful : ActionFailed;
|
||||
}
|
||||
|
||||
void AbstractRpmBasedQt4MaemoTarget::handleTargetAddedSpecial()
|
||||
|
||||
@@ -46,6 +46,7 @@
|
||||
#include <coreplugin/coreconstants.h>
|
||||
|
||||
#include <utils/checkablemessagebox.h>
|
||||
#include <utils/fileutils.h>
|
||||
|
||||
#include <projectexplorer/buildconfiguration.h>
|
||||
#include <projectexplorer/buildsteplist.h>
|
||||
@@ -622,12 +623,14 @@ QString S60CreatePackageStep::generateKeyId(const QString &keyPath) const
|
||||
if (keyPath.isEmpty())
|
||||
return QString();
|
||||
|
||||
QFile file(keyPath);
|
||||
if (!file.open(QIODevice::ReadOnly | QIODevice::Text))
|
||||
Utils::FileReader reader;
|
||||
if (!reader.fetch(keyPath, QIODevice::Text)) {
|
||||
emit addOutput(reader.errorString(), BuildStep::ErrorOutput);
|
||||
return QString();
|
||||
}
|
||||
|
||||
//key file is quite small in size
|
||||
return QCryptographicHash::hash(file.readAll(),
|
||||
return QCryptographicHash::hash(reader.data(),
|
||||
QCryptographicHash::Md5).toHex();
|
||||
}
|
||||
|
||||
|
||||
@@ -48,6 +48,7 @@
|
||||
#include <projectexplorer/buildstep.h>
|
||||
|
||||
#include <utils/qtcassert.h>
|
||||
#include <utils/fileutils.h>
|
||||
|
||||
#include <QtCore/QProcess>
|
||||
|
||||
@@ -276,25 +277,23 @@ void S60PublisherOvi::updateProFile(const QString &var, const QString &values)
|
||||
QStringList lines;
|
||||
ProFile *profile = m_reader->parsedProFile(m_qt4project->rootProjectNode()->path());
|
||||
|
||||
QFile qfile(m_qt4project->rootProjectNode()->path());
|
||||
if (qfile.open(QIODevice::ReadOnly | QIODevice::Text)) {
|
||||
lines = QString::fromLocal8Bit(qfile.readAll()).split(QLatin1Char('\n'));
|
||||
qfile.close();
|
||||
while (!lines.isEmpty() && lines.last().isEmpty())
|
||||
lines.removeLast();
|
||||
} else {
|
||||
m_qt4project->proFileParseError(tr("Error while reading .pro file %1: %2").arg(m_qt4project->rootProjectNode()->path(), qfile.errorString()));
|
||||
Utils::FileReader reader;
|
||||
if (!reader.fetch(m_qt4project->rootProjectNode()->path(), QIODevice::Text)) {
|
||||
emit progressReport(reader.errorString(), m_errorColor);
|
||||
return;
|
||||
}
|
||||
lines = QString::fromLocal8Bit(reader.data()).split(QLatin1Char('\n'));
|
||||
while (!lines.isEmpty() && lines.last().isEmpty())
|
||||
lines.removeLast();
|
||||
|
||||
ProWriter::putVarValues(profile, &lines, QStringList() << values, var,
|
||||
ProWriter::ReplaceValues | ProWriter::OneLine | ProWriter::AppendOperator,
|
||||
"symbian");
|
||||
|
||||
if (qfile.open(QIODevice::WriteOnly | QIODevice::Text)) {
|
||||
qfile.write(lines.join("\n").toLocal8Bit());
|
||||
qfile.close();
|
||||
}
|
||||
Utils::FileSaver saver(m_qt4project->rootProjectNode()->path(), QIODevice::Text);
|
||||
saver.write(lines.join("\n").toLocal8Bit());
|
||||
if (!saver.finalize())
|
||||
emit progressReport(saver.errorString(), m_errorColor);
|
||||
}
|
||||
|
||||
void S60PublisherOvi::updateProFile()
|
||||
|
||||
@@ -57,6 +57,7 @@
|
||||
|
||||
#include <utils/qtcassert.h>
|
||||
#include <utils/stringutils.h>
|
||||
#include <utils/fileutils.h>
|
||||
#include <algorithm>
|
||||
|
||||
#include <QtCore/QDebug>
|
||||
@@ -1090,18 +1091,15 @@ void Qt4PriFileNode::changeFiles(const FileType fileType,
|
||||
{
|
||||
QString contents;
|
||||
{
|
||||
QFile qfile(m_projectFilePath);
|
||||
if (qfile.open(QIODevice::ReadOnly | QIODevice::Text)) {
|
||||
contents = QString::fromLocal8Bit(qfile.readAll());
|
||||
qfile.close();
|
||||
Utils::FileReader reader;
|
||||
if (!reader.fetch(m_projectFilePath, QIODevice::Text)) {
|
||||
m_project->proFileParseError(reader.errorString());
|
||||
return;
|
||||
}
|
||||
contents = QString::fromLocal8Bit(reader.data());
|
||||
lines = contents.split(QLatin1Char('\n'));
|
||||
while (!lines.isEmpty() && lines.last().isEmpty())
|
||||
lines.removeLast();
|
||||
} else {
|
||||
m_project->proFileParseError(tr("Error while reading .pro file %1: %2")
|
||||
.arg(m_projectFilePath, qfile.errorString()));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
ProMessageHandler handler;
|
||||
@@ -1148,14 +1146,12 @@ void Qt4PriFileNode::changeFiles(const FileType fileType,
|
||||
|
||||
void Qt4PriFileNode::save(const QStringList &lines)
|
||||
{
|
||||
QFile qfile(m_projectFilePath);
|
||||
if (qfile.open(QIODevice::WriteOnly | QIODevice::Text)) {
|
||||
Utils::FileSaver saver(m_projectFilePath, QIODevice::Text);
|
||||
foreach (const QString &str, lines) {
|
||||
qfile.write(str.toLocal8Bit());
|
||||
qfile.write("\n");
|
||||
}
|
||||
qfile.close();
|
||||
saver.write(str.toLocal8Bit());
|
||||
saver.write("\n", 1);
|
||||
}
|
||||
saver.finalize(Core::ICore::instance()->mainWindow());
|
||||
|
||||
m_project->qt4ProjectManager()->notifyChanged(m_projectFilePath);
|
||||
}
|
||||
|
||||
@@ -41,6 +41,8 @@
|
||||
#include <coreplugin/icore.h>
|
||||
#endif // CREATORLESSTEST
|
||||
|
||||
#include <utils/fileutils.h>
|
||||
|
||||
namespace Qt4ProjectManager {
|
||||
|
||||
AbstractGeneratedFileInfo::AbstractGeneratedFileInfo()
|
||||
@@ -173,28 +175,29 @@ QString AbstractMobileApp::path(int fileType) const
|
||||
return QString();
|
||||
}
|
||||
|
||||
bool AbstractMobileApp::readTemplate(int fileType, QByteArray *data, QString *errorMessage) const
|
||||
{
|
||||
Utils::FileReader reader;
|
||||
if (!reader.fetch(path(fileType), errorMessage))
|
||||
return false;
|
||||
*data = reader.data();
|
||||
return true;
|
||||
}
|
||||
|
||||
QByteArray AbstractMobileApp::generateDesktopFile(QString *errorMessage) const
|
||||
{
|
||||
QFile desktopTemplate(path(DesktopOrigin));
|
||||
if (!desktopTemplate.open(QIODevice::ReadOnly)) {
|
||||
*errorMessage = QCoreApplication::translate("Qt4ProjectManager::AbstractMobileApp",
|
||||
"Could not open desktop file template");
|
||||
QByteArray desktopFileContent;
|
||||
if (!readTemplate(DesktopOrigin, &desktopFileContent, errorMessage))
|
||||
return QByteArray();
|
||||
}
|
||||
QByteArray desktopFileContent = desktopTemplate.readAll();
|
||||
return desktopFileContent.replace("thisApp", projectName().toUtf8());
|
||||
}
|
||||
|
||||
QByteArray AbstractMobileApp::generateMainCpp(QString *errorMessage) const
|
||||
{
|
||||
QFile sourceFile(path(MainCppOrigin));
|
||||
if (!sourceFile.open(QIODevice::ReadOnly)) {
|
||||
*errorMessage = QCoreApplication::translate("Qt4ProjectManager::AbstractMobileApp",
|
||||
"Could not open main.cpp template '%1'.")
|
||||
.arg(sourceFile.fileName());
|
||||
QByteArray mainCppInput;
|
||||
if (!readTemplate(MainCppOrigin, &mainCppInput, errorMessage))
|
||||
return QByteArray();
|
||||
}
|
||||
QTextStream in(&sourceFile);
|
||||
QTextStream in(&mainCppInput);
|
||||
|
||||
QByteArray mainCppContent;
|
||||
QTextStream out(&mainCppContent, QIODevice::WriteOnly);
|
||||
@@ -236,14 +239,10 @@ QByteArray AbstractMobileApp::generateMainCpp(QString *errorMessage) const
|
||||
QByteArray AbstractMobileApp::generateProFile(QString *errorMessage) const
|
||||
{
|
||||
const QChar comment = QLatin1Char('#');
|
||||
QFile proFile(path(AppProOrigin));
|
||||
if (!proFile.open(QIODevice::ReadOnly)) {
|
||||
*errorMessage = QCoreApplication::translate("Qt4ProjectManager::AbstractMobileApp",
|
||||
"Could not open project file template '%1'.")
|
||||
.arg(proFile.fileName());
|
||||
QByteArray proFileInput;
|
||||
if (!readTemplate(AppProOrigin, &proFileInput, errorMessage))
|
||||
return QByteArray();
|
||||
}
|
||||
QTextStream in(&proFile);
|
||||
QTextStream in(&proFileInput);
|
||||
|
||||
QByteArray proFileContent;
|
||||
QTextStream out(&proFileContent, QIODevice::WriteOnly);
|
||||
@@ -346,15 +345,11 @@ bool AbstractMobileApp::updateFiles(const QList<AbstractGeneratedFileInfo> &list
|
||||
const QByteArray data = generateFile(info.fileType, &error);
|
||||
if (!error.isEmpty())
|
||||
return false;
|
||||
QFile file(info.fileInfo.absoluteFilePath());
|
||||
if (!file.open(QIODevice::WriteOnly) || file.write(data) == -1) {
|
||||
error = QCoreApplication::translate(
|
||||
"Qt4ProjectManager::Internal::QtQuickApp",
|
||||
"Could not write file '%1'.").
|
||||
arg(QDir::toNativeSeparators(info.fileInfo.canonicalFilePath()));
|
||||
Utils::FileSaver saver(QDir::cleanPath(info.fileInfo.absoluteFilePath()));
|
||||
saver.write(data);
|
||||
if (!saver.finalize(&error))
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -397,13 +392,10 @@ QString AbstractMobileApp::error() const
|
||||
QByteArray AbstractMobileApp::readBlob(const QString &filePath,
|
||||
QString *errorMsg) const
|
||||
{
|
||||
QFile sourceFile(filePath);
|
||||
if (!sourceFile.open(QIODevice::ReadOnly)) {
|
||||
*errorMsg = QCoreApplication::translate("Qt4ProjectManager::AbstractMobileApp",
|
||||
"Could not open template file '%1'.").arg(filePath);
|
||||
Utils::FileReader reader;
|
||||
if (!reader.fetch(filePath, errorMsg))
|
||||
return QByteArray();
|
||||
}
|
||||
return sourceFile.readAll();
|
||||
return reader.data();
|
||||
}
|
||||
|
||||
QByteArray AbstractMobileApp::generateFile(int fileType,
|
||||
|
||||
@@ -144,6 +144,7 @@ protected:
|
||||
static void insertParameter(QString &line, const QString ¶meter);
|
||||
|
||||
QByteArray readBlob(const QString &filePath, QString *errorMsg) const;
|
||||
bool readTemplate(int fileType, QByteArray *data, QString *errorMessage) const;
|
||||
QByteArray generateFile(int fileType, QString *errorMessage) const;
|
||||
QString outputPathBase() const;
|
||||
|
||||
|
||||
@@ -41,6 +41,8 @@
|
||||
#include <extensionsystem/pluginmanager.h>
|
||||
#include <extensionsystem/invoker.h>
|
||||
|
||||
#include <utils/fileutils.h>
|
||||
|
||||
#include <QtCore/QDir>
|
||||
#include <QtCore/QFile>
|
||||
#include <QtCore/QTextStream>
|
||||
@@ -258,12 +260,10 @@ bool GuiAppWizard::parametrizeTemplate(const QString &templatePath, const QStrin
|
||||
QString fileName = templatePath;
|
||||
fileName += QDir::separator();
|
||||
fileName += templateName;
|
||||
QFile inFile(fileName);
|
||||
if (!inFile.open(QIODevice::ReadOnly | QIODevice::Text)) {
|
||||
*errorMessage = tr("The template file '%1' could not be opened for reading: %2").arg(fileName, inFile.errorString());
|
||||
Utils::FileReader reader;
|
||||
if (!reader.fetch(fileName, QIODevice::Text, errorMessage))
|
||||
return false;
|
||||
}
|
||||
QString contents = QString::fromUtf8(inFile.readAll());
|
||||
QString contents = QString::fromUtf8(reader.data());
|
||||
|
||||
contents.replace(QLatin1String("%QAPP_INCLUDE%"), QLatin1String("QtGui/QApplication"));
|
||||
contents.replace(QLatin1String("%INCLUDE%"), params.headerFileName);
|
||||
|
||||
@@ -35,6 +35,7 @@
|
||||
#include "ui_mobileappwizardmaemooptionspage.h"
|
||||
#include "ui_mobileappwizardsymbianoptionspage.h"
|
||||
#include <coreplugin/coreconstants.h>
|
||||
#include <utils/fileutils.h>
|
||||
|
||||
#include <QtCore/QTemporaryFile>
|
||||
#include <QtGui/QDesktopServices>
|
||||
@@ -205,15 +206,17 @@ void MobileAppWizardMaemoOptionsPage::setPngIcon(const QString &icon)
|
||||
if (button != QMessageBox::Ok)
|
||||
return;
|
||||
iconPixmap = iconPixmap.scaled(iconSize);
|
||||
QTemporaryFile tmpFile;
|
||||
tmpFile.setAutoRemove(false);
|
||||
const char * const format = QFileInfo(icon).suffix().toAscii().data();
|
||||
if (!tmpFile.open() || !iconPixmap.save(&tmpFile, format)) {
|
||||
Utils::TempFileSaver saver;
|
||||
saver.setAutoRemove(false);
|
||||
if (!saver.hasError())
|
||||
saver.setResult(iconPixmap.save(
|
||||
saver.file(), QFileInfo(icon).suffix().toAscii().constData()));
|
||||
if (!saver.finalize()) {
|
||||
QMessageBox::critical(this, tr("File Error"),
|
||||
tr("Could not copy icon file."));
|
||||
tr("Could not copy icon file: %1").arg(saver.errorString()));
|
||||
return;
|
||||
}
|
||||
actualIconPath = tmpFile.fileName();
|
||||
actualIconPath = saver.fileName();
|
||||
}
|
||||
|
||||
m_d->ui.pngIconButton->setIcon(iconPixmap);
|
||||
|
||||
@@ -39,6 +39,7 @@
|
||||
#include <coreplugin/icore.h>
|
||||
#include <coreplugin/editormanager/editormanager.h>
|
||||
#include <utils/reloadpromptutils.h>
|
||||
#include <utils/fileutils.h>
|
||||
|
||||
#include <QtCore/QTemporaryFile>
|
||||
#include <QtCore/QFileInfo>
|
||||
@@ -97,18 +98,15 @@ ResourceEditorW::~ResourceEditorW()
|
||||
|
||||
bool ResourceEditorW::createNew(const QString &contents)
|
||||
{
|
||||
QTemporaryFile tempFile(0);
|
||||
tempFile.setAutoRemove(true);
|
||||
if (!tempFile.open())
|
||||
Utils::TempFileSaver saver;
|
||||
saver.write(contents.toUtf8());
|
||||
if (!saver.finalize(Core::ICore::instance()->mainWindow()))
|
||||
return false;
|
||||
const QString tempFileName = tempFile.fileName();
|
||||
tempFile.write(contents.toUtf8());
|
||||
tempFile.close();
|
||||
|
||||
const bool rc = m_resourceEditor->load(tempFileName);
|
||||
const bool rc = m_resourceEditor->load(saver.fileName());
|
||||
m_resourceEditor->setFileName(QString());
|
||||
if (debugResourceEditorW)
|
||||
qDebug() << "ResourceEditorW::createNew: " << contents << " (" << tempFileName << ") returns " << rc;
|
||||
qDebug() << "ResourceEditorW::createNew: " << contents << " (" << saver.fileName() << ") returns " << rc;
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
||||
@@ -47,6 +47,7 @@
|
||||
#include <vcsbase/vcsbaseeditorparameterwidget.h>
|
||||
#include <utils/synchronousprocess.h>
|
||||
#include <utils/parameteraction.h>
|
||||
#include <utils/fileutils.h>
|
||||
|
||||
#include <coreplugin/icore.h>
|
||||
#include <coreplugin/coreconstants.h>
|
||||
@@ -808,19 +809,17 @@ void SubversionPlugin::startCommit(const QString &workingDir, const QStringList
|
||||
}
|
||||
m_commitRepository = workingDir;
|
||||
// Create a new submit change file containing the submit template
|
||||
QTemporaryFile changeTmpFile;
|
||||
changeTmpFile.setAutoRemove(false);
|
||||
if (!changeTmpFile.open()) {
|
||||
VCSBase::VCSBaseOutputWindow::instance()->appendError(tr("Cannot create temporary file: %1").arg(changeTmpFile.errorString()));
|
||||
return;
|
||||
}
|
||||
m_commitMessageFileName = changeTmpFile.fileName();
|
||||
// TODO: Regitctrieve submit template from
|
||||
Utils::TempFileSaver saver;
|
||||
saver.setAutoRemove(false);
|
||||
// TODO: Retrieve submit template from
|
||||
const QString submitTemplate;
|
||||
// Create a submit
|
||||
changeTmpFile.write(submitTemplate.toUtf8());
|
||||
changeTmpFile.flush();
|
||||
changeTmpFile.close();
|
||||
saver.write(submitTemplate.toUtf8());
|
||||
if (!saver.finalize()) {
|
||||
VCSBase::VCSBaseOutputWindow::instance()->appendError(saver.errorString());
|
||||
return;
|
||||
}
|
||||
m_commitMessageFileName = saver.fileName();
|
||||
// Create a submit editor and set file list
|
||||
SubversionSubmitEditor *editor = openSubversionSubmitEditor(m_commitMessageFileName);
|
||||
editor->setStatusList(statusOutput);
|
||||
|
||||
@@ -42,6 +42,7 @@
|
||||
#include <texteditor/itexteditor.h>
|
||||
#include <texteditor/basetexteditor.h>
|
||||
#include <utils/stylehelper.h>
|
||||
#include <utils/fileutils.h>
|
||||
|
||||
#include <QtCore/QDebug>
|
||||
#include <QtCore/QDirIterator>
|
||||
@@ -50,6 +51,7 @@
|
||||
#include <QtGui/QCheckBox>
|
||||
#include <QtGui/QComboBox>
|
||||
#include <QtGui/QLabel>
|
||||
#include <QtGui/QMainWindow>
|
||||
#include <QtGui/QPushButton>
|
||||
#include <QtGui/QTextBlock>
|
||||
|
||||
@@ -346,25 +348,22 @@ QStringList BaseFileFind::replaceAll(const QString &text,
|
||||
applyChanges(textEditor->document(), text, changeItems);
|
||||
tc.endEditBlock();
|
||||
} else {
|
||||
QFile file(fileName);
|
||||
|
||||
if (file.open(QFile::ReadOnly)) {
|
||||
QTextStream stream(&file);
|
||||
// ### set the encoding
|
||||
const QString plainText = stream.readAll();
|
||||
file.close();
|
||||
|
||||
Utils::FileReader reader;
|
||||
if (reader.fetch(fileName, Core::ICore::instance()->mainWindow())) {
|
||||
QTextDocument doc;
|
||||
doc.setPlainText(plainText);
|
||||
// ### set the encoding
|
||||
doc.setPlainText(QString::fromLocal8Bit(reader.data()));
|
||||
|
||||
applyChanges(&doc, text, changeItems);
|
||||
|
||||
QFile newFile(fileName);
|
||||
if (newFile.open(QFile::WriteOnly)) {
|
||||
QTextStream stream(&newFile);
|
||||
Utils::FileSaver saver(fileName);
|
||||
if (!saver.hasError()) {
|
||||
QTextStream stream(saver.file());
|
||||
// ### set the encoding
|
||||
stream << doc.toPlainText();
|
||||
saver.setResult(&stream);
|
||||
}
|
||||
saver.finalize(Core::ICore::instance()->mainWindow());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,6 +34,8 @@
|
||||
|
||||
#include "texteditorconstants.h"
|
||||
|
||||
#include <utils/fileutils.h>
|
||||
|
||||
#include <QtCore/QFile>
|
||||
#include <QtCore/QCoreApplication>
|
||||
#include <QtXml/QXmlStreamWriter>
|
||||
@@ -132,13 +134,11 @@ void ColorScheme::clear()
|
||||
m_formats.clear();
|
||||
}
|
||||
|
||||
bool ColorScheme::save(const QString &fileName) const
|
||||
bool ColorScheme::save(const QString &fileName, QWidget *parent) const
|
||||
{
|
||||
QFile file(fileName);
|
||||
if (!file.open(QIODevice::WriteOnly))
|
||||
return false;
|
||||
|
||||
QXmlStreamWriter w(&file);
|
||||
Utils::FileSaver saver(fileName);
|
||||
if (!saver.hasError()) {
|
||||
QXmlStreamWriter w(saver.file());
|
||||
w.setAutoFormatting(true);
|
||||
w.setAutoFormattingIndent(2);
|
||||
|
||||
@@ -167,7 +167,9 @@ bool ColorScheme::save(const QString &fileName) const
|
||||
w.writeEndElement();
|
||||
w.writeEndDocument();
|
||||
|
||||
return true;
|
||||
saver.setResult(&w);
|
||||
}
|
||||
return saver.finalize(parent);
|
||||
}
|
||||
|
||||
namespace {
|
||||
|
||||
@@ -39,6 +39,10 @@
|
||||
#include <QtCore/QString>
|
||||
#include <QtGui/QColor>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
class QWidget;
|
||||
QT_END_NAMESPACE
|
||||
|
||||
namespace TextEditor {
|
||||
|
||||
/*! Format for a particular piece of text (text/comment, etc). */
|
||||
@@ -101,7 +105,7 @@ public:
|
||||
|
||||
void clear();
|
||||
|
||||
bool save(const QString &fileName) const;
|
||||
bool save(const QString &fileName, QWidget *parent) const;
|
||||
bool load(const QString &fileName);
|
||||
|
||||
inline bool equals(const ColorScheme &cs) const
|
||||
|
||||
@@ -42,6 +42,7 @@
|
||||
#include <QtCore/QCoreApplication>
|
||||
#include <QtGui/QTextCharFormat>
|
||||
#include <QtGui/QFont>
|
||||
#include <QtGui/QMainWindow>
|
||||
|
||||
static const char *fontFamilyKey = "FontFamily";
|
||||
static const char *fontSizeKey = "FontSize";
|
||||
@@ -315,7 +316,7 @@ bool FontSettings::loadColorScheme(const QString &fileName,
|
||||
|
||||
bool FontSettings::saveColorScheme(const QString &fileName)
|
||||
{
|
||||
const bool saved = m_scheme.save(fileName);
|
||||
const bool saved = m_scheme.save(fileName, Core::ICore::instance()->mainWindow());
|
||||
if (saved)
|
||||
m_schemeFileName = fileName;
|
||||
return saved;
|
||||
|
||||
@@ -51,6 +51,7 @@
|
||||
#include <QtGui/QInputDialog>
|
||||
#include <QtGui/QListWidget>
|
||||
#include <QtGui/QMessageBox>
|
||||
#include <QtGui/QMainWindow>
|
||||
#include <QtGui/QPalette>
|
||||
#include <QtGui/QTextCharFormat>
|
||||
#include <QtGui/QTextEdit>
|
||||
@@ -492,7 +493,7 @@ void FontSettingsPage::copyColorScheme(const QString &name)
|
||||
|
||||
ColorScheme scheme = d_ptr->m_value.colorScheme();
|
||||
scheme.setDisplayName(name);
|
||||
scheme.save(fileName);
|
||||
if (scheme.save(fileName, Core::ICore::instance()->mainWindow()))
|
||||
d_ptr->m_value.setColorSchemeFileName(fileName);
|
||||
|
||||
refreshColorSchemeList();
|
||||
@@ -559,7 +560,7 @@ void FontSettingsPage::maybeSaveColorScheme()
|
||||
|
||||
if (messageBox->exec() == QMessageBox::Save) {
|
||||
const ColorScheme &scheme = d_ptr->m_ui->schemeEdit->colorScheme();
|
||||
scheme.save(d_ptr->m_value.colorSchemeFileName());
|
||||
scheme.save(d_ptr->m_value.colorSchemeFileName(), Core::ICore::instance()->mainWindow());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -618,7 +619,7 @@ void FontSettingsPage::apply()
|
||||
// Update the scheme and save it under the name it already has
|
||||
d_ptr->m_value.setColorScheme(d_ptr->m_ui->schemeEdit->colorScheme());
|
||||
const ColorScheme &scheme = d_ptr->m_value.colorScheme();
|
||||
scheme.save(d_ptr->m_value.colorSchemeFileName());
|
||||
scheme.save(d_ptr->m_value.colorSchemeFileName(), Core::ICore::instance()->mainWindow());
|
||||
}
|
||||
|
||||
int index = d_ptr->m_ui->schemeComboBox->currentIndex();
|
||||
|
||||
@@ -32,6 +32,8 @@
|
||||
|
||||
#include "definitiondownloader.h"
|
||||
|
||||
#include <utils/fileutils.h>
|
||||
|
||||
#include <QtCore/QLatin1Char>
|
||||
#include <QtCore/QEventLoop>
|
||||
#include <QtCore/QFile>
|
||||
@@ -88,14 +90,9 @@ void DefinitionDownloader::saveData(QNetworkReply *reply)
|
||||
const QString &urlPath = m_url.path();
|
||||
const QString &fileName =
|
||||
urlPath.right(urlPath.length() - urlPath.lastIndexOf(QLatin1Char('/')) - 1);
|
||||
QFile file(m_localPath + fileName);
|
||||
if (file.open(QIODevice::Text | QIODevice::WriteOnly)) {
|
||||
file.write(reply->readAll());
|
||||
file.close();
|
||||
m_status = Ok;
|
||||
} else {
|
||||
m_status = WriteError;
|
||||
}
|
||||
Utils::FileSaver saver(m_localPath + fileName, QIODevice::Text);
|
||||
saver.write(reply->readAll());
|
||||
m_status = saver.finalize() ? Ok: WriteError;
|
||||
}
|
||||
|
||||
DefinitionDownloader::Status DefinitionDownloader::status() const
|
||||
|
||||
@@ -33,11 +33,15 @@
|
||||
#include "refactoringchanges.h"
|
||||
#include "basetexteditor.h"
|
||||
|
||||
#include <coreplugin/icore.h>
|
||||
#include <coreplugin/editormanager/editormanager.h>
|
||||
#include <extensionsystem/pluginmanager.h>
|
||||
|
||||
#include <utils/fileutils.h>
|
||||
|
||||
#include <QtCore/QFile>
|
||||
#include <QtCore/QSet>
|
||||
#include <QtGui/QMainWindow>
|
||||
#include <QtGui/QTextBlock>
|
||||
#include <QtGui/QTextCursor>
|
||||
#include <QtGui/QTextDocument>
|
||||
@@ -126,10 +130,11 @@ bool RefactoringChanges::createFile(const QString &fileName, const QString &cont
|
||||
}
|
||||
|
||||
if (!editor) {
|
||||
QFile file(fileName);
|
||||
file.open(QFile::WriteOnly);
|
||||
file.write(document->toPlainText().toUtf8());
|
||||
Utils::FileSaver saver(fileName);
|
||||
saver.write(document->toPlainText().toUtf8());
|
||||
delete document;
|
||||
if (!saver.finalize(Core::ICore::instance()->mainWindow()))
|
||||
return false;
|
||||
}
|
||||
|
||||
fileChanged(fileName);
|
||||
@@ -229,10 +234,9 @@ RefactoringFile::~RefactoringFile()
|
||||
|
||||
// if this document doesn't have an editor, write the result to a file
|
||||
if (!m_editor && !m_fileName.isEmpty()) {
|
||||
const QByteArray &newContents = doc->toPlainText().toUtf8();
|
||||
QFile file(m_fileName);
|
||||
file.open(QFile::WriteOnly);
|
||||
file.write(newContents);
|
||||
Utils::FileSaver saver(m_fileName);
|
||||
saver.write(doc->toPlainText().toUtf8());
|
||||
saver.finalize(Core::ICore::instance()->mainWindow());
|
||||
}
|
||||
|
||||
if (!m_fileName.isEmpty())
|
||||
@@ -259,9 +263,9 @@ QTextDocument *RefactoringFile::mutableDocument() const
|
||||
else if (!m_document) {
|
||||
QString fileContents;
|
||||
if (!m_fileName.isEmpty()) {
|
||||
QFile file(m_fileName);
|
||||
if (file.open(QIODevice::ReadOnly))
|
||||
fileContents = file.readAll();
|
||||
Utils::FileReader reader;
|
||||
if (reader.fetch(m_fileName, Core::ICore::instance()->mainWindow()))
|
||||
fileContents = QString::fromUtf8(reader.data());
|
||||
}
|
||||
m_document = new QTextDocument(fileContents);
|
||||
}
|
||||
|
||||
@@ -36,6 +36,7 @@
|
||||
|
||||
#include <coreplugin/icore.h>
|
||||
#include <extensionsystem/pluginmanager.h>
|
||||
#include <utils/fileutils.h>
|
||||
|
||||
#include <QtCore/QLatin1String>
|
||||
#include <QtCore/QFile>
|
||||
@@ -312,12 +313,16 @@ void SnippetsCollection::reload()
|
||||
insertSnippet(snippet);
|
||||
}
|
||||
|
||||
void SnippetsCollection::synchronize()
|
||||
bool SnippetsCollection::synchronize(QString *errorString)
|
||||
{
|
||||
if (QFile::exists(m_userSnippetsPath) || QDir().mkpath(m_userSnippetsPath)) {
|
||||
QFile file(m_userSnippetsPath + m_userSnippetsFile);
|
||||
if (file.open(QFile::WriteOnly | QFile::Truncate)) {
|
||||
QXmlStreamWriter writer(&file);
|
||||
if (!QFile::exists(m_userSnippetsPath) && !QDir().mkpath(m_userSnippetsPath)) {
|
||||
*errorString = tr("Cannot create user snippet directory %1").arg(
|
||||
QDir::toNativeSeparators(m_userSnippetsPath));
|
||||
return false;
|
||||
}
|
||||
Utils::FileSaver saver(m_userSnippetsPath + m_userSnippetsFile);
|
||||
if (!saver.hasError()) {
|
||||
QXmlStreamWriter writer(saver.file());
|
||||
writer.setAutoFormatting(true);
|
||||
writer.writeStartDocument();
|
||||
writer.writeStartElement(kSnippets);
|
||||
@@ -331,11 +336,14 @@ void SnippetsCollection::synchronize()
|
||||
}
|
||||
writer.writeEndElement();
|
||||
writer.writeEndDocument();
|
||||
file.close();
|
||||
}
|
||||
|
||||
saver.setResult(&writer);
|
||||
}
|
||||
if (!saver.finalize(errorString))
|
||||
return false;
|
||||
|
||||
reload();
|
||||
return true;
|
||||
}
|
||||
|
||||
void SnippetsCollection::writeSnippetXML(const Snippet &snippet, QXmlStreamWriter *writer) const
|
||||
|
||||
@@ -97,7 +97,7 @@ public:
|
||||
QList<QString> groupIds() const;
|
||||
|
||||
void reload();
|
||||
void synchronize();
|
||||
bool synchronize(QString *errorString);
|
||||
|
||||
private slots:
|
||||
void identifyGroups();
|
||||
|
||||
@@ -49,6 +49,7 @@
|
||||
#include <QtCore/QTextStream>
|
||||
#include <QtCore/QHash>
|
||||
#include <QtGui/QMessageBox>
|
||||
#include <QtGui/QMainWindow>
|
||||
|
||||
namespace TextEditor {
|
||||
namespace Internal {
|
||||
@@ -390,8 +391,12 @@ void SnippetsSettingsPagePrivate::apply()
|
||||
setSnippetContent();
|
||||
|
||||
if (m_snippetsCollectionChanged) {
|
||||
SnippetsCollection::instance()->synchronize();
|
||||
QString errorString;
|
||||
if (SnippetsCollection::instance()->synchronize(&errorString))
|
||||
m_snippetsCollectionChanged = false;
|
||||
else
|
||||
QMessageBox::critical(Core::ICore::instance()->mainWindow(),
|
||||
tr("Error While Saving Snippet Collection"), errorString);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -33,6 +33,8 @@
|
||||
#include "nicknamedialog.h"
|
||||
#include "ui_nicknamedialog.h"
|
||||
|
||||
#include <utils/fileutils.h>
|
||||
|
||||
#include <QtCore/QDebug>
|
||||
#include <QtCore/QFile>
|
||||
#include <QtCore/QDir>
|
||||
@@ -244,15 +246,12 @@ bool NickNameDialog::populateModelFromMailCapFile(const QString &fileName,
|
||||
model->removeRows(0, rowCount);
|
||||
if (fileName.isEmpty())
|
||||
return true;
|
||||
QFile file(fileName);
|
||||
if (!file.open(QIODevice::ReadOnly|QIODevice::Text)) {
|
||||
*errorMessage = tr("Cannot open '%1': %2").
|
||||
arg(QDir::toNativeSeparators(fileName), file.errorString());
|
||||
Utils::FileReader reader;
|
||||
if (!reader.fetch(fileName, QIODevice::Text, errorMessage))
|
||||
return false;
|
||||
}
|
||||
// Split into lines and read
|
||||
NickNameEntry entry;
|
||||
const QStringList lines = QString::fromUtf8(file.readAll()).trimmed().split(QLatin1Char('\n'));
|
||||
const QStringList lines = QString::fromUtf8(reader.data()).trimmed().split(QLatin1Char('\n'));
|
||||
const int count = lines.size();
|
||||
for (int i = 0; i < count; i++) {
|
||||
if (entry.parse(lines.at(i))) {
|
||||
|
||||
@@ -232,13 +232,11 @@ static inline QStringList fieldTexts(const QString &fileContents)
|
||||
|
||||
void VCSBaseSubmitEditor::createUserFields(const QString &fieldConfigFile)
|
||||
{
|
||||
QFile fieldFile(fieldConfigFile);
|
||||
if (!fieldFile.open(QIODevice::ReadOnly|QIODevice::Text)) {
|
||||
qWarning("%s: Unable to open %s: %s", Q_FUNC_INFO, qPrintable(fieldConfigFile), qPrintable(fieldFile.errorString()));
|
||||
Utils::FileReader reader;
|
||||
if (!reader.fetch(fieldConfigFile, QIODevice::Text, Core::ICore::instance()->mainWindow()))
|
||||
return;
|
||||
}
|
||||
// Parse into fields
|
||||
const QStringList fields = fieldTexts(QString::fromUtf8(fieldFile.readAll()));
|
||||
const QStringList fields = fieldTexts(QString::fromUtf8(reader.data()));
|
||||
if (fields.empty())
|
||||
return;
|
||||
// Create a completer on user names
|
||||
@@ -613,24 +611,17 @@ bool VCSBaseSubmitEditor::runSubmitMessageCheckScript(const QString &checkScript
|
||||
if (!tempFilePattern.endsWith(QDir::separator()))
|
||||
tempFilePattern += QDir::separator();
|
||||
tempFilePattern += QLatin1String("msgXXXXXX.txt");
|
||||
QTemporaryFile messageFile(tempFilePattern);
|
||||
messageFile.setAutoRemove(true);
|
||||
if (!messageFile.open()) {
|
||||
*errorMessage = tr("Unable to open '%1': %2").
|
||||
arg(QDir::toNativeSeparators(messageFile.fileName()),
|
||||
messageFile.errorString());
|
||||
Utils::TempFileSaver saver(tempFilePattern);
|
||||
saver.write(fileContents().toUtf8());
|
||||
if (!saver.finalize(errorMessage))
|
||||
return false;
|
||||
}
|
||||
const QString messageFileName = messageFile.fileName();
|
||||
messageFile.write(fileContents().toUtf8());
|
||||
messageFile.close();
|
||||
// Run check process
|
||||
VCSBaseOutputWindow *outputWindow = VCSBaseOutputWindow::instance();
|
||||
outputWindow->appendCommand(msgCheckScript(m_d->m_checkScriptWorkingDirectory, checkScript));
|
||||
QProcess checkProcess;
|
||||
if (!m_d->m_checkScriptWorkingDirectory.isEmpty())
|
||||
checkProcess.setWorkingDirectory(m_d->m_checkScriptWorkingDirectory);
|
||||
checkProcess.start(checkScript, QStringList(messageFileName));
|
||||
checkProcess.start(checkScript, QStringList(saver.fileName()));
|
||||
checkProcess.closeWriteChannel();
|
||||
if (!checkProcess.waitForStarted()) {
|
||||
*errorMessage = tr("The check script '%1' could not be started: %2").arg(checkScript, checkProcess.errorString());
|
||||
|
||||
Reference in New Issue
Block a user