summaryrefslogtreecommitdiffstats
path: root/src/corelib/io
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@nokia.com>2009-08-31 17:34:10 (GMT)
committerThiago Macieira <thiago.macieira@nokia.com>2009-08-31 17:34:10 (GMT)
commit0d411622521a89c04a416e2aaf3da44b6015b183 (patch)
tree51e61cea6b56b40d359a8914f59bf3297a5e0d3e /src/corelib/io
parent3b65bb32fda7e34373b64f416ea92a3fa6eb266c (diff)
parent20cc50a21eb5841b3a3e8546877e805f5a4df528 (diff)
downloadQt-0d411622521a89c04a416e2aaf3da44b6015b183.zip
Qt-0d411622521a89c04a416e2aaf3da44b6015b183.tar.gz
Qt-0d411622521a89c04a416e2aaf3da44b6015b183.tar.bz2
Merge branch '4.5' into 4.6
Diffstat (limited to 'src/corelib/io')
-rw-r--r--src/corelib/io/qtemporaryfile.cpp38
1 files changed, 30 insertions, 8 deletions
diff --git a/src/corelib/io/qtemporaryfile.cpp b/src/corelib/io/qtemporaryfile.cpp
index 48f34d6..fa3ed09 100644
--- a/src/corelib/io/qtemporaryfile.cpp
+++ b/src/corelib/io/qtemporaryfile.cpp
@@ -292,14 +292,20 @@ class QTemporaryFileEngine : public QFSFileEngine
Q_DECLARE_PRIVATE(QFSFileEngine)
public:
QTemporaryFileEngine(const QString &file, bool fileIsTemplate = true)
- : QFSFileEngine(file), filePathIsTemplate(fileIsTemplate)
+ : QFSFileEngine(), filePathIsTemplate(fileIsTemplate)
{
+ Q_D(QFSFileEngine);
+ d->filePath = file;
+
+ if (!filePathIsTemplate)
+ QFSFileEngine::setFileName(file);
}
~QTemporaryFileEngine();
bool isReallyOpen();
void setFileName(const QString &file);
+ void setFileTemplate(const QString &fileTemplate);
bool open(QIODevice::OpenMode flags);
bool remove();
@@ -336,6 +342,13 @@ void QTemporaryFileEngine::setFileName(const QString &file)
QFSFileEngine::setFileName(file);
}
+void QTemporaryFileEngine::setFileTemplate(const QString &fileTemplate)
+{
+ Q_D(QFSFileEngine);
+ if (filePathIsTemplate)
+ d->filePath = fileTemplate;
+}
+
bool QTemporaryFileEngine::open(QIODevice::OpenMode openMode)
{
Q_D(QFSFileEngine);
@@ -382,12 +395,19 @@ bool QTemporaryFileEngine::open(QIODevice::OpenMode openMode)
return false;
}
+ QString template_ = d->filePath;
d->filePath = QString::fromLocal8Bit(filename);
- filePathIsTemplate = false;
d->nativeInitFileName();
- d->closeFileHandle = true;
delete [] filename;
- return QFSFileEngine::open(openMode);
+
+ if (QFSFileEngine::open(openMode)) {
+ filePathIsTemplate = false;
+ return true;
+ }
+
+ d->filePath = template_;
+ d->nativeFilePath.clear();
+ return false;
#endif
}
@@ -533,7 +553,8 @@ QTemporaryFile::QTemporaryFile()
QTemporaryFile::QTemporaryFile(const QString &templateName)
: QFile(*new QTemporaryFilePrivate, 0)
{
- setFileTemplate(templateName);
+ Q_D(QTemporaryFile);
+ d->templateName = templateName;
}
/*!
@@ -567,7 +588,8 @@ QTemporaryFile::QTemporaryFile(QObject *parent)
QTemporaryFile::QTemporaryFile(const QString &templateName, QObject *parent)
: QFile(*new QTemporaryFilePrivate, parent)
{
- setFileTemplate(templateName);
+ Q_D(QTemporaryFile);
+ d->templateName = templateName;
}
#endif
@@ -671,10 +693,10 @@ QString QTemporaryFile::fileTemplate() const
*/
void QTemporaryFile::setFileTemplate(const QString &name)
{
- Q_ASSERT(!isOpen());
Q_D(QTemporaryFile);
- fileEngine()->setFileName(name);
d->templateName = name;
+ if (d->fileEngine)
+ static_cast<QTemporaryFileEngine*>(d->fileEngine)->setFileTemplate(name);
}
/*!