Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
F
flatpak-qt-creator
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Marco Bubke
flatpak-qt-creator
Commits
45c9cf7a
Commit
45c9cf7a
authored
Mar 30, 2011
by
Oswald Buddenhagen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add/unify i/o error handling
lots of use of Utils::FileSaver and Utils::FileReader Task-number: QTCREATORBUG-1619
parent
fae7dc95
Changes
70
Show whitespace changes
Inline
Side-by-side
Showing
70 changed files
with
632 additions
and
710 deletions
+632
-710
src/libs/extensionsystem/pluginspec.cpp
src/libs/extensionsystem/pluginspec.cpp
+2
-3
src/libs/utils/ssh/sshconnection.cpp
src/libs/utils/ssh/sshconnection.cpp
+5
-10
src/plugins/coreplugin/actionmanager/commandsfile.cpp
src/plugins/coreplugin/actionmanager/commandsfile.cpp
+31
-29
src/plugins/coreplugin/basefilewizard.cpp
src/plugins/coreplugin/basefilewizard.cpp
+5
-12
src/plugins/coreplugin/externaltool.cpp
src/plugins/coreplugin/externaltool.cpp
+39
-47
src/plugins/cpaster/cpasterplugin.cpp
src/plugins/cpaster/cpasterplugin.cpp
+9
-27
src/plugins/cpaster/fileshareprotocol.cpp
src/plugins/cpaster/fileshareprotocol.cpp
+21
-18
src/plugins/cpptools/cppfilesettingspage.cpp
src/plugins/cpptools/cppfilesettingspage.cpp
+13
-18
src/plugins/cpptools/cppfindreferences.cpp
src/plugins/cpptools/cppfindreferences.cpp
+4
-3
src/plugins/cvs/cvsplugin.cpp
src/plugins/cvs/cvsplugin.cpp
+9
-11
src/plugins/debugger/debuggerplugin.cpp
src/plugins/debugger/debuggerplugin.cpp
+10
-7
src/plugins/debugger/gdb/classicgdbengine.cpp
src/plugins/debugger/gdb/classicgdbengine.cpp
+2
-4
src/plugins/debugger/logwindow.cpp
src/plugins/debugger/logwindow.cpp
+4
-9
src/plugins/designer/qtcreatorintegration.cpp
src/plugins/designer/qtcreatorintegration.cpp
+4
-3
src/plugins/genericprojectmanager/genericproject.cpp
src/plugins/genericprojectmanager/genericproject.cpp
+9
-8
src/plugins/git/gitclient.cpp
src/plugins/git/gitclient.cpp
+9
-11
src/plugins/git/gitplugin.cpp
src/plugins/git/gitplugin.cpp
+8
-10
src/plugins/help/generalsettingspage.cpp
src/plugins/help/generalsettingspage.cpp
+10
-3
src/plugins/help/helpviewer.cpp
src/plugins/help/helpviewer.cpp
+12
-14
src/plugins/macros/macro.cpp
src/plugins/macros/macro.cpp
+18
-8
src/plugins/macros/macro.h
src/plugins/macros/macro.h
+7
-3
src/plugins/macros/macromanager.cpp
src/plugins/macros/macromanager.cpp
+11
-9
src/plugins/memcheck/suppressiondialog.cpp
src/plugins/memcheck/suppressiondialog.cpp
+6
-6
src/plugins/mercurial/mercurialclient.cpp
src/plugins/mercurial/mercurialclient.cpp
+7
-4
src/plugins/perforce/perforceplugin.cpp
src/plugins/perforce/perforceplugin.cpp
+31
-30
src/plugins/perforce/perforceplugin.h
src/plugins/perforce/perforceplugin.h
+3
-1
src/plugins/projectexplorer/customwizard/customwizard.cpp
src/plugins/projectexplorer/customwizard/customwizard.cpp
+5
-8
src/plugins/projectexplorer/msvctoolchain.cpp
src/plugins/projectexplorer/msvctoolchain.cpp
+15
-25
src/plugins/projectexplorer/persistentsettings.cpp
src/plugins/projectexplorer/persistentsettings.cpp
+26
-23
src/plugins/projectexplorer/persistentsettings.h
src/plugins/projectexplorer/persistentsettings.h
+5
-1
src/plugins/projectexplorer/session.cpp
src/plugins/projectexplorer/session.cpp
+1
-1
src/plugins/projectexplorer/toolchainmanager.cpp
src/plugins/projectexplorer/toolchainmanager.cpp
+2
-1
src/plugins/projectexplorer/userfileaccessor.cpp
src/plugins/projectexplorer/userfileaccessor.cpp
+1
-1
src/plugins/qmldesigner/components/formeditor/formeditorwidget.cpp
...ns/qmldesigner/components/formeditor/formeditorwidget.cpp
+5
-9
src/plugins/qmldesigner/components/integration/designdocumentcontroller.cpp
...igner/components/integration/designdocumentcontroller.cpp
+10
-18
src/plugins/qmldesigner/components/integration/designdocumentcontroller.h
...esigner/components/integration/designdocumentcontroller.h
+0
-1
src/plugins/qmldesigner/components/itemlibrary/itemlibrarywidget.cpp
.../qmldesigner/components/itemlibrary/itemlibrarywidget.cpp
+4
-13
src/plugins/qmldesigner/components/navigator/navigatorwidget.cpp
...gins/qmldesigner/components/navigator/navigatorwidget.cpp
+5
-12
src/plugins/qmldesigner/components/propertyeditor/basicwidgets.cpp
...ns/qmldesigner/components/propertyeditor/basicwidgets.cpp
+6
-7
src/plugins/qmldesigner/components/propertyeditor/propertyeditor.cpp
.../qmldesigner/components/propertyeditor/propertyeditor.cpp
+4
-4
src/plugins/qmldesigner/designmodewidget.cpp
src/plugins/qmldesigner/designmodewidget.cpp
+5
-11
src/plugins/qmldesigner/styledoutputpaneplaceholder.cpp
src/plugins/qmldesigner/styledoutputpaneplaceholder.cpp
+5
-7
src/plugins/qmljstools/qmljsplugindumper.cpp
src/plugins/qmljstools/qmljsplugindumper.cpp
+5
-8
src/plugins/qmlprojectmanager/qmlproject.cpp
src/plugins/qmlprojectmanager/qmlproject.cpp
+5
-4
src/plugins/qt4projectmanager/customwidgetwizard/plugingenerator.cpp
.../qt4projectmanager/customwidgetwizard/plugingenerator.cpp
+8
-11
src/plugins/qt4projectmanager/qt-maemo/maemodeviceconfigwizard.cpp
...ns/qt4projectmanager/qt-maemo/maemodeviceconfigwizard.cpp
+5
-7
src/plugins/qt4projectmanager/qt-maemo/maemokeydeployer.cpp
src/plugins/qt4projectmanager/qt-maemo/maemokeydeployer.cpp
+5
-8
src/plugins/qt4projectmanager/qt-maemo/maemosshconfigdialog.cpp
...ugins/qt4projectmanager/qt-maemo/maemosshconfigdialog.cpp
+4
-10
src/plugins/qt4projectmanager/qt-maemo/qt4maemotarget.cpp
src/plugins/qt4projectmanager/qt-maemo/qt4maemotarget.cpp
+4
-6
src/plugins/qt4projectmanager/qt-s60/s60createpackagestep.cpp
...plugins/qt4projectmanager/qt-s60/s60createpackagestep.cpp
+6
-3
src/plugins/qt4projectmanager/qt-s60/s60publisherovi.cpp
src/plugins/qt4projectmanager/qt-s60/s60publisherovi.cpp
+11
-12
src/plugins/qt4projectmanager/qt4nodes.cpp
src/plugins/qt4projectmanager/qt4nodes.cpp
+13
-17
src/plugins/qt4projectmanager/wizards/abstractmobileapp.cpp
src/plugins/qt4projectmanager/wizards/abstractmobileapp.cpp
+25
-33
src/plugins/qt4projectmanager/wizards/abstractmobileapp.h
src/plugins/qt4projectmanager/wizards/abstractmobileapp.h
+1
-0
src/plugins/qt4projectmanager/wizards/guiappwizard.cpp
src/plugins/qt4projectmanager/wizards/guiappwizard.cpp
+5
-5
src/plugins/qt4projectmanager/wizards/mobileappwizardpages.cpp
...lugins/qt4projectmanager/wizards/mobileappwizardpages.cpp
+9
-6
src/plugins/resourceeditor/resourceeditorw.cpp
src/plugins/resourceeditor/resourceeditorw.cpp
+6
-8
src/plugins/subversion/subversionplugin.cpp
src/plugins/subversion/subversionplugin.cpp
+10
-11
src/plugins/texteditor/basefilefind.cpp
src/plugins/texteditor/basefilefind.cpp
+11
-12
src/plugins/texteditor/colorscheme.cpp
src/plugins/texteditor/colorscheme.cpp
+34
-32
src/plugins/texteditor/colorscheme.h
src/plugins/texteditor/colorscheme.h
+5
-1
src/plugins/texteditor/fontsettings.cpp
src/plugins/texteditor/fontsettings.cpp
+2
-1
src/plugins/texteditor/fontsettingspage.cpp
src/plugins/texteditor/fontsettingspage.cpp
+5
-4
src/plugins/texteditor/generichighlighter/definitiondownloader.cpp
...ns/texteditor/generichighlighter/definitiondownloader.cpp
+5
-8
src/plugins/texteditor/refactoringchanges.cpp
src/plugins/texteditor/refactoringchanges.cpp
+14
-10
src/plugins/texteditor/snippets/snippetscollection.cpp
src/plugins/texteditor/snippets/snippetscollection.cpp
+26
-18
src/plugins/texteditor/snippets/snippetscollection.h
src/plugins/texteditor/snippets/snippetscollection.h
+1
-1
src/plugins/texteditor/snippets/snippetssettingspage.cpp
src/plugins/texteditor/snippets/snippetssettingspage.cpp
+7
-2
src/plugins/vcsbase/nicknamedialog.cpp
src/plugins/vcsbase/nicknamedialog.cpp
+5
-6
src/plugins/vcsbase/vcsbasesubmiteditor.cpp
src/plugins/vcsbase/vcsbasesubmiteditor.cpp
+7
-16
No files found.
src/libs/extensionsystem/pluginspec.cpp
View file @
45c9cf7a
...
...
@@ -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
();
...
...
src/libs/utils/ssh/sshconnection.cpp
View file @
45c9cf7a
...
...
@@ -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
);
}
...
...
src/plugins/coreplugin/actionmanager/commandsfile.cpp
View file @
45c9cf7a
...
...
@@ -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
...
...
src/plugins/coreplugin/basefilewizard.cpp
View file @
45c9cf7a
...
...
@@ -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
...
...
src/plugins/coreplugin/externaltool.cpp
View file @
45c9cf7a
...
...
@@ -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
...
...
src/plugins/cpaster/cpasterplugin.cpp
View file @
45c9cf7a
...
...
@@ -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
);
...
...
src/plugins/cpaster/fileshareprotocol.cpp
View file @
45c9cf7a
...
...
@@ -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
src/plugins/cpptools/cppfilesettingspage.cpp
View file @
45c9cf7a
...
...
@@ -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
);
}
...
...
src/plugins/cpptools/cppfindreferences.cpp
View file @
45c9cf7a
...
...
@@ -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
Q
TextStream
(
&
file
).
readAll
();
// ### FIXME
return
Q
String
::
fromLocal8Bit
(
reader
.
data
());
// ### FIXME encoding
}
}
...
...
src/plugins/cvs/cvsplugin.cpp
View file @
45c9cf7a
...
...
@@ -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
);
...
...
src/plugins/debugger/debuggerplugin.cpp
View file @
45c9cf7a
...
...
@@ -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. */
...
...
src/plugins/debugger/gdb/classicgdbengine.cpp
View file @
45c9cf7a
...
...
@@ -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
;
}
...
...
src/plugins/debugger/logwindow.cpp
View file @
45c9cf7a
...
...
@@ -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
;
}
...
...
src/plugins/designer/qtcreatorintegration.cpp
View file @
45c9cf7a
...
...
@@ -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
=
Q
TextStream
(
&
file
).
readAll
();
// ### FIXME
Utils
::
FileReader
reader
;
if
(
reader
.
fetch
(
fileName
))
// ### FIXME error reporting
src
=
Q
String
::
fromLocal8Bit
(
reader
.
data
());
// ### FIXME encoding
}
QByteArray
source
=
snapshot
.
preprocessedCode
(
src
,
fileName
);
...
...
src/plugins/genericprojectmanager/genericproject.cpp
View file @
45c9cf7a
...
...
@@ -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
;
}
...
...
src/plugins/git/gitclient.cpp
View file @
45c9cf7a
...
...
@@ -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
;
...
...
src/plugins/git/gitplugin.cpp
View file @
45c9cf7a
...
...
@@ -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
();