From 30081393a6fd2e40825b9836e2d086fbeb1ab91d Mon Sep 17 00:00:00 2001 From: scrawl Date: Wed, 19 Apr 2017 18:28:49 +0200 Subject: [PATCH] Add InventoryWindow::clear() as part of world cleanup --- apps/openmw/mwgui/inventorywindow.cpp | 25 ++++++++++++++++++------- apps/openmw/mwgui/inventorywindow.hpp | 2 ++ apps/openmw/mwgui/windowmanagerimp.cpp | 2 ++ 3 files changed, 22 insertions(+), 7 deletions(-) diff --git a/apps/openmw/mwgui/inventorywindow.cpp b/apps/openmw/mwgui/inventorywindow.cpp index 21b90991c..b5a1b50d0 100644 --- a/apps/openmw/mwgui/inventorywindow.cpp +++ b/apps/openmw/mwgui/inventorywindow.cpp @@ -136,6 +136,18 @@ namespace MWGui dirtyPreview(); updatePreviewSize(); + + updateEncumbranceBar(); + mItemView->update(); + notifyContentChanged(); + } + + void InventoryWindow::clear() + { + mPtr = MWWorld::Ptr(); + mTradeModel = NULL; + mSortModel = NULL; + mItemView->setModel(NULL); } void InventoryWindow::setGuiMode(GuiMode mode) @@ -340,13 +352,12 @@ namespace MWGui void InventoryWindow::open() { - mPtr = MWMechanics::getPlayer(); - - updateEncumbranceBar(); - - mItemView->update(); - - notifyContentChanged(); + if (!mPtr.isEmpty()) + { + updateEncumbranceBar(); + mItemView->update(); + notifyContentChanged(); + } adjustPanes(); } diff --git a/apps/openmw/mwgui/inventorywindow.hpp b/apps/openmw/mwgui/inventorywindow.hpp index 651bda590..11091c428 100644 --- a/apps/openmw/mwgui/inventorywindow.hpp +++ b/apps/openmw/mwgui/inventorywindow.hpp @@ -60,6 +60,8 @@ namespace MWGui void updatePlayer(); + void clear(); + void useItem(const MWWorld::Ptr& ptr); void setGuiMode(GuiMode mode); diff --git a/apps/openmw/mwgui/windowmanagerimp.cpp b/apps/openmw/mwgui/windowmanagerimp.cpp index 16d1a9c6d..9238e5cfd 100644 --- a/apps/openmw/mwgui/windowmanagerimp.cpp +++ b/apps/openmw/mwgui/windowmanagerimp.cpp @@ -1696,6 +1696,8 @@ namespace MWGui mCompanionWindow->resetReference(); mConsole->resetReference(); + mInventoryWindow->clear(); + mSelectedSpell.clear(); mCustomMarkers.clear();