[LyX/master] Guard against possible referencing null.
Pavel Sanda
sanda at lyx.org
Thu Oct 14 20:06:36 UTC 2021
commit f7de009b176b3134608781ed2380beaf7a2a7476
Author: Pavel Sanda <sanda at lyx.org>
Date: Thu Oct 14 22:23:14 2021 +0200
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 fcd14e3..3d6ad9c 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<QListWidget *>(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 7c7a969..c1be9b8 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 {
More information about the lyx-cvs
mailing list