Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
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
Hide 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)
...
@@ -489,10 +489,9 @@ bool PluginSpecPrivate::read(const QString &fileName)
errorString
=
""
;
errorString
=
""
;
dependencies
.
clear
();
dependencies
.
clear
();
QFile
file
(
fileName
);
QFile
file
(
fileName
);
if
(
!
file
.
exists
())
return
reportError
(
tr
(
"File does not exist: %1"
).
arg
(
file
.
fileName
()));
if
(
!
file
.
open
(
QIODevice
::
ReadOnly
))
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
);
QFileInfo
fileInfo
(
file
);
location
=
fileInfo
.
absolutePath
();
location
=
fileInfo
.
absolutePath
();
filePath
=
fileInfo
.
absoluteFilePath
();
filePath
=
fileInfo
.
absoluteFilePath
();
...
...
src/libs/utils/ssh/sshconnection.cpp
View file @
45c9cf7a
...
@@ -41,6 +41,7 @@
...
@@ -41,6 +41,7 @@
#include "sshkeyexchange_p.h"
#include "sshkeyexchange_p.h"
#include <utils/qtcassert.h>
#include <utils/qtcassert.h>
#include <utils/fileutils.h>
#include <botan/exceptn.h>
#include <botan/exceptn.h>
#include <botan/init.h>
#include <botan/init.h>
...
@@ -410,18 +411,12 @@ void SshConnectionPrivate::handleServiceAcceptPacket()
...
@@ -410,18 +411,12 @@ void SshConnectionPrivate::handleServiceAcceptPacket()
m_sendFacility
.
sendUserAuthByPwdRequestPacket
(
m_connParams
.
userName
.
toUtf8
(),
m_sendFacility
.
sendUserAuthByPwdRequestPacket
(
m_connParams
.
userName
.
toUtf8
(),
SshCapabilities
::
SshConnectionService
,
m_connParams
.
password
.
toUtf8
());
SshCapabilities
::
SshConnectionService
,
m_connParams
.
password
.
toUtf8
());
}
else
{
}
else
{
QFile
privKeyFile
(
m_connParams
.
privateKeyFile
);
Utils
::
FileReader
reader
;
bool
couldOpen
=
privKeyFile
.
open
(
QIODevice
::
ReadOnly
);
if
(
!
reader
.
fetch
(
m_connParams
.
privateKeyFile
))
QByteArray
contents
;
if
(
couldOpen
)
contents
=
privKeyFile
.
readAll
();
if
(
!
couldOpen
||
privKeyFile
.
error
()
!=
QFile
::
NoError
)
{
throw
SshClientException
(
SshKeyFileError
,
throw
SshClientException
(
SshKeyFileError
,
tr
(
"Could not read private key file: %1"
)
tr
(
"Private key error: %1"
).
arg
(
reader
.
errorString
()));
.
arg
(
privKeyFile
.
errorString
()));
}
m_sendFacility
.
createAuthenticationKey
(
contents
);
m_sendFacility
.
createAuthenticationKey
(
reader
.
data
()
);
m_sendFacility
.
sendUserAuthByKeyRequestPacket
(
m_connParams
.
userName
.
toUtf8
(),
m_sendFacility
.
sendUserAuthByKeyRequestPacket
(
m_connParams
.
userName
.
toUtf8
(),
SshCapabilities
::
SshConnectionService
);
SshCapabilities
::
SshConnectionService
);
}
}
...
...
src/plugins/coreplugin/actionmanager/commandsfile.cpp
View file @
45c9cf7a
...
@@ -39,6 +39,8 @@
...
@@ -39,6 +39,8 @@
#include <utils/qtcassert.h>
#include <utils/qtcassert.h>
#include <utils/fileutils.h>
#include <QtCore/QFile>
#include <QtCore/QFile>
#include <QtCore/QXmlStreamAttributes>
#include <QtCore/QXmlStreamAttributes>
#include <QtCore/QXmlStreamWriter>
#include <QtCore/QXmlStreamWriter>
...
@@ -134,37 +136,37 @@ bool CommandsFile::exportCommands(const QList<ShortcutItem *> &items)
...
@@ -134,37 +136,37 @@ bool CommandsFile::exportCommands(const QList<ShortcutItem *> &items)
{
{
const
UniqueIDManager
*
idmanager
=
UniqueIDManager
::
instance
();
const
UniqueIDManager
*
idmanager
=
UniqueIDManager
::
instance
();
QFile
file
(
m_filename
);
Utils
::
FileSaver
saver
(
m_filename
,
QIODevice
::
Text
);
if
(
!
file
.
open
(
QIODevice
::
WriteOnly
|
QIODevice
::
Text
))
if
(
!
saver
.
hasError
())
{
return
false
;
const
Context
ctx
;
QXmlStreamWriter
w
(
saver
.
file
());
const
Context
ctx
;
w
.
setAutoFormatting
(
true
);
QXmlStreamWriter
w
(
&
file
);
w
.
setAutoFormattingIndent
(
1
);
// Historical, used to be QDom.
w
.
setAutoFormatting
(
true
);
w
.
writeStartDocument
();
w
.
setAutoFormattingIndent
(
1
);
// Historical, used to be QDom.
w
.
writeDTD
(
QLatin1String
(
"<!DOCTYPE KeyboardMappingScheme>"
));
w
.
writeStartDocument
();
w
.
writeComment
(
QString
::
fromAscii
(
" Written by Qt Creator %1, %2. "
).
w
.
writeDTD
(
QLatin1String
(
"<!DOCTYPE KeyboardMappingScheme>"
));
arg
(
QLatin1String
(
Core
::
Constants
::
IDE_VERSION_LONG
),
w
.
writeComment
(
QString
::
fromAscii
(
" Written by Qt Creator %1, %2. "
).
QDateTime
::
currentDateTime
().
toString
(
Qt
::
ISODate
)));
arg
(
QLatin1String
(
Core
::
Constants
::
IDE_VERSION_LONG
),
w
.
writeStartElement
(
ctx
.
mappingElement
);
QDateTime
::
currentDateTime
().
toString
(
Qt
::
ISODate
)));
foreach
(
const
ShortcutItem
*
item
,
items
)
{
w
.
writeStartElement
(
ctx
.
mappingElement
);
const
QString
id
=
idmanager
->
stringForUniqueIdentifier
(
item
->
m_cmd
->
id
());
foreach
(
const
ShortcutItem
*
item
,
items
)
{
if
(
item
->
m_key
.
isEmpty
())
{
const
QString
id
=
idmanager
->
stringForUniqueIdentifier
(
item
->
m_cmd
->
id
());
w
.
writeEmptyElement
(
ctx
.
shortCutElement
);
if
(
item
->
m_key
.
isEmpty
())
{
w
.
writeAttribute
(
ctx
.
idAttribute
,
id
);
w
.
writeEmptyElement
(
ctx
.
shortCutElement
);
}
else
{
w
.
writeAttribute
(
ctx
.
idAttribute
,
id
);
w
.
writeStartElement
(
ctx
.
shortCutElement
);
}
else
{
w
.
writeAttribute
(
ctx
.
idAttribute
,
id
);
w
.
writeStartElement
(
ctx
.
shortCutElement
);
w
.
writeEmptyElement
(
ctx
.
keyElement
);
w
.
writeAttribute
(
ctx
.
idAttribute
,
id
);
w
.
writeAttribute
(
ctx
.
valueAttribute
,
item
->
m_key
.
toString
());
w
.
writeEmptyElement
(
ctx
.
keyElement
);
w
.
writeEndElement
();
// Shortcut
w
.
writeAttribute
(
ctx
.
valueAttribute
,
item
->
m_key
.
toString
());
}
w
.
writeEndElement
();
// Shortcut
}
}
w
.
writeEndElement
();
w
.
writeEndDocument
();
saver
.
setResult
(
&
w
);
}
}
w
.
writeEndElement
();
return
saver
.
finalize
();
w
.
writeEndDocument
();
file
.
close
();
return
true
;
}
}
}
// namespace Internal
}
// namespace Internal
...
...
src/plugins/coreplugin/basefilewizard.cpp
View file @
45c9cf7a
...
@@ -42,6 +42,7 @@
...
@@ -42,6 +42,7 @@
#include <utils/filewizarddialog.h>
#include <utils/filewizarddialog.h>
#include <utils/qtcassert.h>
#include <utils/qtcassert.h>
#include <utils/stringutils.h>
#include <utils/stringutils.h>
#include <utils/fileutils.h>
#include <QtCore/QDir>
#include <QtCore/QDir>
#include <QtCore/QFile>
#include <QtCore/QFile>
...
@@ -179,23 +180,15 @@ bool GeneratedFile::write(QString *errorMessage) const
...
@@ -179,23 +180,15 @@ bool GeneratedFile::write(QString *errorMessage) const
return
false
;
return
false
;
}
}
}
}
// Write out
QFile
file
(
m_d
->
path
);
// Write out
QIODevice
::
OpenMode
flags
=
QIODevice
::
WriteOnly
|
QIODevice
::
Truncate
;
QIODevice
::
OpenMode
flags
=
QIODevice
::
WriteOnly
|
QIODevice
::
Truncate
;
if
(
!
isBinary
())
if
(
!
isBinary
())
flags
|=
QIODevice
::
Text
;
flags
|=
QIODevice
::
Text
;
if
(
!
file
.
open
(
flags
))
{
Utils
::
FileSaver
saver
(
m_d
->
path
,
flags
);
*
errorMessage
=
BaseFileWizard
::
tr
(
"Unable to open %1 for writing: %2"
).
arg
(
m_d
->
path
,
file
.
errorString
());
saver
.
write
(
m_d
->
contents
);
return
false
;
return
saver
.
finalize
(
errorMessage
);
}
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
;
}
}
GeneratedFile
::
Attributes
GeneratedFile
::
attributes
()
const
GeneratedFile
::
Attributes
GeneratedFile
::
attributes
()
const
...
...
src/plugins/coreplugin/externaltool.cpp
View file @
45c9cf7a
...
@@ -43,6 +43,7 @@
...
@@ -43,6 +43,7 @@
#include <utils/qtcassert.h>
#include <utils/qtcassert.h>
#include <utils/stringutils.h>
#include <utils/stringutils.h>
#include <utils/environment.h>
#include <utils/environment.h>
#include <utils/fileutils.h>
#include <QtCore/QXmlStreamReader>
#include <QtCore/QXmlStreamReader>
#include <QtCore/QXmlStreamWriter>
#include <QtCore/QXmlStreamWriter>
...
@@ -432,21 +433,15 @@ ExternalTool * ExternalTool::createFromXml(const QByteArray &xml, QString *error
...
@@ -432,21 +433,15 @@ ExternalTool * ExternalTool::createFromXml(const QByteArray &xml, QString *error
ExternalTool
*
ExternalTool
::
createFromFile
(
const
QString
&
fileName
,
QString
*
errorMessage
,
const
QString
&
locale
)
ExternalTool
*
ExternalTool
::
createFromFile
(
const
QString
&
fileName
,
QString
*
errorMessage
,
const
QString
&
locale
)
{
{
QFileInfo
info
(
fileName
);
QString
absFileName
=
QFileInfo
(
fileName
).
absoluteFilePath
();
QFile
file
(
info
.
absoluteFilePath
());
Utils
::
FileReader
reader
;
if
(
!
file
.
open
(
QIODevice
::
ReadOnly
))
{
if
(
!
reader
.
fetch
(
absFileName
,
errorMessage
))
if
(
errorMessage
)
*
errorMessage
=
tr
(
"Could not open tool specification %1 for reading: %2"
).
arg
(
fileName
,
file
.
errorString
());
return
0
;
return
0
;
}
ExternalTool
*
tool
=
ExternalTool
::
createFromXml
(
reader
.
data
(),
errorMessage
,
locale
);
const
QByteArray
&
bytes
=
file
.
readAll
();
file
.
close
();
ExternalTool
*
tool
=
ExternalTool
::
createFromXml
(
bytes
,
errorMessage
,
locale
);
if
(
!
tool
)
{
if
(
!
tool
)
{
return
0
;
return
0
;
}
}
tool
->
m_fileName
=
file
.
f
ileName
()
;
tool
->
m_fileName
=
absF
ileName
;
return
tool
;
return
tool
;
}
}
...
@@ -467,43 +462,40 @@ bool ExternalTool::save(QString *errorMessage) const
...
@@ -467,43 +462,40 @@ bool ExternalTool::save(QString *errorMessage) const
{
{
if
(
m_fileName
.
isEmpty
())
if
(
m_fileName
.
isEmpty
())
return
false
;
return
false
;
QFile
file
(
m_fileName
);
Utils
::
FileSaver
saver
(
m_fileName
);
if
(
!
file
.
open
(
QIODevice
::
WriteOnly
))
{
if
(
!
saver
.
hasError
())
{
if
(
errorMessage
)
QXmlStreamWriter
out
(
saver
.
file
());
*
errorMessage
=
tr
(
"Could not write tool specification %1: %2"
).
out
.
setAutoFormatting
(
true
);
arg
(
m_fileName
,
file
.
errorString
());
out
.
writeStartDocument
(
QLatin1String
(
"1.0"
));
return
false
;
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
);
return
saver
.
finalize
(
errorMessage
);
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
;
}
}
bool
ExternalTool
::
operator
==
(
const
ExternalTool
&
other
)
const
bool
ExternalTool
::
operator
==
(
const
ExternalTool
&
other
)
const
...
...
src/plugins/cpaster/cpasterplugin.cpp
View file @
45c9cf7a
...
@@ -52,6 +52,7 @@
...
@@ -52,6 +52,7 @@
#include <coreplugin/icore.h>
#include <coreplugin/icore.h>
#include <coreplugin/messagemanager.h>
#include <coreplugin/messagemanager.h>
#include <utils/qtcassert.h>
#include <utils/qtcassert.h>
#include <utils/fileutils.h>
#include <texteditor/basetexteditor.h>
#include <texteditor/basetexteditor.h>
#include <QtCore/QtPlugin>
#include <QtCore/QtPlugin>
...
@@ -277,23 +278,6 @@ static inline QString tempFilePattern(const QString &prefix, const QString &exte
...
@@ -277,23 +278,6 @@ static inline QString tempFilePattern(const QString &prefix, const QString &exte
return
pattern
;
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
,
void
CodepasterPlugin
::
finishFetch
(
const
QString
&
titleDescription
,
const
QString
&
content
,
const
QString
&
content
,
bool
error
)
bool
error
)
...
@@ -313,23 +297,21 @@ void CodepasterPlugin::finishFetch(const QString &titleDescription,
...
@@ -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
// 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.
// by looking at the file name of FileManager::currentFile() without expensive checking.
// Default to "txt".
// Default to "txt".
QByteArray
byteContent
=
content
.
toUtf8
();
QString
suffix
;
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
();
suffix
=
mimeType
.
preferredSuffix
();
if
(
suffix
.
isEmpty
())
if
(
suffix
.
isEmpty
())
suffix
=
QLatin1String
(
"txt"
);
suffix
=
QLatin1String
(
"txt"
);
const
QString
filePrefix
=
filePrefixFromTitle
(
titleDescription
);
const
QString
filePrefix
=
filePrefixFromTitle
(
titleDescription
);
QString
errorMessage
;
Utils
::
TempFileSaver
saver
(
tempFilePattern
(
filePrefix
,
suffix
));
TemporaryFilePtr
tempFile
=
writeTemporaryFile
(
tempFilePattern
(
filePrefix
,
suffix
),
content
,
&
errorMessage
);
saver
.
setAutoRemove
(
false
);
if
(
tempFile
.
isNull
())
{
saver
.
write
(
byteContent
);
messageManager
->
printToOutputPane
(
errorMessage
);
if
(
!
saver
.
finalize
())
{
messageManager
->
printToOutputPane
(
saver
.
errorString
());
return
;
return
;
}
}
// Keep the file and store in list of files to be removed.
const
QString
fileName
=
saver
.
fileName
();
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
();
m_fetchedSnippets
.
push_back
(
fileName
);
m_fetchedSnippets
.
push_back
(
fileName
);
// Open editor with title.
// Open editor with title.
Core
::
IEditor
*
editor
=
EditorManager
::
instance
()
->
openEditor
(
fileName
,
QString
(),
EditorManager
::
ModeSwitch
);
Core
::
IEditor
*
editor
=
EditorManager
::
instance
()
->
openEditor
(
fileName
,
QString
(),
EditorManager
::
ModeSwitch
);
...
...
src/plugins/cpaster/fileshareprotocol.cpp
View file @
45c9cf7a
...
@@ -38,6 +38,7 @@
...
@@ -38,6 +38,7 @@
#include <coreplugin/messageoutputwindow.h>
#include <coreplugin/messageoutputwindow.h>
#include <utils/qtcassert.h>
#include <utils/qtcassert.h>
#include <utils/fileutils.h>
#include <QtCore/QXmlStreamReader>
#include <QtCore/QXmlStreamReader>
#include <QtCore/QXmlStreamAttribute>
#include <QtCore/QXmlStreamAttribute>
...
@@ -195,27 +196,29 @@ void FileShareProtocol::paste(const QString &text,
...
@@ -195,27 +196,29 @@ void FileShareProtocol::paste(const QString &text,
const
QString
&
description
)
const
QString
&
description
)
{
{
// Write out temp XML file
// Write out temp XML file
QTemporaryFile
tempFile
(
m_settings
->
path
+
QLatin1Char
(
'/'
)
+
QLatin1String
(
tempPatternC
));
Utils
::
TempFileSaver
saver
(
m_settings
->
path
+
QLatin1Char
(
'/'
)
+
QLatin1String
(
tempPatternC
));
tempFile
.
setAutoRemove
(
false
);
saver
.
setAutoRemove
(
false
);
if
(
!
tempFile
.
open
())
{
if
(
!
saver
.
hasError
())
{
const
QString
msg
=
tr
(
"Unable to open a file for writing in %1: %2"
).
arg
(
m_settings
->
path
,
tempFile
.
errorString
());
// Flat text sections embedded into pasterElement
Core
::
ICore
::
instance
()
->
messageManager
()
->
printToOutputPanePopup
(
msg
);
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
;
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
);
Core
::
ICore
::
instance
()
->
messageManager
()
->
printToOutputPanePopup
(
msg
);
}
}
}
// namespace CodePaster
}
// namespace CodePaster
src/plugins/cpptools/cppfilesettingspage.cpp
View file @
45c9cf7a
...
@@ -41,6 +41,8 @@
...
@@ -41,6 +41,8 @@
#include <extensionsystem/pluginmanager.h>
#include <extensionsystem/pluginmanager.h>
#include <utils/fileutils.h>
#include <QtCore/QSettings>
#include <QtCore/QSettings>
#include <QtCore/QDebug>
#include <QtCore/QDebug>
#include <QtCore/QFile>
#include <QtCore/QFile>
...
@@ -301,25 +303,18 @@ void CppFileSettingsWidget::setSettings(const CppFileSettings &s)
...
@@ -301,25 +303,18 @@ void CppFileSettingsWidget::setSettings(const CppFileSettings &s)
void
CppFileSettingsWidget
::
slotEdit
()
void
CppFileSettingsWidget
::
slotEdit
()
{
{
QString
path
=
licenseTemplatePath
();
QString
path
=
licenseTemplatePath
();
// Edit existing file with C++
if
(
path
.
isEmpty
())
{
if
(
!
path
.
isEmpty
())
{
// Pick a file name and write new template, edit with C++
Core
::
EditorManager
::
instance
()
->
openEditor
(
path
,
QLatin1String
(
CppEditor
::
Constants
::
CPPEDITOR_ID
),
path
=
QFileDialog
::
getSaveFileName
(
this
,
tr
(
"Choose Location for New License Template File"
));
Core
::
EditorManager
::
ModeSwitch
);
if
(
path
.
isEmpty
())
return
;
return
;
}
Utils
::
FileSaver
saver
(
path
,
QIODevice
::
Text
);
// Pick a file name and write new template, edit with C++
saver
.
write
(
tr
(
licenseTemplateTemplate
).
toUtf8
());
path
=
QFileDialog
::
getSaveFileName
(
this
,
tr
(
"Choose Location for New License Template File"
));
if
(
!
saver
.
finalize
(
this
))
if
(
path
.
isEmpty
())
return
;
return
;
setLicenseTemplatePath
(
path
);
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
;
}
}
file
.
write
(
tr
(
licenseTemplateTemplate
).
toUtf8
());
// Edit (now) existing file with C++
file
.
close
();
setLicenseTemplatePath
(
path
);
Core
::
EditorManager
::
instance
()
->
openEditor
(
path
,
QLatin1String
(
CppEditor
::
Constants
::
CPPEDITOR_ID
),
Core
::
EditorManager
::
instance
()
->
openEditor
(
path
,
QLatin1String
(
CppEditor
::
Constants
::
CPPEDITOR_ID
),
Core
::
EditorManager
::
ModeSwitch
);
Core
::
EditorManager
::
ModeSwitch
);
}
}
...
...
src/plugins/cpptools/cppfindreferences.cpp
View file @
45c9cf7a
...
@@ -38,6 +38,7 @@
...
@@ -38,6 +38,7 @@
#include <find/searchresultwindow.h>
#include <find/searchresultwindow.h>
#include <extensionsystem/pluginmanager.h>
#include <extensionsystem/pluginmanager.h>
#include <utils/filesearch.h>
#include <utils/filesearch.h>
#include <utils/fileutils.h>
#include <coreplugin/progressmanager/progressmanager.h>
#include <coreplugin/progressmanager/progressmanager.h>
#include <coreplugin/progressmanager/futureprogress.h>
#include <coreplugin/progressmanager/futureprogress.h>
#include <coreplugin/editormanager/editormanager.h>
#include <coreplugin/editormanager/editormanager.h>
...
@@ -76,11 +77,11 @@ static QString getSource(const QString &fileName,
...
@@ -76,11 +77,11 @@ static QString getSource(const QString &fileName,
if
(
workingCopy
.
contains
(
fileName
))
{
if
(
workingCopy
.
contains
(
fileName
))
{
return
workingCopy
.
source
(
fileName
);
return
workingCopy
.
source
(
fileName
);
}
else
{
}
else
{
QFile
file
(
fileName
)
;
Utils
::
FileReader
reader
;
if
(
!
file
.
open
(
QFile
::
ReadOnly
))
if
(
!
reader
.
fetch
(
fileName
))
// ### FIXME error reporting
return
QString
();
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 @@
...
@@ -60,6 +60,7 @@
#include <coreplugin/editormanager/editormanager.h>
#include <coreplugin/editormanager/editormanager.h>