Przeglądaj źródła

Fixed two memory leaks

AlexVinS 7 lat temu
rodzic
commit
614cde4a55

+ 5 - 2
client/windows/CCastleInterface.cpp

@@ -1124,8 +1124,11 @@ CCastleInterface::CCastleInterface(const CGTownInstance * Town, const CGTownInst
 	exit->assignedKeys.insert(SDLK_ESCAPE);
 	exit->setImageOrder(4, 5, 6, 7);
 
-	auto split = std::make_shared<CButton>(Point(744, 382), "TSBTNS", CButton::tooltip(CGI->generaltexth->tcommands[3]), [&](){garr->splitClick();});
-	split->addCallback(std::bind(&HeroSlots::splitClicked, heroes));
+	auto split = std::make_shared<CButton>(Point(744, 382), "TSBTNS", CButton::tooltip(CGI->generaltexth->tcommands[3]), [&]()
+	{
+		garr->splitClick();
+		heroes->splitClicked();
+	});
 	garr->addSplitBtn(split);
 
 	Rect barRect(9, 182, 732, 18);

+ 4 - 2
client/windows/GUIClasses.cpp

@@ -923,9 +923,11 @@ CExchangeWindow::CExchangeWindow(ObjectInstanceID hero1, ObjectInstanceID hero2,
 	statusbar = CGStatusBar::create(std::make_shared<CPicture>(*background, barRect, 5, 578, false));
 
 	//garrison interface
+
 	garr = std::make_shared<CGarrisonInt>(69, 131, 4, Point(418,0), heroInst[0], heroInst[1], true, true);
-	garr->addSplitBtn(std::make_shared<CButton>( Point( 10, 132), "TSBTNS.DEF", CButton::tooltip(CGI->generaltexth->tcommands[3]), std::bind(&CGarrisonInt::splitClick, garr)));
-	garr->addSplitBtn(std::make_shared<CButton>( Point(740, 132), "TSBTNS.DEF", CButton::tooltip(CGI->generaltexth->tcommands[3]), std::bind(&CGarrisonInt::splitClick, garr)));
+	auto splitButtonCallback = [&](){ garr->splitClick(); };
+	garr->addSplitBtn(std::make_shared<CButton>( Point( 10, 132), "TSBTNS.DEF", CButton::tooltip(CGI->generaltexth->tcommands[3]), splitButtonCallback));
+	garr->addSplitBtn(std::make_shared<CButton>( Point(740, 132), "TSBTNS.DEF", CButton::tooltip(CGI->generaltexth->tcommands[3]), splitButtonCallback));
 
 	updateWidgets();
 }