Guard against possible referencing null.

Those checks might not be needed, but it's not self obvious from
the surrounding code. Because we already experienced crash from
similar change (cf 1c1c83eced), let's be prudent here.

https://www.mail-archive.com/lyx-devel@lists.lyx.org/msg216414.html
This commit is contained in:
Pavel Sanda 2021-10-14 21:57:57 +02:00
parent 1c1c83eced
commit cad91ec1bc
2 changed files with 4 additions and 2 deletions

View File

@ -159,6 +159,7 @@ void BulletsModule::selectItem(int font, int character, bool select)
return; return;
QListWidget * lw = static_cast<QListWidget *>(bulletpaneSW->widget(font)); QListWidget * lw = static_cast<QListWidget *>(bulletpaneSW->widget(font));
if (lw && lw->item(character))
lw->item(character)->setSelected(select); lw->item(character)->setSelected(select);
} }

View File

@ -3448,6 +3448,7 @@ void PrefShortcuts::shortcutOkPressed()
if (item) { if (item) {
user_bind_.bind(&k, func); user_bind_.bind(&k, func);
shortcutsTW->sortItems(0, Qt::AscendingOrder); shortcutsTW->sortItems(0, Qt::AscendingOrder);
if (item->parent())
item->parent()->setExpanded(true); item->parent()->setExpanded(true);
shortcutsTW->setCurrentItem(item); shortcutsTW->setCurrentItem(item);
shortcutsTW->scrollToItem(item); shortcutsTW->scrollToItem(item);