From f7de009b176b3134608781ed2380beaf7a2a7476 Mon Sep 17 00:00:00 2001 From: Pavel Sanda Date: Thu, 14 Oct 2021 22:23:14 +0200 Subject: [PATCH] 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 1c1c83eced96), let's be prudent here. If you know that these pointers can't be null from broader context feel free to remove the guards. Introduced by 24926b2e2399, fix 104fdcc9be40df1 not backported but now fixed by 1c1c83eced96 in 2.3. https://www.mail-archive.com/lyx-devel@lists.lyx.org/msg216414.html --- src/frontends/qt/BulletsModule.cpp | 3 ++- src/frontends/qt/GuiPrefs.cpp | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/frontends/qt/BulletsModule.cpp b/src/frontends/qt/BulletsModule.cpp index fcd14e3159..3d6ad9cc41 100644 --- a/src/frontends/qt/BulletsModule.cpp +++ b/src/frontends/qt/BulletsModule.cpp @@ -288,7 +288,8 @@ void BulletsModule::selectItem(int font, int character, bool select) return; QListWidget * lw = static_cast(bulletpaneSW->widget(font)); - lw->item(character)->setSelected(select); + if (lw->item(character)) + lw->item(character)->setSelected(select); } diff --git a/src/frontends/qt/GuiPrefs.cpp b/src/frontends/qt/GuiPrefs.cpp index 7c7a969b17..c1be9b80b2 100644 --- a/src/frontends/qt/GuiPrefs.cpp +++ b/src/frontends/qt/GuiPrefs.cpp @@ -3443,7 +3443,8 @@ void PrefShortcuts::shortcutOkPressed() if (item) { user_bind_.bind(&k, func); shortcutsTW->sortItems(0, Qt::AscendingOrder); - item->parent()->setExpanded(true); + if (item->parent()) + item->parent()->setExpanded(true); shortcutsTW->setCurrentItem(item); shortcutsTW->scrollToItem(item); } else { -- 2.39.2