summaryrefslogtreecommitdiffstats
path: root/src/corelib/kernel
diff options
context:
space:
mode:
authorAaron Kennedy <aaron.kennedy@nokia.com>2009-07-30 05:52:29 (GMT)
committerAaron Kennedy <aaron.kennedy@nokia.com>2009-07-31 02:00:23 (GMT)
commitb859422e23a31af1cda5011883d8a25c934cea65 (patch)
treefd82502455465edb9eb8cfe12afac182d58b83af /src/corelib/kernel
parentc257996dfdc87b9a9682d35419792730e477d3ac (diff)
downloadQt-b859422e23a31af1cda5011883d8a25c934cea65.zip
Qt-b859422e23a31af1cda5011883d8a25c934cea65.tar.gz
Qt-b859422e23a31af1cda5011883d8a25c934cea65.tar.bz2
Make QAbstractItemModel default rolenames reentrant
Reviewed-by: Martin Jones Reviewed-by: mbm
Diffstat (limited to 'src/corelib/kernel')
-rw-r--r--src/corelib/kernel/qabstractitemmodel.cpp28
1 files changed, 17 insertions, 11 deletions
diff --git a/src/corelib/kernel/qabstractitemmodel.cpp b/src/corelib/kernel/qabstractitemmodel.cpp
index cd17076..01440e4 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();
}
/*!