From 2722ca50fb2cddb5a8518205ec08ba2126dace57 Mon Sep 17 00:00:00 2001 From: Finbar Crago Date: Fri, 29 Jun 2018 23:32:05 +1000 Subject: [PATCH] fix QuickKeysMenu crash on reopening window after item drop + pickup [see: !11#note_85086570] --- apps/openmw/mwgui/quickkeysmenu.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/apps/openmw/mwgui/quickkeysmenu.cpp b/apps/openmw/mwgui/quickkeysmenu.cpp index 2899dfb77..47bc88c8b 100644 --- a/apps/openmw/mwgui/quickkeysmenu.cpp +++ b/apps/openmw/mwgui/quickkeysmenu.cpp @@ -99,15 +99,16 @@ namespace MWGui { MWWorld::Ptr item = *mKey[i].button->getUserData(); // Make sure the item is available and is not broken - if (item.getRefData().getCount() < 1 || + if (!item || item.getRefData().getCount() < 1 || (item.getClass().hasItemHealth(item) && item.getClass().getItemHealth(item) <= 0)) { // Try searching for a compatible replacement - std::string id = item.getCellRef().getRefId(); + item = store.findReplacement(mKey[i].id); + + if (item) + mKey[i].button->setUserData(MWWorld::Ptr(item)); - item = store.findReplacement(id); - mKey[i].button->setUserData(MWWorld::Ptr(item)); break; } }