shortcuteditor example: Don't reference null-action

The parent nodes of the leaf ShortcutEditorModelItem nodes
do not have an action item.

Pick-to: 6.5
Change-Id: If9f8554101974a96f95db048b1bd691f3e89a23a
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
This commit is contained in:
Tor Arne Vestbø 2023-05-16 12:59:43 +02:00
parent bc4e9e432a
commit fda4da6df9

View File

@ -257,11 +257,11 @@ bool ShortcutEditorModel::setData(const QModelIndex &index, const QVariant &valu
QString keySequenceString = value.toString();
ShortcutEditorModelItem *item = static_cast<ShortcutEditorModelItem *>(index.internalPointer());
QAction *itemAction = item->action();
if (itemAction
&& keySequenceString == itemAction->shortcut().toString(QKeySequence::NativeText))
return true;
itemAction->setShortcut(keySequenceString);
if (itemAction) {
if (keySequenceString == itemAction->shortcut().toString(QKeySequence::NativeText))
return true;
itemAction->setShortcut(keySequenceString);
}
Q_EMIT dataChanged(index, index);
if (keySequenceString.isEmpty())