diff options
author | mread <qt-info@nokia.com> | 2011-01-18 16:50:09 (GMT) |
---|---|---|
committer | João Abecasis <joao.abecasis@nokia.com> | 2011-02-10 12:26:44 (GMT) |
commit | d35e6856c4fb7e98dac5db3aaa94ac271375405e (patch) | |
tree | 1a0bcf64d0093562f030f4d6e91122cbe2495bd9 | |
parent | 30f845abdad6dcff620f93122495aee8aac7452f (diff) | |
download | Qt-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
-rw-r--r-- | src/gui/kernel/qevent.cpp | 16 | ||||
-rw-r--r-- | src/gui/kernel/qevent_p.h | 1 | ||||
-rw-r--r-- | 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<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); 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 |