Qt: The `mutable` keyword exists for a reason
Vicki Pfau vi@endrift.com
Thu, 25 Jun 2020 18:11:16 -0700
2 files changed,
3 insertions(+),
3 deletions(-)
M
src/platform/qt/ShortcutModel.cpp
→
src/platform/qt/ShortcutModel.cpp
@@ -80,7 +80,7 @@ if (parent.isValid()) {
pmenu = static_cast<Item*>(parent.internalPointer())->name; } QString name = m_controller->name(row, pmenu); - Item* item = &(*const_cast<QHash<QString, Item>*>(&m_cache))[name]; + Item* item = &m_cache[name]; item->name = name; item->shortcut = m_controller->shortcut(name); return createIndex(row, column, item);@@ -95,7 +95,7 @@ QString parent = m_controller->parent(item->name);
if (parent.isNull()) { return QModelIndex(); } - Item* pitem = &(*const_cast<QHash<QString, Item>*>(&m_cache))[parent]; + Item* pitem = &m_cache[parent]; pitem->name = parent; pitem->shortcut = m_controller->shortcut(parent); return createIndex(m_controller->indexIn(parent), 0, pitem);
M
src/platform/qt/ShortcutModel.h
→
src/platform/qt/ShortcutModel.h
@@ -44,7 +44,7 @@ QString name;
const Shortcut* shortcut = nullptr; }; - QHash<QString, Item> m_cache; + mutable QHash<QString, Item> m_cache; }; }