From cf772ab6f9fdfe1647b9b7b79aab685ebc831f31 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Mon, 20 Feb 2017 15:51:27 +0300 Subject: Fix some leaks in unit tests. Add support for suppression some leaks in asan. --- src/gui/widgets/browserbox_unittest.cc | 7 +++++-- src/gui/widgets/widget.h | 3 +++ src/gui/windowmanager_unittest.cc | 12 +++++++++++- 3 files changed, 19 insertions(+), 3 deletions(-) (limited to 'src/gui') diff --git a/src/gui/widgets/browserbox_unittest.cc b/src/gui/widgets/browserbox_unittest.cc index 3978c309d..a3434427f 100644 --- a/src/gui/widgets/browserbox_unittest.cc +++ b/src/gui/widgets/browserbox_unittest.cc @@ -30,6 +30,7 @@ #include "gui/widgets/browserbox.h" +#include "utils/delete2.h" #include "utils/virtfs.h" #include "render/sdlgraphics.h" @@ -170,8 +171,10 @@ TEST_CASE("BrowserBox tests", "browserbox") row = "##1%%2"; box->addRow(row); + delete Widget::getGloablFont(); + Widget::setGlobalFont(nullptr); delete box; - delete client; - client = nullptr; + delete2(client); + delete2(logger); // VirtFs::deinit(); } diff --git a/src/gui/widgets/widget.h b/src/gui/widgets/widget.h index 4a9957738..92b345cea 100644 --- a/src/gui/widgets/widget.h +++ b/src/gui/widgets/widget.h @@ -641,6 +641,9 @@ class Widget notfinal : public Widget2 */ static void setGlobalFont(Font *const font); + static Font *getGloablFont() + { return mGlobalFont; } + /** * Sets the font for the widget. If NULL is passed, the global font * will be used. diff --git a/src/gui/windowmanager_unittest.cc b/src/gui/windowmanager_unittest.cc index 392e6e872..68fc3852b 100644 --- a/src/gui/windowmanager_unittest.cc +++ b/src/gui/windowmanager_unittest.cc @@ -25,7 +25,7 @@ #include "settings.h" #include "textcommand.h" -#include "being/being.h" +#include "being/localplayer.h" #include "const/resources/currency.h" @@ -159,6 +159,10 @@ TEST_CASE("Windows tests", "windowmanager") config.setValue("fontSize", 16); theme = new Theme; Theme::selectSkin(); + + localPlayer = new LocalPlayer(static_cast(1), + BeingTypeId_zero); + ActorSprite::load(); gui = new Gui(); gui->postInit(mainGraphics); @@ -568,6 +572,7 @@ TEST_CASE("Windows tests", "windowmanager") gui->draw(); mainGraphics->updateScreen(); delete2(dialog); + delete2(textCommand); } SECTION("TextDialog") @@ -677,9 +682,14 @@ TEST_CASE("Windows tests", "windowmanager") delete2(connectionDialog); } + delete2(localPlayer); delete2(userPalette); delete2(client); delete2(serverFeatures); delete2(inventoryHandler); + delete2(charServerHandler); + delete2(playerHandler); + delete2(logger); + // VirtFs::deinit(); } -- cgit v1.2.3-70-g09d2