فهرست منبع

crash fix: dismiss hero when pick artifact

kdmcser 11 ماه پیش
والد
کامیت
993a4dc73d
3فایلهای تغییر یافته به همراه5 افزوده شده و 1 حذف شده
  1. 2 0
      client/widgets/CArtifactsOfHeroBase.cpp
  2. 2 1
      client/widgets/CArtifactsOfHeroMain.cpp
  3. 1 0
      client/windows/CHeroWindow.cpp

+ 2 - 0
client/widgets/CArtifactsOfHeroBase.cpp

@@ -140,6 +140,8 @@ void CArtifactsOfHeroBase::gestureArtPlace(CComponentHolder & artPlace, const Po
 void CArtifactsOfHeroBase::setHero(const CGHeroInstance * hero)
 {
 	curHero = hero;
+	if (!hero)
+		return;
 
 	for(auto slot : artWorn)
 	{

+ 2 - 1
client/widgets/CArtifactsOfHeroMain.cpp

@@ -28,7 +28,8 @@ CArtifactsOfHeroMain::CArtifactsOfHeroMain(const Point & position)
 
 CArtifactsOfHeroMain::~CArtifactsOfHeroMain()
 {
-	CArtifactsOfHeroBase::putBackPickedArtifact();
+	if(curHero)
+		CArtifactsOfHeroBase::putBackPickedArtifact();
 }
 
 void CArtifactsOfHeroMain::keyPressed(EShortcut key)

+ 1 - 0
client/windows/CHeroWindow.cpp

@@ -312,6 +312,7 @@ void CHeroWindow::dismissCurrent()
 			arts->putBackPickedArtifact();
 			close();
 			LOCPLINT->cb->dismissHero(curHero);
+			arts->setHero(nullptr);
 		}, nullptr);
 }