summaryrefslogtreecommitdiffstats
path: root/src/gui/kernel
diff options
context:
space:
mode:
authormread <qt-info@nokia.com>2011-01-07 11:07:08 (GMT)
committerJoão Abecasis <joao.abecasis@nokia.com>2011-02-10 12:26:33 (GMT)
commitf29b95cef0441958050c86d3544cdfde32e9e62e (patch)
tree1020798e76164f3597b34cf590d3d5b3f06191ae /src/gui/kernel
parent977638104d091dd8780f4d1bee79bf014d6a2fe9 (diff)
downloadQt-f29b95cef0441958050c86d3544cdfde32e9e62e.zip
Qt-f29b95cef0441958050c86d3544cdfde32e9e62e.tar.gz
Qt-f29b95cef0441958050c86d3544cdfde32e9e62e.tar.bz2
Using QFile open by RFile and take ownership of handle
QFileOpenEvent's open method now opens the QFile with an RFile handle if possible. It takes a duplicate of the handle and transfers ownership to the QFile, so that the QFile can be used many times and outside of the lifetime of the QFileOpenEvent. Task-number: QTBUG-15015 Reviewed-by: Shane Kearns
Diffstat (limited to 'src/gui/kernel')
-rw-r--r--src/gui/kernel/qevent.cpp18
-rw-r--r--src/gui/kernel/qevent.h2
2 files changed, 13 insertions, 7 deletions
diff --git a/src/gui/kernel/qevent.cpp b/src/gui/kernel/qevent.cpp
index 8f2e6cb..17bcbfb 100644
--- a/src/gui/kernel/qevent.cpp
+++ b/src/gui/kernel/qevent.cpp
@@ -3099,9 +3099,11 @@ QUrl QFileOpenEvent::url() const
}
/*!
- \fn void openFile(QFile &file, QIODevice::OpenMode flags) const
+ \fn bool openFile(QFile &file, QIODevice::OpenMode flags) const
Opens a QFile on the file referenced by this event.
+ Returns true if successful; otherwise returns false.
+
This is necessary as some files cannot be opened with the filename alone, but require specific
information stored in this event.
For example, if this QFileOpenEvent contains a request to open a Symbian data caged file,
@@ -3109,18 +3111,22 @@ QUrl QFileOpenEvent::url() const
\since 4.8
*/
-void QFileOpenEvent::openFile(QFile &file, QIODevice::OpenMode flags) const
+bool QFileOpenEvent::openFile(QFile &file, QIODevice::OpenMode flags) const
{
file.setFileName(f);
#ifdef Q_OS_SYMBIAN
const QFileOpenEventPrivate *priv = reinterpret_cast<const QFileOpenEventPrivate *>(d);
if (priv->file.SubSessionHandle()) {
- // TODO return a QFile opened from the file handle
- file.open(flags);
- return;
+ RFile dup;
+ if (dup.Duplicate(priv->file) == KErrNone) {
+ QScopedPointer<RFile, QScopedPointerRCloser<RFile> > dupCloser(&dup);
+ bool open = file.open(dup, flags, QFile::AutoCloseHandle);
+ dupCloser.take();
+ return open;
+ }
}
#endif
- file.open(flags);
+ return file.open(flags);
}
#ifndef QT_NO_TOOLBAR
diff --git a/src/gui/kernel/qevent.h b/src/gui/kernel/qevent.h
index 88a7a8a..997ac0c 100644
--- a/src/gui/kernel/qevent.h
+++ b/src/gui/kernel/qevent.h
@@ -657,7 +657,7 @@ public:
inline QString file() const { return f; }
QUrl url() const;
- void openFile(QFile &file, QIODevice::OpenMode flags) const;
+ bool openFile(QFile &file, QIODevice::OpenMode flags) const;
private:
QString f;
};