diff options
author | Aaron Kennedy <aaron.kennedy@nokia.com> | 2009-07-30 15:52:29 +1000 |
---|---|---|
committer | Aaron Kennedy <aaron.kennedy@nokia.com> | 2009-07-31 12:00:23 +1000 |
commit | b859422e23a31af1cda5011883d8a25c934cea65 (patch) | |
tree | fd82502455465edb9eb8cfe12afac182d58b83af /src/corelib | |
parent | c257996dfdc87b9a9682d35419792730e477d3ac (diff) | |
download | qt4-tools-b859422e23a31af1cda5011883d8a25c934cea65.tar.gz |
Make QAbstractItemModel default rolenames reentrant
Reviewed-by: Martin Jones
Reviewed-by: mbm
Diffstat (limited to 'src/corelib')
-rw-r--r-- | src/corelib/kernel/qabstractitemmodel.cpp | 28 |
1 files changed, 17 insertions, 11 deletions
diff --git a/src/corelib/kernel/qabstractitemmodel.cpp b/src/corelib/kernel/qabstractitemmodel.cpp index cd17076ef7..01440e4b84 100644 --- a/src/corelib/kernel/qabstractitemmodel.cpp +++ b/src/corelib/kernel/qabstractitemmodel.cpp @@ -467,19 +467,25 @@ QAbstractItemModel *QAbstractItemModelPrivate::staticEmptyModel() return qEmptyModel(); } +namespace { + struct DefaultRoleNames : public QHash<int, QByteArray> + { + DefaultRoleNames() { + (*this)[Qt::DisplayRole] = "display"; + (*this)[Qt::DecorationRole] = "decoration"; + (*this)[Qt::EditRole] = "edit"; + (*this)[Qt::ToolTipRole] = "toolTip"; + (*this)[Qt::StatusTipRole] = "statusTip"; + (*this)[Qt::WhatsThisRole] = "whatsThis"; + } + }; +} + +Q_GLOBAL_STATIC(DefaultRoleNames, q_defaultRoleNames); + const QHash<int,QByteArray> &QAbstractItemModelPrivate::defaultRoleNames() { - static QHash<int,QByteArray> roleNames; - if (roleNames.isEmpty()) { - roleNames[Qt::DisplayRole] = "display"; - roleNames[Qt::DecorationRole] = "decoration"; - roleNames[Qt::EditRole] = "edit"; - roleNames[Qt::ToolTipRole] = "toolTip"; - roleNames[Qt::StatusTipRole] = "statusTip"; - roleNames[Qt::WhatsThisRole] = "whatsThis"; - } - - return roleNames; + return *q_defaultRoleNames(); } /*! |