From 2fab59c0d50c42d9e1875201d7296df57bb1b919 Mon Sep 17 00:00:00 2001 From: Méven Car Date: Mon, 20 Oct 2025 14:15:13 +0200 Subject: kstandarditemlistwidget: guard against textOption not existing In editedRoleChanged. This can happen if updateTextsCache has not yet be called before editedRoleChanged in tests notably. --- src/kitemviews/kstandarditemlistwidget.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'src') 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); -- cgit v1.3