From d35e6856c4fb7e98dac5db3aaa94ac271375405e Mon Sep 17 00:00:00 2001 From: mread Date: Tue, 18 Jan 2011 16:50:09 +0000 Subject: 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 --- src/gui/kernel/qevent.cpp | 16 +++++++++++----- src/gui/kernel/qevent_p.h | 1 + src/gui/s60framework/qs60mainappui.cpp | 3 ++- 3 files changed, 14 insertions(+), 6 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 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(priv.take()); } @@ -3072,11 +3080,7 @@ QFileOpenEvent::QFileOpenEvent(const RFile &fileHandle) */ QFileOpenEvent::~QFileOpenEvent() { - QFileOpenEventPrivate *priv = reinterpret_cast(d); -#ifdef Q_OS_SYMBIAN - priv->file.Close(); -#endif - delete priv; + delete reinterpret_cast(d); } /*! @@ -3117,6 +3121,8 @@ bool QFileOpenEvent::openFile(QFile &file, QIODevice::OpenMode flags) const const QFileOpenEventPrivate *priv = reinterpret_cast(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 > dupCloser(&dup); bool open = file.open(dup, flags, QFile::AutoCloseHandle); diff --git a/src/gui/kernel/qevent_p.h b/src/gui/kernel/qevent_p.h index 01af384..b79f372 100644 --- a/src/gui/kernel/qevent_p.h +++ b/src/gui/kernel/qevent_p.h @@ -178,6 +178,7 @@ public: : url(url) { } + ~QFileOpenEventPrivate(); QUrl url; #ifdef Q_OS_SYMBIAN diff --git a/src/gui/s60framework/qs60mainappui.cpp b/src/gui/s60framework/qs60mainappui.cpp index 454f90d..8ae43a5 100644 --- a/src/gui/s60framework/qs60mainappui.cpp +++ b/src/gui/s60framework/qs60mainappui.cpp @@ -408,7 +408,8 @@ void QS60MainAppUi::HandleForegroundEventL(TBool aForeground) TBool QS60MainAppUi::ProcessCommandParametersL(TApaCommand /*aCommand*/, TFileName &aDocumentName, const TDesC8 &/*aTail*/) { // bypass CEikAppUi::ProcessCommandParametersL(..) which modifies aDocumentName, preventing apparc document opening from working. - return ConeUtils::FileExists(aDocumentName); + // The return value is effectively unused in Qt apps (see QS60MainDocument::OpenFileL) + return EFalse; } #ifndef Q_WS_S60 -- cgit v0.12