[LyX/2.3.x] Guard against possible referencing null.
Pavel Sanda
sanda at lyx.org
Thu Oct 14 19:40:59 UTC 2021
commit cad91ec1bcfb998622710f56ef36fee6635137bf
Author: Pavel Sanda <sanda at lyx.org>
Date: Thu Oct 14 21:57:57 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.
https://www.mail-archive.com/lyx-devel@lists.lyx.org/msg216414.html
---
src/frontends/qt4/BulletsModule.cpp | 3 ++-
src/frontends/qt4/GuiPrefs.cpp | 3 ++-
2 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/src/frontends/qt4/BulletsModule.cpp b/src/frontends/qt4/BulletsModule.cpp
index ef21bd9..a654160 100644
--- a/src/frontends/qt4/BulletsModule.cpp
+++ b/src/frontends/qt4/BulletsModule.cpp
@@ -159,7 +159,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 && lw->item(character))
+ lw->item(character)->setSelected(select);
}
diff --git a/src/frontends/qt4/GuiPrefs.cpp b/src/frontends/qt4/GuiPrefs.cpp
index e9bdbaf..93b7826 100644
--- a/src/frontends/qt4/GuiPrefs.cpp
+++ b/src/frontends/qt4/GuiPrefs.cpp
@@ -3448,7 +3448,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