Doc: Improve QTemporaryFile::open() descriptions
Explain the behavior of open() in detail, including the edge cases (reopening a file). Fix links to QIODeviceBase::OpenMode flags. Use explicit links to make linking more robust. Use the same parameter name 'mode' as in the base class. Pick-to: 6.8 Task-number: QTBUG-131484 Change-Id: I5d01b3bb48a7a439b93c144e6d38482607de8d33 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> (cherry picked from commit adaf1fb107ceb7003313ceb67605f986b74763b1) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
parent
b70e61788f
commit
604dcc714a
@ -738,12 +738,19 @@ QTemporaryFile::~QTemporaryFile()
|
|||||||
/*!
|
/*!
|
||||||
\fn bool QTemporaryFile::open()
|
\fn bool QTemporaryFile::open()
|
||||||
|
|
||||||
A QTemporaryFile will always be opened in QIODevice::ReadWrite mode,
|
Opens a unique temporary file in the file system in
|
||||||
this allows easy access to the data in the file. This function will
|
\l QIODeviceBase::ReadWrite mode.
|
||||||
return true upon success and will set the fileName() to the unique
|
Returns \c true if the file was successfully opened, or was already open.
|
||||||
filename used.
|
Otherwise returns \c false.
|
||||||
|
|
||||||
\sa fileName(), QT_USE_NODISCARD_FILE_OPEN
|
If called for the first time, open() will create a unique file name
|
||||||
|
based on \l fileTemplate(). The file is guaranteed to have been created
|
||||||
|
by this function (that is, it has never existed before).
|
||||||
|
|
||||||
|
If a file is reopened after calling \l close(), the same file will be
|
||||||
|
opened again.
|
||||||
|
|
||||||
|
\sa setFileTemplate(), QT_USE_NODISCARD_FILE_OPEN
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@ -966,16 +973,26 @@ QTemporaryFile *QTemporaryFile::createNativeFile(QFile &file)
|
|||||||
/*!
|
/*!
|
||||||
\reimp
|
\reimp
|
||||||
|
|
||||||
Creates a unique file name for the temporary file, and opens it. You can
|
Opens a unique temporary file in the file system with \a mode flags.
|
||||||
get the unique name later by calling fileName(). The file is guaranteed to
|
Returns \c true if the file was successfully opened, or was already open.
|
||||||
have been created by this function (i.e., it has never existed before).
|
Otherwise returns \c false.
|
||||||
|
|
||||||
|
If called for the first time, open() will create a unique file name
|
||||||
|
based on \l fileTemplate(), and open it with \a mode flags.
|
||||||
|
The file is guaranteed to have been created by this function (that is,
|
||||||
|
it has never existed before).
|
||||||
|
|
||||||
|
If a file is reopened after calling \l close(), the same file will be
|
||||||
|
opened again with \a mode flags.
|
||||||
|
|
||||||
|
\sa setFileTemplate(), QT_USE_NODISCARD_FILE_OPEN
|
||||||
*/
|
*/
|
||||||
bool QTemporaryFile::open(OpenMode flags)
|
bool QTemporaryFile::open(OpenMode mode)
|
||||||
{
|
{
|
||||||
Q_D(QTemporaryFile);
|
Q_D(QTemporaryFile);
|
||||||
auto tef = static_cast<QTemporaryFileEngine *>(d->fileEngine.get());
|
auto tef = static_cast<QTemporaryFileEngine *>(d->fileEngine.get());
|
||||||
if (tef && tef->isReallyOpen()) {
|
if (tef && tef->isReallyOpen()) {
|
||||||
setOpenMode(flags);
|
setOpenMode(mode);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -986,7 +1003,7 @@ bool QTemporaryFile::open(OpenMode flags)
|
|||||||
// d->engine();
|
// d->engine();
|
||||||
d->resetFileEngine();
|
d->resetFileEngine();
|
||||||
|
|
||||||
if (QFile::open(flags)) {
|
if (QFile::open(mode)) {
|
||||||
tef = static_cast<QTemporaryFileEngine *>(d->fileEngine.get());
|
tef = static_cast<QTemporaryFileEngine *>(d->fileEngine.get());
|
||||||
if (tef->isUnnamedFile())
|
if (tef->isUnnamedFile())
|
||||||
d->fileName.clear();
|
d->fileName.clear();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user