OSDN Git Service

plug QAbstractItemModelPrivate::defaultRoleNames() memory
authorIvailo Monev <xakepa10@laimg.moc>
Tue, 21 Jan 2020 10:15:24 +0000 (10:15 +0000)
committerIvailo Monev <xakepa10@laimg.moc>
Tue, 21 Jan 2020 10:15:24 +0000 (10:15 +0000)
Signed-off-by: Ivailo Monev <xakepa10@laimg.moc>
src/core/kernel/qabstractitemmodel.cpp

index 193dc5d..c7c6ff1 100644 (file)
@@ -466,20 +466,19 @@ QAbstractItemModel *QAbstractItemModelPrivate::staticEmptyModel()
 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";
+        insert(Qt::DisplayRole, "display");
+        insert(Qt::DecorationRole, "decoration");
+        insert(Qt::EditRole, "edit");
+        insert(Qt::ToolTipRole, "toolTip");
+        insert(Qt::StatusTipRole, "statusTip");
+        insert(Qt::WhatsThisRole, "whatsThis");
     }
 };
 
-Q_GLOBAL_STATIC(DefaultRoleNames, qDefaultRoleNames)
-
 const QHash<int,QByteArray> &QAbstractItemModelPrivate::defaultRoleNames()
 {
-    return *qDefaultRoleNames();
+    static const DefaultRoleNames qDefaultRoleNames;
+    return qDefaultRoleNames;
 }