]> git.lyx.org Git - features.git/commitdiff
Guard against possible referencing null.
authorPavel Sanda <sanda@lyx.org>
Thu, 14 Oct 2021 20:23:14 +0000 (22:23 +0200)
committerPavel Sanda <sanda@lyx.org>
Thu, 14 Oct 2021 20:28:43 +0000 (22:28 +0200)
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
src/frontends/qt/GuiPrefs.cpp

index fcd14e3159656b43b798ee034c65b04c875d65d2..3d6ad9cc41a80771f5aad91bd22baf023f033e4a 100644 (file)
@@ -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);
 }
 
 
index 7c7a969b17c52742953c713684392cc6619fdc77..c1be9b80b2cdba7bf3458ce61073e72d1cf3fd49 100644 (file)
@@ -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 {