diff options
| author | Méven Car <[email protected]> | 2025-10-20 14:15:13 +0200 |
|---|---|---|
| committer | Méven Car <[email protected]> | 2025-10-23 08:10:58 +0000 |
| commit | 2fab59c0d50c42d9e1875201d7296df57bb1b919 (patch) | |
| tree | 135a62f4b282db70c41f600ba4e361bc206e2b98 | |
| parent | bc5627eec73e5df94f27ed4176ef543a3cc75d58 (diff) | |
kstandarditemlistwidget: guard against textOption not existing
In editedRoleChanged.
This can happen if updateTextsCache has not yet be called before
editedRoleChanged in tests notably.
| -rw-r--r-- | src/kitemviews/kstandarditemlistwidget.cpp | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/src/kitemviews/kstandarditemlistwidget.cpp b/src/kitemviews/kstandarditemlistwidget.cpp index d98aed94c..5a81ad5a5 100644 --- a/src/kitemviews/kstandarditemlistwidget.cpp +++ b/src/kitemviews/kstandarditemlistwidget.cpp @@ -867,8 +867,6 @@ void KStandardItemListWidget::editedRoleChanged(const QByteArray ¤t, const Q_ASSERT(!m_roleEditor); - const TextInfo *textInfo = m_textInfo.value("text"); - m_roleEditor = new KItemListRoleEditor(parent); m_roleEditor->setRole(current); m_roleEditor->setAllowUpDownKeyChainEdit(m_layout != IconsLayout); @@ -877,8 +875,11 @@ void KStandardItemListWidget::editedRoleChanged(const QByteArray ¤t, const const QString text = data().value(current).toString(); m_roleEditor->setPlainText(text); - QTextOption textOption = textInfo->staticText.textOption(); - m_roleEditor->document()->setDefaultTextOption(textOption); + const TextInfo *textInfo = m_textInfo.value("text"); + if (textInfo) { + QTextOption textOption = textInfo->staticText.textOption(); + m_roleEditor->document()->setDefaultTextOption(textOption); + } const int textSelectionLength = selectionLength(text); |
