diff options
Diffstat (limited to 'src/widgets/itemviews/qdirmodel.cpp')
-rw-r--r-- | src/widgets/itemviews/qdirmodel.cpp | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/src/widgets/itemviews/qdirmodel.cpp b/src/widgets/itemviews/qdirmodel.cpp index 0c157c940f..8a7ab3c63c 100644 --- a/src/widgets/itemviews/qdirmodel.cpp +++ b/src/widgets/itemviews/qdirmodel.cpp @@ -34,7 +34,6 @@ #include "qdirmodel.h" #ifndef QT_NO_DIRMODEL -#include <qstack.h> #include <qfile.h> #include <qfilesystemmodel.h> #include <qurl.h> @@ -49,6 +48,9 @@ #include <private/qabstractitemmodel_p.h> #include <qdebug.h> +#include <stack> +#include <vector> + /*! \enum QDirModel::Roles \value FileIconRole @@ -163,14 +165,15 @@ void QDirModelPrivate::clear(QDirNode *parent) const void QDirModelPrivate::invalidate() { - QStack<const QDirNode*> nodes; + std::stack<const QDirNode*, std::vector<const QDirNode*> > nodes; nodes.push(&root); while (!nodes.empty()) { - const QDirNode *current = nodes.pop(); + const QDirNode *current = nodes.top(); + nodes.pop(); current->stat = false; - const QVector<QDirNode> children = current->children; - for (int i = 0; i < children.count(); ++i) - nodes.push(&children.at(i)); + const QVector<QDirNode> &children = current->children; + for (const auto &child : children) + nodes.push(&child); } } @@ -1022,7 +1025,7 @@ bool QDirModel::rmdir(const QModelIndex &index) return false; QDirModelPrivate::QDirNode *n = d_func()->node(index); - if (!n->info.isDir()) { + if (Q_UNLIKELY(!n->info.isDir())) { qWarning("rmdir: the node is not a directory"); return false; } @@ -1172,7 +1175,7 @@ QDirModelPrivate::QDirNode *QDirModelPrivate::node(int row, QDirNode *parent) co if (isDir && !p->populated) populate(p); // will also resolve symlinks - if (row >= p->children.count()) { + if (Q_UNLIKELY(row >= p->children.count())) { qWarning("node: the row does not exist"); return 0; } |