Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Marco Bubke
flatpak-qt-creator
Commits
45c9cf7a
Commit
45c9cf7a
authored
Mar 30, 2011
by
Oswald Buddenhagen
Browse files
add/unify i/o error handling
lots of use of Utils::FileSaver and Utils::FileReader Task-number: QTCREATORBUG-1619
parent
fae7dc95
Changes
70
Hide whitespace changes
Inline
Side-by-side
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,37 +136,37 @@ 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
;
const
Context
ctx
;
QXmlStreamWriter
w
(
&
file
);
w
.
setAutoFormatting
(
true
);
w
.
setAutoFormattingIndent
(
1
);
// Historical, used to be QDom.
w
.
writeStartDocument
();
w
.
writeDTD
(
QLatin1String
(
"<!DOCTYPE KeyboardMappingScheme>"
));
w
.
writeComment
(
QString
::
fromAscii
(
" Written by Qt Creator %1, %2. "
).
arg
(
QLatin1String
(
Core
::
Constants
::
IDE_VERSION_LONG
),
QDateTime
::
currentDateTime
().
toString
(
Qt
::
ISODate
)));
w
.
writeStartElement
(
ctx
.
mappingElement
);
foreach
(
const
ShortcutItem
*
item
,
items
)
{
const
QString
id
=
idmanager
->
stringForUniqueIdentifier
(
item
->
m_cmd
->
id
());
if
(
item
->
m_key
.
isEmpty
())
{
w
.
writeEmptyElement
(
ctx
.
shortCutElement
);
w
.
writeAttribute
(
ctx
.
idAttribute
,
id
);
}
else
{
w
.
writeStartElement
(
ctx
.
shortCutElement
);
w
.
writeAttribute
(
ctx
.
idAttribute
,
id
);
w
.
writeEmptyElement
(
ctx
.
keyElement
);
w
.
writeAttribute
(
ctx
.
valueAttribute
,
item
->
m_key
.
toString
());
w
.
writeEndElement
();
// Shortcut
Utils
::
FileSaver
saver
(
m_filename
,
QIODevice
::
Text
);
if
(
!
saver
.
hasError
())
{
const
Context
ctx
;
QXmlStreamWriter
w
(
saver
.
file
());
w
.
setAutoFormatting
(
true
);
w
.
setAutoFormattingIndent
(
1
);
// Historical, used to be QDom.
w
.
writeStartDocument
();
w
.
writeDTD
(
QLatin1String
(
"<!DOCTYPE KeyboardMappingScheme>"
));
w
.
writeComment
(
QString
::
fromAscii
(
" Written by Qt Creator %1, %2. "
).
arg
(
QLatin1String
(
Core
::
Constants
::
IDE_VERSION_LONG
),
QDateTime
::
currentDateTime
().
toString
(
Qt
::
ISODate
)));
w
.
writeStartElement
(
ctx
.
mappingElement
);
foreach
(
const
ShortcutItem
*
item
,
items
)
{
const
QString
id
=
idmanager
->
stringForUniqueIdentifier
(
item
->
m_cmd
->
id
());
if
(
item
->
m_key
.
isEmpty
())
{
w
.
writeEmptyElement
(
ctx
.
shortCutElement
);
w
.
writeAttribute
(
ctx
.
idAttribute
,
id
);
}
else
{
w
.
writeStartElement
(
ctx
.
shortCutElement
);
w
.
writeAttribute
(
ctx
.
idAttribute
,
id
);
w
.
writeEmptyElement
(
ctx
.
keyElement
);
w
.
writeAttribute
(
ctx
.
valueAttribute
,
item
->
m_key
.
toString
());
w
.
writeEndElement
();
// Shortcut
}
}
w
.
writeEndElement
();
w
.
writeEndDocument
();
saver
.
setResult
(
&
w
);
}
w
.
writeEndElement
();
w
.
writeEndDocument
();
file
.
close
();
return
true
;
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
.
f
ileName
()
;
tool
->
m_fileName
=
absF
ileName
;
return
tool
;
}
...
...
@@ -467,43 +462,40 @@ 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
;
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"
)
.
arg
(
QDateTime
::
currentDateTime
().
toString
(),
QLatin1String
(
Constants
::
IDE_VERSION_LONG
)));
out
.
writeStartElement
(
QLatin1String
(
kExternalTool
));
out
.
writeAttribute
(
QLatin1String
(
kId
),
m_id
);
out
.
writeTextElement
(
QLatin1String
(
kDescription
),
m_description
);
out
.
writeTextElement
(
QLatin1String
(
kDisplayName
),
m_displayName
);
out
.
writeTextElement
(
QLatin1String
(
kCategory
),
m_displayCategory
);
if
(
m_order
!=
-
1
)
out
.
writeTextElement
(
QLatin1String
(
kOrder
),
QString
::
number
(
m_order
));
out
.
writeStartElement
(
QLatin1String
(
kExecutable
));
out
.
writeAttribute
(
QLatin1String
(
kOutput
),
stringForOutputHandling
(
m_outputHandling
));
out
.
writeAttribute
(
QLatin1String
(
kError
),
stringForOutputHandling
(
m_errorHandling
));
out
.
writeAttribute
(
QLatin1String
(
kModifiesDocument
),
m_modifiesCurrentDocument
?
QLatin1String
(
kYes
)
:
QLatin1String
(
kNo
));
foreach
(
const
QString
&
executable
,
m_executables
)
out
.
writeTextElement
(
QLatin1String
(
kPath
),
executable
);
if
(
!
m_arguments
.
isEmpty
())
out
.
writeTextElement
(
QLatin1String
(
kArguments
),
m_arguments
);
if
(
!
m_input
.
isEmpty
())
out
.
writeTextElement
(
QLatin1String
(
kInput
),
m_input
);
if
(
!
m_workingDirectory
.
isEmpty
())
out
.
writeTextElement
(
QLatin1String
(
kWorkingDirectory
),
m_workingDirectory
);
out
.
writeEndElement
();
out
.
writeEndDocument
();
saver
.
setResult
(
&
out
);
}
QXmlStreamWriter
out
(
&
file
);
out
.
setAutoFormatting
(
true
);
out
.
writeStartDocument
(
QLatin1String
(
"1.0"
));
out
.
writeComment
(
QString
::
fromLatin1
(
"Written on %1 by Qt Creator %2"
)
.
arg
(
QDateTime
::
currentDateTime
().
toString
(),
QLatin1String
(
Constants
::
IDE_VERSION_LONG
)));
out
.
writeStartElement
(
QLatin1String
(
kExternalTool
));
out
.
writeAttribute
(
QLatin1String
(
kId
),
m_id
);
out
.
writeTextElement
(
QLatin1String
(
kDescription
),
m_description
);
out
.
writeTextElement
(
QLatin1String
(
kDisplayName
),
m_displayName
);
out
.
writeTextElement
(
QLatin1String
(
kCategory
),
m_displayCategory
);
if
(
m_order
!=
-
1
)
out
.
writeTextElement
(
QLatin1String
(
kOrder
),
QString
::
number
(
m_order
));
out
.
writeStartElement
(
QLatin1String
(
kExecutable
));
out
.
writeAttribute
(
QLatin1String
(
kOutput
),
stringForOutputHandling
(
m_outputHandling
));
out
.
writeAttribute
(
QLatin1String
(
kError
),
stringForOutputHandling
(
m_errorHandling
));
out
.
writeAttribute
(
QLatin1String
(
kModifiesDocument
),
m_modifiesCurrentDocument
?
QLatin1String
(
kYes
)
:
QLatin1String
(
kNo
));
foreach
(
const
QString
&
executable
,
m_executables
)
out
.
writeTextElement
(
QLatin1String
(
kPath
),
executable
);
if
(
!
m_arguments
.
isEmpty
())
out
.
writeTextElement
(
QLatin1String
(
kArguments
),
m_arguments
);
if
(
!
m_input
.
isEmpty
())
out
.
writeTextElement
(
QLatin1String
(
kInput
),
m_input
);
if
(
!
m_workingDirectory
.
isEmpty
())
out
.
writeTextElement
(
QLatin1String
(
kWorkingDirectory
),
m_workingDirectory
);
out
.
writeEndElement
();
out
.
writeEndDocument
();
file
.
close
();
return
true
;
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
(
c
ontent
.
toUtf8
()
))
if
(
const
Core
::
MimeType
mimeType
=
Core
::
ICore
::
instance
()
->
mimeDatabase
()
->
findByData
(
byteC
ontent
))
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,27 +196,29 @@ 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
);
Utils
::
TempFileSaver
saver
(
m_settings
->
path
+
QLatin1Char
(
'/'
)
+
QLatin1String
(
tempPatternC
));
saver
.
setAutoRemove
(
false
);
if
(
!
saver
.
hasError
())
{
// Flat text sections embedded into pasterElement
QXmlStreamWriter
writer
(
saver
.
file
());
writer
.
writeStartDocument
();
writer
.
writeStartElement
(
QLatin1String
(
pasterElementC
));
writer
.
writeTextElement
(
QLatin1String
(
userElementC
),
username
);
writer
.
writeTextElement
(
QLatin1String
(
descriptionElementC
),
description
);
writer
.
writeTextElement
(
QLatin1String
(
textElementC
),
text
);
writer
.
writeEndElement
();
writer
.
writeEndDocument
();
saver
.
setResult
(
&
writer
);
}
if
(
!
saver
.
finalize
())
{
Core
::
ICore
::
instance
()
->
messageManager
()
->
printToOutputPanePopup
(
saver
.
errorString
());
return
;
}
// Flat text sections embedded into pasterElement
QXmlStreamWriter
writer
(
&
tempFile
);
writer
.
writeStartDocument
();
writer
.
writeStartElement
(
QLatin1String
(
pasterElementC
));
writer
.
writeTextElement
(
QLatin1String
(
userElementC
),
username
);
writer
.
writeTextElement
(
QLatin1String
(
descriptionElementC
),
description
);
writer
.
writeTextElement
(
QLatin1String
(
textElementC
),
text
);
writer
.
writeEndElement
();
writer
.
writeEndDocument
();
tempFile
.
close
();
const
QString
msg
=
tr
(
"Pasted: %1"
).
arg
(
tempFile
.
fileName
());
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
;
}
// 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
()));
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
;
Utils
::
FileSaver
saver
(
path
,
QIODevice
::
Text
);
saver
.
write
(
tr
(
licenseTemplateTemplate
).
toUtf8
());
if
(
!
saver
.
finalize
(
this
))
return
;
setLicenseTemplatePath
(
path
);
}
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
);
ts
<<
m_logWindow
->
inputContents
();
ts
<<
"
\n\n
=======================================
\n\n
"
;
ts
<<
m_logWindow
->
combinedContents
();
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>