summaryrefslogtreecommitdiffstats
path: root/src/gui/kernel/qevent.cpp
diff options
context:
space:
mode:
authormread <qt-info@nokia.com>2011-01-18 16:50:09 (GMT)
committerJoão Abecasis <joao.abecasis@nokia.com>2011-02-10 12:26:44 (GMT)
commitd35e6856c4fb7e98dac5db3aaa94ac271375405e (patch)
tree1a0bcf64d0093562f030f4d6e91122cbe2495bd9 /src/gui/kernel/qevent.cpp
parent30f845abdad6dcff620f93122495aee8aac7452f (diff)
downloadQt-d35e6856c4fb7e98dac5db3aaa94ac271375405e.zip
Qt-d35e6856c4fb7e98dac5db3aaa94ac271375405e.tar.gz
Qt-d35e6856c4fb7e98dac5db3aaa94ac271375405e.tar.bz2
Updates after review comments
Tidied up QFileOpenEventPrivate destruction. Commented the Duplicates to explain their benefit. Remove the file exists check from ProcessCommandParametersL Task-number: QTBUG-15015 Reviewed-by: Shane Kearns
Diffstat (limited to 'src/gui/kernel/qevent.cpp')
-rw-r--r--src/gui/kernel/qevent.cpp16
1 files changed, 11 insertions, 5 deletions
diff --git a/src/gui/kernel/qevent.cpp b/src/gui/kernel/qevent.cpp
index 5027aa2..698c94b 100644
--- a/src/gui/kernel/qevent.cpp
+++ b/src/gui/kernel/qevent.cpp
@@ -3030,6 +3030,13 @@ QShowEvent::~QShowEvent()
\note This class is currently supported for Mac OS X and Symbian only.
*/
+QFileOpenEventPrivate::~QFileOpenEventPrivate()
+{
+#ifdef Q_OS_SYMBIAN
+ file.Close();
+#endif
+}
+
/*!
\internal
@@ -3063,6 +3070,7 @@ QFileOpenEvent::QFileOpenEvent(const RFile &fileHandle)
fileHandle.FullName(fullName);
f = qt_TDesC2QString(fullName);
QScopedPointer<QFileOpenEventPrivate> priv(new QFileOpenEventPrivate(QUrl::fromLocalFile(f)));
+ // Duplicate here allows the file handle to be valid after S60 app construction is complete.
qt_symbian_throwIfError(priv->file.Duplicate(fileHandle));
d = reinterpret_cast<QEventPrivate *>(priv.take());
}
@@ -3072,11 +3080,7 @@ QFileOpenEvent::QFileOpenEvent(const RFile &fileHandle)
*/
QFileOpenEvent::~QFileOpenEvent()
{
- QFileOpenEventPrivate *priv = reinterpret_cast<QFileOpenEventPrivate *>(d);
-#ifdef Q_OS_SYMBIAN
- priv->file.Close();
-#endif
- delete priv;
+ delete reinterpret_cast<QFileOpenEventPrivate *>(d);
}
/*!
@@ -3117,6 +3121,8 @@ bool QFileOpenEvent::openFile(QFile &file, QIODevice::OpenMode flags) const
const QFileOpenEventPrivate *priv = reinterpret_cast<const QFileOpenEventPrivate *>(d);
if (priv->file.SubSessionHandle()) {
RFile dup;
+ // Duplicate here means that the opened QFile will continue to be valid beyond the lifetime of this QFileOpenEvent.
+ // It also allows openFile to be used in threads other than the thread in which the QFileOpenEvent was created.
if (dup.Duplicate(priv->file) == KErrNone) {
QScopedPointer<RFile, QScopedPointerRCloser<RFile> > dupCloser(&dup);
bool open = file.open(dup, flags, QFile::AutoCloseHandle);