QTemporaryDir/File: cleanups (static internal function, QScopedPointer)

Change-Id: I61311d151e2ae94a22df58297bbfb7a636a01c4a
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
David Faure 2011-12-08 16:00:33 +01:00 committed by Qt by Nokia
parent ee18d6ea1f
commit 757ef710d8
3 changed files with 10 additions and 13 deletions

View File

@ -66,7 +66,6 @@ public:
QTemporaryDirPrivate();
~QTemporaryDirPrivate();
QString defaultTemplateName() const;
void create(const QString &templateName);
QString path;
@ -84,7 +83,7 @@ QTemporaryDirPrivate::~QTemporaryDirPrivate()
{
}
QString QTemporaryDirPrivate::defaultTemplateName() const
static QString defaultTemplateName()
{
QString baseName;
#if defined(QT_BUILD_CORE_LIB)
@ -167,14 +166,14 @@ void QTemporaryDirPrivate::create(const QString &templateName)
QTemporaryDir::QTemporaryDir()
: d_ptr(new QTemporaryDirPrivate)
{
d_ptr->create(d_ptr->defaultTemplateName());
d_ptr->create(defaultTemplateName());
}
QTemporaryDir::QTemporaryDir(const QString &templateName)
: d_ptr(new QTemporaryDirPrivate)
{
if (templateName.isEmpty())
d_ptr->create(d_ptr->defaultTemplateName());
d_ptr->create(defaultTemplateName());
else
d_ptr->create(templateName);
}
@ -188,9 +187,8 @@ QTemporaryDir::QTemporaryDir(const QString &templateName)
*/
QTemporaryDir::~QTemporaryDir()
{
if (d_ptr->success && d_ptr->autoRemove)
if (d_ptr->autoRemove)
remove();
delete d_ptr;
}
/*!

View File

@ -43,6 +43,7 @@
#define QTEMPORARYDIR_H
#include <QtCore/qdir.h>
#include <QtCore/QScopedPointer>
QT_BEGIN_HEADER
@ -70,7 +71,7 @@ public:
QString path() const;
private:
QTemporaryDirPrivate* const d_ptr;
QScopedPointer<QTemporaryDirPrivate> d_ptr;
Q_DISABLE_COPY(QTemporaryDir)
};

View File

@ -439,8 +439,6 @@ protected:
QTemporaryFilePrivate();
~QTemporaryFilePrivate();
QString defaultTemplateName() const;
bool autoRemove;
QString templateName;
};
@ -453,7 +451,7 @@ QTemporaryFilePrivate::~QTemporaryFilePrivate()
{
}
QString QTemporaryFilePrivate::defaultTemplateName() const
static QString defaultTemplateName()
{
QString baseName;
#if defined(QT_BUILD_CORE_LIB)
@ -518,7 +516,7 @@ QTemporaryFile::QTemporaryFile()
: QFile(*new QTemporaryFilePrivate)
{
Q_D(QTemporaryFile);
d->templateName = d->defaultTemplateName();
d->templateName = defaultTemplateName();
}
QTemporaryFile::QTemporaryFile(const QString &templateName)
@ -541,7 +539,7 @@ QTemporaryFile::QTemporaryFile()
: QFile(*new QTemporaryFilePrivate, 0)
{
Q_D(QTemporaryFile);
d->templateName = d->defaultTemplateName();
d->templateName = defaultTemplateName();
}
/*!
@ -577,7 +575,7 @@ QTemporaryFile::QTemporaryFile(QObject *parent)
: QFile(*new QTemporaryFilePrivate, parent)
{
Q_D(QTemporaryFile);
d->templateName = d->defaultTemplateName();
d->templateName = defaultTemplateName();
}
/*!