summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@kdab.com>2012-03-05 18:27:10 +0100
committerQt by Nokia <qt-info@nokia.com>2012-03-23 11:22:40 +0100
commit9848c8b92c70006e55a7fa569d06d62efaf5ccc1 (patch)
tree53201bd7e3a7a2a596b6510f3a1bd8cdaf278700
parent3986b5127419dfd6db6ce667b2976d188e25d9be (diff)
QDirIterator: don't inherit from QDir
Remove the inheritance hack used in QDirIterator to gain access to QDir's d-pointer by simply making QDirIterator a friend of QDir. This allows to turn QDir into a final class. Change-Id: I97efef8714bb194d62b9fe5192ce240a90f2bf97 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
-rw-r--r--src/corelib/io/qdir.h2
-rw-r--r--src/corelib/io/qdiriterator.cpp4
2 files changed, 3 insertions, 3 deletions
diff --git a/src/corelib/io/qdir.h b/src/corelib/io/qdir.h
index 5551ecd2fb..a5105fe2fb 100644
--- a/src/corelib/io/qdir.h
+++ b/src/corelib/io/qdir.h
@@ -52,6 +52,7 @@ QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
+class QDirIterator;
class QDirPrivate;
class Q_CORE_EXPORT QDir
@@ -210,6 +211,7 @@ protected:
QSharedDataPointer<QDirPrivate> d_ptr;
private:
+ friend class QDirIterator;
// Q_DECLARE_PRIVATE equivalent for shared data pointers
QDirPrivate* d_func();
inline const QDirPrivate* d_func() const
diff --git a/src/corelib/io/qdiriterator.cpp b/src/corelib/io/qdiriterator.cpp
index b8536a8dce..56912e8706 100644
--- a/src/corelib/io/qdiriterator.cpp
+++ b/src/corelib/io/qdiriterator.cpp
@@ -410,9 +410,7 @@ bool QDirIteratorPrivate::matchesFilters(const QString &fileName, const QFileInf
*/
QDirIterator::QDirIterator(const QDir &dir, IteratorFlags flags)
{
- // little trick to get hold of the QDirPrivate while there is no API on QDir to give it to us
- class MyQDir : public QDir { public: const QDirPrivate *priv() const { return d_ptr.constData(); } };
- const QDirPrivate *other = static_cast<const MyQDir*>(&dir)->priv();
+ const QDirPrivate *other = dir.d_ptr.constData();
d.reset(new QDirIteratorPrivate(other->dirEntry, other->nameFilters, other->filters, flags, !other->fileEngine.isNull()));
}