1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-04-01 12:36:42 +00:00

Fix dangling MWWorld::Ptrs in enchanting dialog after loading save game (Fixes #1722)

This commit is contained in:
scrawl 2014-07-29 15:32:22 +02:00
parent a59620f643
commit 1a6db097ed
2 changed files with 19 additions and 6 deletions

View file

@ -58,9 +58,6 @@ namespace MWGui
void EnchantingDialog::open() void EnchantingDialog::open()
{ {
center(); center();
setSoulGem(MWWorld::Ptr());
setItem(MWWorld::Ptr());
} }
void EnchantingDialog::setSoulGem(const MWWorld::Ptr &gem) void EnchantingDialog::setSoulGem(const MWWorld::Ptr &gem)
@ -78,7 +75,6 @@ namespace MWGui
mSoulBox->setUserData(gem); mSoulBox->setUserData(gem);
mEnchanting.setSoulGem(gem); mEnchanting.setSoulGem(gem);
} }
updateLabels();
} }
void EnchantingDialog::setItem(const MWWorld::Ptr &item) void EnchantingDialog::setItem(const MWWorld::Ptr &item)
@ -96,7 +92,6 @@ namespace MWGui
mItemBox->setUserData(item); mItemBox->setUserData(item);
mEnchanting.setOldItem(item); mEnchanting.setOldItem(item);
} }
updateLabels();
} }
void EnchantingDialog::exit() void EnchantingDialog::exit()
@ -148,6 +143,9 @@ namespace MWGui
mPtr = actor; mPtr = actor;
setSoulGem(MWWorld::Ptr());
setItem(MWWorld::Ptr());
startEditing (); startEditing ();
mPrice->setVisible(true); mPrice->setVisible(true);
mPriceText->setVisible(true); mPriceText->setVisible(true);
@ -167,6 +165,7 @@ namespace MWGui
startEditing(); startEditing();
setSoulGem(soulgem); setSoulGem(soulgem);
setItem(MWWorld::Ptr());
mPrice->setVisible(false); mPrice->setVisible(false);
mPriceText->setVisible(false); mPriceText->setVisible(false);
@ -177,6 +176,16 @@ namespace MWGui
{ {
MWBase::Environment::get().getWindowManager()->removeGuiMode (GM_Dialogue); MWBase::Environment::get().getWindowManager()->removeGuiMode (GM_Dialogue);
MWBase::Environment::get().getWindowManager()->removeGuiMode (GM_Enchanting); MWBase::Environment::get().getWindowManager()->removeGuiMode (GM_Enchanting);
resetReference();
}
void EnchantingDialog::resetReference()
{
ReferenceInterface::resetReference();
setItem(MWWorld::Ptr());
setSoulGem(MWWorld::Ptr());
mPtr = MWWorld::Ptr();
mEnchanting.setEnchanter(MWWorld::Ptr());
} }
void EnchantingDialog::onCancelButtonClicked(MyGUI::Widget* sender) void EnchantingDialog::onCancelButtonClicked(MyGUI::Widget* sender)
@ -219,8 +228,8 @@ namespace MWGui
void EnchantingDialog::onSoulSelected(MWWorld::Ptr item) void EnchantingDialog::onSoulSelected(MWWorld::Ptr item)
{ {
mItemSelectionDialog->setVisible(false); mItemSelectionDialog->setVisible(false);
mEnchanting.setSoulGem(item);
mEnchanting.setSoulGem(item);
if(mEnchanting.getGemCharge()==0) if(mEnchanting.getGemCharge()==0)
{ {
MWBase::Environment::get().getWindowManager()->messageBox ("#{sNotifyMessage32}"); MWBase::Environment::get().getWindowManager()->messageBox ("#{sNotifyMessage32}");
@ -228,6 +237,7 @@ namespace MWGui
} }
setSoulGem(item); setSoulGem(item);
updateLabels();
} }
void EnchantingDialog::onSoulCancel() void EnchantingDialog::onSoulCancel()
@ -252,6 +262,7 @@ namespace MWGui
else else
{ {
setSoulGem(MWWorld::Ptr()); setSoulGem(MWWorld::Ptr());
updateLabels();
} }
} }

View file

@ -29,6 +29,8 @@ namespace MWGui
void startEnchanting(MWWorld::Ptr actor); void startEnchanting(MWWorld::Ptr actor);
void startSelfEnchanting(MWWorld::Ptr soulgem); void startSelfEnchanting(MWWorld::Ptr soulgem);
virtual void resetReference();
protected: protected:
virtual void onReferenceUnavailable(); virtual void onReferenceUnavailable();
virtual void notifyEffectsChanged (); virtual void notifyEffectsChanged ();