From 7eb1dcb682ab5aaf96542f5c81e29e0c8f99a955 Mon Sep 17 00:00:00 2001 From: scrawl Date: Sat, 16 Nov 2013 22:29:40 +0100 Subject: [PATCH] Fix trade windows crashing after a new game --- apps/openmw/mwgui/container.cpp | 6 ++++-- apps/openmw/mwgui/tradewindow.cpp | 5 ++++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/apps/openmw/mwgui/container.cpp b/apps/openmw/mwgui/container.cpp index 5d864752fc..19ed4dbc00 100644 --- a/apps/openmw/mwgui/container.cpp +++ b/apps/openmw/mwgui/container.cpp @@ -220,11 +220,13 @@ namespace MWGui mDisposeCorpseButton->setVisible(loot); - setTitle(MWWorld::Class::get(container).getName(container)); - mSortModel = new SortFilterItemModel(mModel); mItemView->setModel (mSortModel); + + // Careful here. setTitle may cause size updates, causing itemview redraw, so make sure to do it last + // or we end up using a possibly invalid model. + setTitle(MWWorld::Class::get(container).getName(container)); } void ContainerWindow::onCloseButtonClicked(MyGUI::Widget* _sender) diff --git a/apps/openmw/mwgui/tradewindow.cpp b/apps/openmw/mwgui/tradewindow.cpp index c179236087..65e3917ed5 100644 --- a/apps/openmw/mwgui/tradewindow.cpp +++ b/apps/openmw/mwgui/tradewindow.cpp @@ -82,7 +82,6 @@ namespace MWGui void TradeWindow::startTrade(const MWWorld::Ptr& actor) { mPtr = actor; - setTitle(MWWorld::Class::get(actor).getName(actor)); mCurrentBalance = 0; mCurrentMerchantOffer = 0; @@ -99,6 +98,10 @@ namespace MWGui mItemView->setModel (mSortModel); updateLabels(); + + // Careful here. setTitle may cause size updates, causing itemview redraw, so make sure to do it last + // or we end up using a possibly invalid model. + setTitle(MWWorld::Class::get(actor).getName(actor)); } void TradeWindow::onFilterChanged(MyGUI::Widget* _sender)