summaryrefslogtreecommitdiff
path: root/src/gui
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2014-03-28 00:39:12 +0300
committerAndrei Karas <akaras@inbox.ru>2014-03-28 11:04:23 +0300
commit0c35dab0ba366f85b40ef1795125521f1df8c264 (patch)
treedde6abde3288f543ae96a2468b2275af8a03e704 /src/gui
parent47cc515695fcd0b16467506e4984d2ec38fad4e4 (diff)
downloadmv-0c35dab0ba366f85b40ef1795125521f1df8c264.tar.gz
mv-0c35dab0ba366f85b40ef1795125521f1df8c264.tar.bz2
mv-0c35dab0ba366f85b40ef1795125521f1df8c264.tar.xz
mv-0c35dab0ba366f85b40ef1795125521f1df8c264.zip
simplify variables cleanup.
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/font.cpp4
-rw-r--r--src/gui/gui.cpp31
-rw-r--r--src/gui/theme.cpp7
-rw-r--r--src/gui/viewport.cpp12
-rw-r--r--src/gui/widgets/button.cpp6
-rw-r--r--src/gui/widgets/characterdisplay.cpp4
-rw-r--r--src/gui/widgets/dropshortcutcontainer.cpp6
-rw-r--r--src/gui/widgets/emotepage.cpp5
-rw-r--r--src/gui/widgets/guitable.cpp8
-rw-r--r--src/gui/widgets/itemcontainer.cpp7
-rw-r--r--src/gui/widgets/itemlinkhandler.cpp5
-rw-r--r--src/gui/widgets/itemshortcutcontainer.cpp8
-rw-r--r--src/gui/widgets/layout.cpp7
-rw-r--r--src/gui/widgets/popup.cpp5
-rw-r--r--src/gui/widgets/progressbar.cpp5
-rw-r--r--src/gui/widgets/progressindicator.cpp5
-rw-r--r--src/gui/widgets/scrollarea.cpp8
-rw-r--r--src/gui/widgets/shortcutcontainer.cpp5
-rw-r--r--src/gui/widgets/slider.cpp5
-rw-r--r--src/gui/widgets/spellshortcutcontainer.cpp5
-rw-r--r--src/gui/widgets/tabbedarea.cpp19
-rw-r--r--src/gui/widgets/tabs/chattab.cpp7
-rw-r--r--src/gui/widgets/tabs/setup_audio.cpp8
-rw-r--r--src/gui/widgets/tabs/setup_colors.cpp11
-rw-r--r--src/gui/widgets/tabs/setup_input.cpp21
-rw-r--r--src/gui/widgets/tabs/setup_joystick.cpp4
-rw-r--r--src/gui/widgets/tabs/setup_other.cpp10
-rw-r--r--src/gui/widgets/tabs/setup_perfomance.cpp4
-rw-r--r--src/gui/widgets/tabs/setup_relations.cpp14
-rw-r--r--src/gui/widgets/tabs/setup_theme.cpp28
-rw-r--r--src/gui/widgets/tabs/setup_touch.cpp10
-rw-r--r--src/gui/widgets/tabs/setup_video.cpp13
-rw-r--r--src/gui/widgets/tabs/setup_visual.cpp19
-rw-r--r--src/gui/widgets/tabs/setuptabscroll.cpp7
-rw-r--r--src/gui/widgets/tabs/tab.cpp8
-rw-r--r--src/gui/widgets/textfield.cpp4
-rw-r--r--src/gui/widgets/window.cpp11
-rw-r--r--src/gui/windowmenu.cpp4
-rw-r--r--src/gui/windows/buydialog.cpp5
-rw-r--r--src/gui/windows/changeemaildialog.cpp4
-rw-r--r--src/gui/windows/changepassworddialog.cpp4
-rw-r--r--src/gui/windows/charcreatedialog.cpp13
-rw-r--r--src/gui/windows/chatwindow.cpp13
-rw-r--r--src/gui/windows/debugwindow.cpp10
-rw-r--r--src/gui/windows/emotewindow.cpp22
-rw-r--r--src/gui/windows/equipmentwindow.cpp10
-rw-r--r--src/gui/windows/inventorywindow.cpp5
-rw-r--r--src/gui/windows/itemamountwindow.cpp4
-rw-r--r--src/gui/windows/logindialog.cpp7
-rw-r--r--src/gui/windows/minimap.cpp4
-rw-r--r--src/gui/windows/ministatuswindow.cpp7
-rw-r--r--src/gui/windows/npcdialog.cpp59
-rw-r--r--src/gui/windows/questswindow.cpp7
-rw-r--r--src/gui/windows/quitdialog.cpp13
-rw-r--r--src/gui/windows/registerdialog.cpp4
-rw-r--r--src/gui/windows/selldialog.cpp4
-rw-r--r--src/gui/windows/serverdialog.cpp10
-rw-r--r--src/gui/windows/setupwindow.cpp4
-rw-r--r--src/gui/windows/shopwindow.cpp8
-rw-r--r--src/gui/windows/shortcutwindow.cpp8
-rw-r--r--src/gui/windows/skilldialog.cpp10
-rw-r--r--src/gui/windows/socialwindow.cpp82
-rw-r--r--src/gui/windows/statuswindow.cpp4
-rw-r--r--src/gui/windows/textcommandeditor.cpp10
-rw-r--r--src/gui/windows/unregisterdialog.cpp4
-rw-r--r--src/gui/windows/updaterwindow.cpp4
-rw-r--r--src/gui/windows/worldselectdialog.cpp4
67 files changed, 282 insertions, 411 deletions
diff --git a/src/gui/font.cpp b/src/gui/font.cpp
index cf3116631..acc27d4ab 100644
--- a/src/gui/font.cpp
+++ b/src/gui/font.cpp
@@ -76,6 +76,7 @@
#include "resources/resourcemanager.h"
#include "resources/surfaceimagehelper.h"
+#include "utils/delete2.h"
#include "utils/paths.h"
#include "utils/sdlcheckutils.h"
#include "utils/stringutils.h"
@@ -163,8 +164,7 @@ SDLTextChunk::SDLTextChunk(const std::string &text0, const Color &color0,
SDLTextChunk::~SDLTextChunk()
{
- delete img;
- img = nullptr;
+ delete2(img);
#ifdef UNITTESTS
sdlTextChunkCnt --;
#endif
diff --git a/src/gui/gui.cpp b/src/gui/gui.cpp
index 761810c1a..9a50583b9 100644
--- a/src/gui/gui.cpp
+++ b/src/gui/gui.cpp
@@ -95,6 +95,7 @@
#include "resources/imageset.h"
#include "resources/resourcemanager.h"
+#include "utils/delete2.h"
#include "utils/langs.h"
#include "utils/timer.h"
@@ -290,8 +291,7 @@ void Gui::postInit(Graphics *const graphics)
Gui::~Gui()
{
config.removeListeners(mConfigListener);
- delete mConfigListener;
- mConfigListener = nullptr;
+ delete2(mConfigListener);
if (mMouseCursors)
{
@@ -299,31 +299,22 @@ Gui::~Gui()
mMouseCursors = nullptr;
}
- delete mGuiFont;
- mGuiFont = nullptr;
- delete boldFont;
- boldFont = nullptr;
- delete mHelpFont;
- mHelpFont = nullptr;
- delete mSecureFont;
- mSecureFont = nullptr;
- delete mInfoParticleFont;
- mInfoParticleFont = nullptr;
- delete mNpcFont;
- mNpcFont = nullptr;
+ delete2(mGuiFont);
+ delete2(boldFont);
+ delete2(mHelpFont);
+ delete2(mSecureFont);
+ delete2(mInfoParticleFont);
+ delete2(mNpcFont);
delete getTop();
- delete guiInput;
- guiInput = nullptr;
+ delete2(guiInput);
- delete theme;
- theme = nullptr;
+ delete2(theme);
if (Widget::widgetExists(mTop))
setTop(nullptr);
- delete mFocusHandler;
- mFocusHandler = nullptr;
+ delete2(mFocusHandler);
}
void Gui::logic()
diff --git a/src/gui/theme.cpp b/src/gui/theme.cpp
index b208ce960..6fa007e06 100644
--- a/src/gui/theme.cpp
+++ b/src/gui/theme.cpp
@@ -32,6 +32,7 @@
#include "resources/image.h"
#include "resources/resourcemanager.h"
+#include "utils/delete2.h"
#include "utils/dtor.h"
#include "utils/files.h"
#include "utils/physfstools.h"
@@ -121,10 +122,8 @@ Skin::~Skin()
mStickyImageDown = nullptr;
}
- delete mOptions;
- mOptions = nullptr;
- delete mBorder;
- mBorder = nullptr;
+ delete2(mOptions);
+ delete2(mBorder);
}
void Skin::updateAlpha(const float minimumOpacityAllowed)
diff --git a/src/gui/viewport.cpp b/src/gui/viewport.cpp
index ba11bdf95..df97a5673 100644
--- a/src/gui/viewport.cpp
+++ b/src/gui/viewport.cpp
@@ -35,6 +35,7 @@
#include "input/inputmanager.h"
#include "gui/gui.h"
+#include "gui/font.h"
#include "gui/popups/beingpopup.h"
#include "gui/popups/popupmenu.h"
@@ -42,7 +43,7 @@
#include "gui/windows/ministatuswindow.h"
-#include "gui/font.h"
+#include "utils/delete2.h"
#include "debug.h"
@@ -104,12 +105,9 @@ Viewport::~Viewport()
{
config.removeListeners(this);
CHECKLISTENERS
- delete mPopupMenu;
- mPopupMenu = nullptr;
- delete mBeingPopup;
- mBeingPopup = nullptr;
- delete mTextPopup;
- mTextPopup = nullptr;
+ delete2(mPopupMenu);
+ delete2(mBeingPopup);
+ delete2(mTextPopup);
}
void Viewport::setMap(Map *const map)
diff --git a/src/gui/widgets/button.cpp b/src/gui/widgets/button.cpp
index dffcc7814..054a338aa 100644
--- a/src/gui/widgets/button.cpp
+++ b/src/gui/widgets/button.cpp
@@ -77,9 +77,10 @@
#include "gui/font.h"
#include "gui/gui.h"
-
#include "gui/rect.h"
+#include "utils/delete2.h"
+
#include "debug.h"
int Button::mInstances = 0;
@@ -362,8 +363,7 @@ Button::~Button()
for (int mode = 0; mode < BUTTON_COUNT; mode ++)
theme->unload(button[mode]);
}
- delete mVertexes2;
- mVertexes2 = nullptr;
+ delete2(mVertexes2);
if (mImageSet)
{
mImageSet->decRef();
diff --git a/src/gui/widgets/characterdisplay.cpp b/src/gui/widgets/characterdisplay.cpp
index db2f2e2de..389b3f8cc 100644
--- a/src/gui/widgets/characterdisplay.cpp
+++ b/src/gui/widgets/characterdisplay.cpp
@@ -33,6 +33,7 @@
#include "gui/widgets/label.h"
#include "gui/widgets/layouthelper.h"
+#include "utils/delete2.h"
#include "utils/gettext.h"
#include "utils/stringutils.h"
@@ -77,8 +78,7 @@ CharacterDisplay::CharacterDisplay(const Widget2 *const widget,
CharacterDisplay::~CharacterDisplay()
{
- delete mPopup;
- mPopup = nullptr;
+ delete2(mPopup);
}
void CharacterDisplay::setCharacter(Net::Character *const character)
diff --git a/src/gui/widgets/dropshortcutcontainer.cpp b/src/gui/widgets/dropshortcutcontainer.cpp
index d85bcccf4..67e027a96 100644
--- a/src/gui/widgets/dropshortcutcontainer.cpp
+++ b/src/gui/widgets/dropshortcutcontainer.cpp
@@ -28,6 +28,7 @@
#include "being/playerinfo.h"
+#include "gui/font.h"
#include "gui/viewport.h"
#include "gui/popups/itempopup.h"
@@ -36,7 +37,7 @@
#include "resources/image.h"
-#include "gui/font.h"
+#include "utils/delete2.h"
#include "debug.h"
@@ -81,8 +82,7 @@ DropShortcutContainer::~DropShortcutContainer()
mBackgroundImg->decRef();
mBackgroundImg = nullptr;
}
- delete mItemPopup;
- mItemPopup = nullptr;
+ delete2(mItemPopup);
}
void DropShortcutContainer::setWidget2(const Widget2 *const widget)
diff --git a/src/gui/widgets/emotepage.cpp b/src/gui/widgets/emotepage.cpp
index c0fcb8ecf..789d3e1aa 100644
--- a/src/gui/widgets/emotepage.cpp
+++ b/src/gui/widgets/emotepage.cpp
@@ -25,6 +25,8 @@
#include "resources/imageset.h"
#include "resources/resourcemanager.h"
+#include "utils/delete2.h"
+
#include "debug.h"
namespace
@@ -55,8 +57,7 @@ EmotePage::~EmotePage()
mEmotes->decRef();
mEmotes = nullptr;
}
- delete mVertexes;
- mVertexes = nullptr;
+ delete2(mVertexes);
}
void EmotePage::draw(Graphics *graphics)
diff --git a/src/gui/widgets/guitable.cpp b/src/gui/widgets/guitable.cpp
index 3248f1884..6feed2b12 100644
--- a/src/gui/widgets/guitable.cpp
+++ b/src/gui/widgets/guitable.cpp
@@ -30,12 +30,13 @@
#include "input/keydata.h"
-#include "utils/dtor.h"
-
#include "listeners/actionlistener.h"
#include "render/graphics.h"
+#include "utils/delete2.h"
+#include "utils/dtor.h"
+
#include "debug.h"
float GuiTable::mAlpha = 1.0;
@@ -126,8 +127,7 @@ GuiTable::~GuiTable()
gui->removeDragged(this);
uninstallActionListeners();
- delete mModel;
- mModel = nullptr;
+ delete2(mModel);
}
const TableModel *GuiTable::getModel() const
diff --git a/src/gui/widgets/itemcontainer.cpp b/src/gui/widgets/itemcontainer.cpp
index 1c6cf9ec3..ee2e35920 100644
--- a/src/gui/widgets/itemcontainer.cpp
+++ b/src/gui/widgets/itemcontainer.cpp
@@ -29,6 +29,7 @@
#include "being/playerinfo.h"
+#include "gui/font.h"
#include "gui/gui.h"
#include "gui/viewport.h"
@@ -46,9 +47,10 @@
#include "resources/image.h"
-#include "gui/font.h"
#include "listeners/selectionlistener.h"
+#include "utils/delete2.h"
+
#include <algorithm>
#include "debug.h"
@@ -218,8 +220,7 @@ ItemContainer::~ItemContainer()
if (theme)
theme->unload(mSkin);
- delete mItemPopup;
- mItemPopup = nullptr;
+ delete2(mItemPopup);
delete []mShowMatrix;
}
diff --git a/src/gui/widgets/itemlinkhandler.cpp b/src/gui/widgets/itemlinkhandler.cpp
index 2cf27ae30..efc6ef175 100644
--- a/src/gui/widgets/itemlinkhandler.cpp
+++ b/src/gui/widgets/itemlinkhandler.cpp
@@ -39,6 +39,8 @@
#include "input/mouseinput.h"
+#include "utils/delete2.h"
+
#include <string>
#include "debug.h"
@@ -74,8 +76,7 @@ ItemLinkHandler::ItemLinkHandler() :
ItemLinkHandler::~ItemLinkHandler()
{
- delete mItemPopup;
- mItemPopup = nullptr;
+ delete2(mItemPopup);
}
void ItemLinkHandler::handleLink(const std::string &link, MouseEvent *event)
diff --git a/src/gui/widgets/itemshortcutcontainer.cpp b/src/gui/widgets/itemshortcutcontainer.cpp
index 33ae1890d..420eb5578 100644
--- a/src/gui/widgets/itemshortcutcontainer.cpp
+++ b/src/gui/widgets/itemshortcutcontainer.cpp
@@ -46,6 +46,8 @@
#include "resources/image.h"
+#include "utils/delete2.h"
+
#include "debug.h"
ItemShortcutContainer::ItemShortcutContainer(Widget2 *const widget,
@@ -95,10 +97,8 @@ ItemShortcutContainer::~ItemShortcutContainer()
mBackgroundImg->decRef();
mBackgroundImg = nullptr;
}
- delete mItemPopup;
- mItemPopup = nullptr;
- delete mSpellPopup;
- mSpellPopup = nullptr;
+ delete2(mItemPopup);
+ delete2(mSpellPopup);
}
void ItemShortcutContainer::setWidget2(const Widget2 *const widget)
diff --git a/src/gui/widgets/layout.cpp b/src/gui/widgets/layout.cpp
index 668334fd5..410c8188e 100644
--- a/src/gui/widgets/layout.cpp
+++ b/src/gui/widgets/layout.cpp
@@ -26,6 +26,8 @@
#include "gui/widgets/basiccontainer2.h"
+#include "utils/delete2.h"
+
#include <cassert>
#include "debug.h"
@@ -45,10 +47,7 @@ LayoutCell &ContainerPlacer::operator()
LayoutCell::~LayoutCell()
{
if (mType == ARRAY)
- {
- delete mArray;
- mArray = nullptr;
- }
+ delete2(mArray)
}
LayoutArray &LayoutCell::getArray()
diff --git a/src/gui/widgets/popup.cpp b/src/gui/widgets/popup.cpp
index a8bcec4ea..2116de113 100644
--- a/src/gui/widgets/popup.cpp
+++ b/src/gui/widgets/popup.cpp
@@ -27,6 +27,8 @@
#include "gui/viewport.h"
+#include "utils/delete2.h"
+
#include "debug.h"
Popup::Popup(const std::string &name,
@@ -72,8 +74,7 @@ Popup::~Popup()
{
logger->log("Popup::~Popup(\"%s\")", mPopupName.c_str());
- delete mVertexes;
- mVertexes = nullptr;
+ delete2(mVertexes);
if (mSkin)
{
diff --git a/src/gui/widgets/progressbar.cpp b/src/gui/widgets/progressbar.cpp
index e2ff95228..ea4ef11bd 100644
--- a/src/gui/widgets/progressbar.cpp
+++ b/src/gui/widgets/progressbar.cpp
@@ -28,6 +28,8 @@
#include "gui/font.h"
#include "gui/gui.h"
+#include "utils/delete2.h"
+
#include "debug.h"
int ProgressBar::mInstances = 0;
@@ -100,8 +102,7 @@ ProgressBar::~ProgressBar()
mSkin = nullptr;
}
Theme::unloadRect(mFillRect);
- delete mVertexes;
- mVertexes = nullptr;
+ delete2(mVertexes);
}
void ProgressBar::logic()
diff --git a/src/gui/widgets/progressindicator.cpp b/src/gui/widgets/progressindicator.cpp
index 8e86417bd..c960ad075 100644
--- a/src/gui/widgets/progressindicator.cpp
+++ b/src/gui/widgets/progressindicator.cpp
@@ -28,6 +28,8 @@
#include "resources/animation.h"
#include "resources/imageset.h"
+#include "utils/delete2.h"
+
#include "debug.h"
ProgressIndicator::ProgressIndicator(Widget2 *const widget) :
@@ -54,8 +56,7 @@ ProgressIndicator::~ProgressIndicator()
if (gui)
gui->removeDragged(this);
- delete mIndicator;
- mIndicator = nullptr;
+ delete2(mIndicator);
}
void ProgressIndicator::logic()
diff --git a/src/gui/widgets/scrollarea.cpp b/src/gui/widgets/scrollarea.cpp
index 95323a170..2efa144c9 100644
--- a/src/gui/widgets/scrollarea.cpp
+++ b/src/gui/widgets/scrollarea.cpp
@@ -72,6 +72,8 @@
#include "resources/image.h"
+#include "utils/delete2.h"
+
#include "debug.h"
int ScrollArea::instances = 0;
@@ -164,10 +166,8 @@ ScrollArea::~ScrollArea()
}
}
- delete mVertexes;
- mVertexes = nullptr;
- delete mVertexes2;
- mVertexes2 = nullptr;
+ delete2(mVertexes);
+ delete2(mVertexes2);
setContent(nullptr);
}
diff --git a/src/gui/widgets/shortcutcontainer.cpp b/src/gui/widgets/shortcutcontainer.cpp
index b1bb1e867..49be84b88 100644
--- a/src/gui/widgets/shortcutcontainer.cpp
+++ b/src/gui/widgets/shortcutcontainer.cpp
@@ -26,6 +26,8 @@
#include "gui/gui.h"
+#include "utils/delete2.h"
+
#include "debug.h"
float ShortcutContainer::mAlpha = 1.0;
@@ -51,8 +53,7 @@ ShortcutContainer::~ShortcutContainer()
if (gui)
gui->removeDragged(this);
- delete mVertexes;
- mVertexes = nullptr;
+ delete2(mVertexes);
}
void ShortcutContainer::widgetResized(const Event &event A_UNUSED)
diff --git a/src/gui/widgets/slider.cpp b/src/gui/widgets/slider.cpp
index cf9aad03d..e440631ad 100644
--- a/src/gui/widgets/slider.cpp
+++ b/src/gui/widgets/slider.cpp
@@ -76,6 +76,8 @@
#include "resources/image.h"
+#include "utils/delete2.h"
+
#include "debug.h"
ImageRect Slider::buttons[2];
@@ -130,8 +132,7 @@ Slider::~Slider()
if (gui)
gui->removeDragged(this);
- delete mVertexes;
- mVertexes = nullptr;
+ delete2(mVertexes);
mInstances--;
if (mInstances == 0)
{
diff --git a/src/gui/widgets/spellshortcutcontainer.cpp b/src/gui/widgets/spellshortcutcontainer.cpp
index add394a64..e86376812 100644
--- a/src/gui/widgets/spellshortcutcontainer.cpp
+++ b/src/gui/widgets/spellshortcutcontainer.cpp
@@ -36,6 +36,8 @@
#include "resources/image.h"
+#include "utils/delete2.h"
+
#include "debug.h"
SpellShortcutContainer::SpellShortcutContainer(Widget2 *const widget,
@@ -78,8 +80,7 @@ SpellShortcutContainer::~SpellShortcutContainer()
if (mBackgroundImg)
mBackgroundImg->decRef();
mBackgroundImg = nullptr;
- delete mSpellPopup;
- mSpellPopup = nullptr;
+ delete2(mSpellPopup);
}
void SpellShortcutContainer::setWidget2(const Widget2 *const widget)
diff --git a/src/gui/widgets/tabbedarea.cpp b/src/gui/widgets/tabbedarea.cpp
index 3cb6cb302..cf55fa10b 100644
--- a/src/gui/widgets/tabbedarea.cpp
+++ b/src/gui/widgets/tabbedarea.cpp
@@ -75,6 +75,8 @@
#include "gui/widgets/scrollarea.h"
#include "gui/widgets/tabs/tab.h"
+#include "utils/delete2.h"
+
#include "debug.h"
TabbedArea::TabbedArea(const Widget2 *const widget) :
@@ -127,21 +129,14 @@ TabbedArea::~TabbedArea()
remove(mTabContainer);
remove(mWidgetContainer);
- delete mTabContainer;
- mTabContainer = nullptr;
- delete mWidgetContainer;
- mWidgetContainer = nullptr;
+ delete2(mTabContainer);
+ delete2(mWidgetContainer);
for (size_t i = 0, sz = mTabsToDelete.size(); i < sz; i++)
- {
- delete mTabsToDelete[i];
- mTabsToDelete[i] = nullptr;
- }
+ delete2(mTabsToDelete[i])
- delete mArrowButton[0];
- mArrowButton[0] = nullptr;
- delete mArrowButton[1];
- mArrowButton[1] = nullptr;
+ delete2(mArrowButton[0]);
+ delete2(mArrowButton[1]);
}
void TabbedArea::enableScrollButtons(const bool enable)
diff --git a/src/gui/widgets/tabs/chattab.cpp b/src/gui/widgets/tabs/chattab.cpp
index 8fe9d707b..e52f935b3 100644
--- a/src/gui/widgets/tabs/chattab.cpp
+++ b/src/gui/widgets/tabs/chattab.cpp
@@ -45,6 +45,7 @@
#include "resources/db/itemdb.h"
+#include "utils/delete2.h"
#include "utils/gettext.h"
#include "debug.h"
@@ -85,10 +86,8 @@ ChatTab::~ChatTab()
if (chatWindow)
chatWindow->removeTab(this);
- delete mTextOutput;
- mTextOutput = nullptr;
- delete mScrollArea;
- mScrollArea = nullptr;
+ delete2(mTextOutput);
+ delete2(mScrollArea);
}
void ChatTab::chatLog(std::string line, Own own,
diff --git a/src/gui/widgets/tabs/setup_audio.cpp b/src/gui/widgets/tabs/setup_audio.cpp
index 6cf675635..89a9594c1 100644
--- a/src/gui/widgets/tabs/setup_audio.cpp
+++ b/src/gui/widgets/tabs/setup_audio.cpp
@@ -35,6 +35,7 @@
#include "gui/widgets/layouthelper.h"
#include "gui/widgets/scrollarea.h"
+#include "utils/delete2.h"
#include "utils/gettext.h"
#include "debug.h"
@@ -160,11 +161,8 @@ Setup_Audio::Setup_Audio(const Widget2 *const widget) :
Setup_Audio::~Setup_Audio()
{
- delete mSoundModel;
- mSoundModel = nullptr;
-
- delete mChannelsList;
- mChannelsList = nullptr;
+ delete2(mSoundModel);
+ delete2(mChannelsList);
}
void Setup_Audio::apply()
diff --git a/src/gui/widgets/tabs/setup_colors.cpp b/src/gui/widgets/tabs/setup_colors.cpp
index eb7e695f4..00537ad05 100644
--- a/src/gui/widgets/tabs/setup_colors.cpp
+++ b/src/gui/widgets/tabs/setup_colors.cpp
@@ -34,6 +34,7 @@
#include "gui/widgets/textfield.h"
#include "gui/widgets/textpreview.h"
+#include "utils/delete2.h"
#include "utils/gettext.h"
#include "utils/stringutils.h"
@@ -198,15 +199,9 @@ Setup_Colors::Setup_Colors(const Widget2 *const widget) :
Setup_Colors::~Setup_Colors()
{
if (mPreviewBox && mPreviewBox->getContent() == mPreview)
- {
- delete mTextPreview;
- mTextPreview = nullptr;
- }
+ delete2(mTextPreview)
else
- {
- delete mPreview;
- mPreview = nullptr;
- }
+ delete2(mPreview)
}
void Setup_Colors::action(const ActionEvent &event)
diff --git a/src/gui/widgets/tabs/setup_input.cpp b/src/gui/widgets/tabs/setup_input.cpp
index b04937881..a29e0d797 100644
--- a/src/gui/widgets/tabs/setup_input.cpp
+++ b/src/gui/widgets/tabs/setup_input.cpp
@@ -41,6 +41,8 @@
#include "gui/models/listmodel.h"
+#include "utils/delete2.h"
+
#include "debug.h"
static int selectedData = 0;
@@ -169,21 +171,14 @@ Setup_Input::Setup_Input(const Widget2 *const widget) :
Setup_Input::~Setup_Input()
{
- delete mKeyList;
- mKeyList = nullptr;
- delete mKeyListModel;
- mKeyListModel = nullptr;
-
- delete mAssignKeyButton;
- mAssignKeyButton = nullptr;
- delete mUnassignKeyButton;
- mUnassignKeyButton = nullptr;
- delete mResetKeysButton;
- mResetKeysButton = nullptr;
+ delete2(mKeyList);
+ delete2(mKeyListModel);
+ delete2(mAssignKeyButton);
+ delete2(mUnassignKeyButton);
+ delete2(mResetKeysButton);
delete [] mActionDataSize;
mActionDataSize = nullptr;
- delete mScrollArea;
- mScrollArea = nullptr;
+ delete2(mScrollArea);
}
void Setup_Input::apply()
diff --git a/src/gui/widgets/tabs/setup_joystick.cpp b/src/gui/widgets/tabs/setup_joystick.cpp
index b3d7b78b9..4d2845656 100644
--- a/src/gui/widgets/tabs/setup_joystick.cpp
+++ b/src/gui/widgets/tabs/setup_joystick.cpp
@@ -34,6 +34,7 @@
#include "gui/widgets/label.h"
#include "gui/widgets/layouthelper.h"
+#include "utils/delete2.h"
#include "utils/gettext.h"
#include "debug.h"
@@ -99,8 +100,7 @@ Setup_Joystick::Setup_Joystick(const Widget2 *const widget) :
Setup_Joystick::~Setup_Joystick()
{
- delete mNamesModel;
- mNamesModel = nullptr;
+ delete2(mNamesModel);
}
void Setup_Joystick::action(const ActionEvent &event)
diff --git a/src/gui/widgets/tabs/setup_other.cpp b/src/gui/widgets/tabs/setup_other.cpp
index 12cb614cd..ed8ba11ad 100644
--- a/src/gui/widgets/tabs/setup_other.cpp
+++ b/src/gui/widgets/tabs/setup_other.cpp
@@ -31,6 +31,7 @@
#include "configuration.h"
#include "map.h"
+#include "utils/delete2.h"
#include "utils/gettext.h"
#include "debug.h"
@@ -404,12 +405,9 @@ Setup_Other::Setup_Other(const Widget2 *const widget) :
Setup_Other::~Setup_Other()
{
- delete mProxyTypeList;
- mProxyTypeList = nullptr;
- delete mShortcutsList;
- mShortcutsList = nullptr;
- delete mDensityList;
- mDensityList = nullptr;
+ delete2(mProxyTypeList);
+ delete2(mShortcutsList);
+ delete2(mDensityList);
}
void Setup_Other::apply()
diff --git a/src/gui/widgets/tabs/setup_perfomance.cpp b/src/gui/widgets/tabs/setup_perfomance.cpp
index 5a0566ec2..dad054e83 100644
--- a/src/gui/widgets/tabs/setup_perfomance.cpp
+++ b/src/gui/widgets/tabs/setup_perfomance.cpp
@@ -28,6 +28,7 @@
#include "gui/widgets/scrollarea.h"
#include "gui/widgets/setupitem.h"
+#include "utils/delete2.h"
#include "utils/gettext.h"
#include "debug.h"
@@ -159,6 +160,5 @@ Setup_Perfomance::Setup_Perfomance(const Widget2 *const widget) :
Setup_Perfomance::~Setup_Perfomance()
{
- delete mTexturesList;
- mTexturesList = nullptr;
+ delete2(mTexturesList);
}
diff --git a/src/gui/widgets/tabs/setup_relations.cpp b/src/gui/widgets/tabs/setup_relations.cpp
index ca060477f..77a758cb4 100644
--- a/src/gui/widgets/tabs/setup_relations.cpp
+++ b/src/gui/widgets/tabs/setup_relations.cpp
@@ -37,6 +37,7 @@
#include "gui/widgets/scrollarea.h"
#include "gui/widgets/guitable.h"
+#include "utils/delete2.h"
#include "utils/dtor.h"
#include "utils/gettext.h"
@@ -81,10 +82,8 @@ public:
~PlayerTableModel()
{
freeWidgets();
- delete mListModel;
- mListModel = nullptr;
- delete mPlayers;
- mPlayers = nullptr;
+ delete2(mListModel)
+ delete2(mPlayers)
}
int getRows() const override final
@@ -159,9 +158,7 @@ public:
void freeWidgets()
{
- delete mPlayers;
- mPlayers = nullptr;
-
+ delete2(mPlayers)
delete_all(mWidgets);
mWidgets.clear();
}
@@ -266,8 +263,7 @@ Setup_Relations::Setup_Relations(const Widget2 *const widget) :
Setup_Relations::~Setup_Relations()
{
player_relations.removeListener(this);
- delete mIgnoreActionChoicesModel;
- mIgnoreActionChoicesModel = nullptr;
+ delete2(mIgnoreActionChoicesModel);
}
diff --git a/src/gui/widgets/tabs/setup_theme.cpp b/src/gui/widgets/tabs/setup_theme.cpp
index 424828694..9b23fc3c3 100644
--- a/src/gui/widgets/tabs/setup_theme.cpp
+++ b/src/gui/widgets/tabs/setup_theme.cpp
@@ -37,6 +37,7 @@
#include "configuration.h"
+#include "utils/delete2.h"
#include "utils/gettext.h"
#include "resources/resourcemanager.h"
@@ -371,26 +372,13 @@ Setup_Theme::Setup_Theme(const Widget2 *const widget) :
Setup_Theme::~Setup_Theme()
{
- delete mInfo;
- mInfo = nullptr;
-
- delete mThemesModel;
- mThemesModel = nullptr;
-
- delete mFontsModel;
- mFontsModel = nullptr;
-
- delete mFontSizeListModel;
- mFontSizeListModel = nullptr;
-
- delete mNpcFontSizeListModel;
- mNpcFontSizeListModel = nullptr;
-
- delete mLangListModel;
- mLangListModel = nullptr;
-
- delete mInfo;
- mInfo = nullptr;
+ delete2(mInfo);
+ delete2(mThemesModel);
+ delete2(mFontsModel);
+ delete2(mFontSizeListModel);
+ delete2(mNpcFontSizeListModel);
+ delete2(mLangListModel);
+ delete2(mInfo);
}
void Setup_Theme::updateInfo()
diff --git a/src/gui/widgets/tabs/setup_touch.cpp b/src/gui/widgets/tabs/setup_touch.cpp
index fb50ab4d5..eab39ccb0 100644
--- a/src/gui/widgets/tabs/setup_touch.cpp
+++ b/src/gui/widgets/tabs/setup_touch.cpp
@@ -27,6 +27,7 @@
#include "gui/widgets/setuptouchitem.h"
#include "gui/widgets/scrollarea.h"
+#include "utils/delete2.h"
#include "utils/gettext.h"
#include "utils/stringutils.h"
@@ -126,10 +127,7 @@ Setup_Touch::Setup_Touch(const Widget2 *const widget) :
Setup_Touch::~Setup_Touch()
{
- delete mSizeList;
- mSizeList = nullptr;
- delete mFormatList;
- mFormatList = nullptr;
- delete mActionsList;
- mActionsList = nullptr;
+ delete2(mSizeList);
+ delete2(mFormatList);
+ delete2(mActionsList);
}
diff --git a/src/gui/widgets/tabs/setup_video.cpp b/src/gui/widgets/tabs/setup_video.cpp
index 416ae8c3c..dfe14fa2c 100644
--- a/src/gui/widgets/tabs/setup_video.cpp
+++ b/src/gui/widgets/tabs/setup_video.cpp
@@ -41,6 +41,7 @@
#include "render/rendererslistsdl.h"
+#include "utils/delete2.h"
#include "utils/gettext.h"
#include "utils/sdlhelper.h"
@@ -309,14 +310,10 @@ Setup_Video::Setup_Video(const Widget2 *const widget) :
Setup_Video::~Setup_Video()
{
- delete mModeListModel;
- mModeListModel = nullptr;
- delete mModeList;
- mModeList = nullptr;
- delete mOpenGLListModel;
- mOpenGLListModel = nullptr;
- delete mDialog;
- mDialog = nullptr;
+ delete2(mModeListModel);
+ delete2(mModeList);
+ delete2(mOpenGLListModel);
+ delete2(mDialog);
}
void Setup_Video::apply()
diff --git a/src/gui/widgets/tabs/setup_visual.cpp b/src/gui/widgets/tabs/setup_visual.cpp
index 860b1d516..eb6591f9f 100644
--- a/src/gui/widgets/tabs/setup_visual.cpp
+++ b/src/gui/widgets/tabs/setup_visual.cpp
@@ -28,6 +28,7 @@
#include "client.h"
+#include "utils/delete2.h"
#include "utils/gettext.h"
#include "debug.h"
@@ -215,18 +216,12 @@ Setup_Visual::Setup_Visual(const Widget2 *const widget) :
Setup_Visual::~Setup_Visual()
{
- delete mSpeachList;
- mSpeachList = nullptr;
- delete mAmbientFxList;
- mAmbientFxList = nullptr;
- delete mParticleList;
- mParticleList = nullptr;
- delete mParticleTypeList;
- mParticleTypeList = nullptr;
- delete mVSyncList;
- mVSyncList = nullptr;
- delete mScaleList;
- mScaleList = nullptr;
+ delete2(mSpeachList);
+ delete2(mAmbientFxList);
+ delete2(mParticleList);
+ delete2(mParticleTypeList);
+ delete2(mVSyncList);
+ delete2(mScaleList);
}
void Setup_Visual::apply()
diff --git a/src/gui/widgets/tabs/setuptabscroll.cpp b/src/gui/widgets/tabs/setuptabscroll.cpp
index 9c185b2bb..cd169e0bf 100644
--- a/src/gui/widgets/tabs/setuptabscroll.cpp
+++ b/src/gui/widgets/tabs/setuptabscroll.cpp
@@ -24,6 +24,8 @@
#include "gui/widgets/setupitem.h"
#include "gui/widgets/vertcontainer.h"
+#include "utils/delete2.h"
+
#include "debug.h"
SetupTabScroll::SetupTabScroll(const Widget2 *const widget) :
@@ -41,10 +43,7 @@ SetupTabScroll::SetupTabScroll(const Widget2 *const widget) :
SetupTabScroll::~SetupTabScroll()
{
mScroll = nullptr;
-
- delete mContainer;
- mContainer = nullptr;
-
+ delete2(mContainer);
removeItems();
}
diff --git a/src/gui/widgets/tabs/tab.cpp b/src/gui/widgets/tabs/tab.cpp
index 32d0cf2a6..c2a6c0207 100644
--- a/src/gui/widgets/tabs/tab.cpp
+++ b/src/gui/widgets/tabs/tab.cpp
@@ -75,6 +75,8 @@
#include "resources/image.h"
+#include "utils/delete2.h"
+
#include "debug.h"
int Tab::mInstances = 0;
@@ -129,16 +131,14 @@ Tab::~Tab()
theme->unload(tabImg[mode]);
}
- delete mLabel;
- mLabel = nullptr;
+ delete2(mLabel);
if (mImage)
{
mImage->decRef();
mImage = nullptr;
}
- delete mVertexes;
- mVertexes = nullptr;
+ delete2(mVertexes);
}
void Tab::init()
diff --git a/src/gui/widgets/textfield.cpp b/src/gui/widgets/textfield.cpp
index d1f19785f..f89d2ead2 100644
--- a/src/gui/widgets/textfield.cpp
+++ b/src/gui/widgets/textfield.cpp
@@ -78,6 +78,7 @@
#include "resources/image.h"
#include "utils/copynpaste.h"
+#include "utils/delete2.h"
#include "utils/timer.h"
#undef DELETE // Win32 compatibility hack
@@ -154,8 +155,7 @@ TextField::~TextField()
if (gui)
gui->removeDragged(this);
- delete mPopupMenu;
- mPopupMenu = nullptr;
+ delete2(mPopupMenu);
instances--;
if (instances == 0)
diff --git a/src/gui/widgets/window.cpp b/src/gui/widgets/window.cpp
index 4f8bc88b3..9e032f75b 100644
--- a/src/gui/widgets/window.cpp
+++ b/src/gui/widgets/window.cpp
@@ -82,6 +82,8 @@
#include "resources/cursor.h"
#include "resources/image.h"
+#include "utils/delete2.h"
+
#include "debug.h"
const int resizeMask = 8 + 4 + 2 + 1;
@@ -219,8 +221,7 @@ Window::~Window()
saveWindowState();
- delete mLayout;
- mLayout = nullptr;
+ delete2(mLayout);
while (!mWidgets.empty())
delete mWidgets.front();
@@ -228,8 +229,7 @@ Window::~Window()
mWidgets.clear();
removeWidgetListener(this);
- delete mVertexes;
- mVertexes = nullptr;
+ delete2(mVertexes);
windowInstances--;
@@ -1262,8 +1262,7 @@ void Window::reflowLayout(int w, int h)
return;
mLayout->reflow(w, h);
- delete mLayout;
- mLayout = nullptr;
+ delete2(mLayout);
setContentSize(w, h);
}
diff --git a/src/gui/windowmenu.cpp b/src/gui/windowmenu.cpp
index 2431a35ea..910bba705 100644
--- a/src/gui/windowmenu.cpp
+++ b/src/gui/windowmenu.cpp
@@ -34,6 +34,7 @@
#include "gui/widgets/button.h"
+#include "utils/delete2.h"
#include "utils/dtor.h"
#include "utils/gettext.h"
@@ -171,8 +172,7 @@ WindowMenu::~WindowMenu()
config.removeListener("autohideButtons", this);
CHECKLISTENERS
- delete mTextPopup;
- mTextPopup = nullptr;
+ delete2(mTextPopup);
for (std::map <std::string, ButtonInfo*>::iterator
it = mButtonNames.begin(),
it_end = mButtonNames.end(); it != it_end; ++it)
diff --git a/src/gui/windows/buydialog.cpp b/src/gui/windows/buydialog.cpp
index 86e819121..8bece77ef 100644
--- a/src/gui/windows/buydialog.cpp
+++ b/src/gui/windows/buydialog.cpp
@@ -47,6 +47,7 @@
#include "resources/iteminfo.h"
+#include "utils/delete2.h"
#include "utils/gettext.h"
#include <algorithm>
@@ -302,9 +303,7 @@ void BuyDialog::init()
BuyDialog::~BuyDialog()
{
- delete mShopItems;
- mShopItems = nullptr;
-
+ delete2(mShopItems);
instances.remove(this);
}
diff --git a/src/gui/windows/changeemaildialog.cpp b/src/gui/windows/changeemaildialog.cpp
index b8f9c1fd2..ce9ec84e8 100644
--- a/src/gui/windows/changeemaildialog.cpp
+++ b/src/gui/windows/changeemaildialog.cpp
@@ -35,6 +35,7 @@
#include "net/loginhandler.h"
#include "net/net.h"
+#include "utils/delete2.h"
#include "utils/gettext.h"
#include <string>
@@ -105,8 +106,7 @@ ChangeEmailDialog::ChangeEmailDialog(LoginData *const data):
ChangeEmailDialog::~ChangeEmailDialog()
{
- delete mWrongDataNoticeListener;
- mWrongDataNoticeListener = nullptr;
+ delete2(mWrongDataNoticeListener);
}
void ChangeEmailDialog::action(const ActionEvent &event)
diff --git a/src/gui/windows/changepassworddialog.cpp b/src/gui/windows/changepassworddialog.cpp
index 05c7a9309..051fa6434 100644
--- a/src/gui/windows/changepassworddialog.cpp
+++ b/src/gui/windows/changepassworddialog.cpp
@@ -36,6 +36,7 @@
#include "net/loginhandler.h"
#include "net/net.h"
+#include "utils/delete2.h"
#include "utils/gettext.h"
#include <string>
@@ -84,8 +85,7 @@ ChangePasswordDialog::ChangePasswordDialog(LoginData *const data):
ChangePasswordDialog::~ChangePasswordDialog()
{
- delete mWrongDataNoticeListener;
- mWrongDataNoticeListener = nullptr;
+ delete2(mWrongDataNoticeListener);
}
void ChangePasswordDialog::action(const ActionEvent &event)
diff --git a/src/gui/windows/charcreatedialog.cpp b/src/gui/windows/charcreatedialog.cpp
index 53b4b55ff..cf69af099 100644
--- a/src/gui/windows/charcreatedialog.cpp
+++ b/src/gui/windows/charcreatedialog.cpp
@@ -45,6 +45,7 @@
#include "resources/db/chardb.h"
#include "resources/db/itemdb.h"
+#include "utils/delete2.h"
#include "utils/gettext.h"
#include "debug.h"
@@ -313,8 +314,7 @@ CharCreateDialog::CharCreateDialog(CharSelectDialog *const parent,
CharCreateDialog::~CharCreateDialog()
{
- delete mPlayer;
- mPlayer = nullptr;
+ delete2(mPlayer);
if (Net::getCharServerHandler())
Net::getCharServerHandler()->setCharCreateDialog(nullptr);
@@ -491,14 +491,11 @@ void CharCreateDialog::setAttributes(const StringVect &labels,
for (unsigned i = 0; i < mAttributeLabel.size(); i++)
{
remove(mAttributeLabel[i]);
- delete mAttributeLabel[i];
- mAttributeLabel[i] = nullptr;
+ delete2(mAttributeLabel[i])
remove(mAttributeSlider[i]);
- delete mAttributeSlider[i];
- mAttributeSlider[i] = nullptr;
+ delete2(mAttributeSlider[i])
remove(mAttributeValue[i]);
- delete mAttributeValue[i];
- mAttributeValue[i] = nullptr;
+ delete2(mAttributeValue[i])
}
mAttributeLabel.resize(labels.size());
diff --git a/src/gui/windows/chatwindow.cpp b/src/gui/windows/chatwindow.cpp
index 0a5480520..51ca414a7 100644
--- a/src/gui/windows/chatwindow.cpp
+++ b/src/gui/windows/chatwindow.cpp
@@ -67,6 +67,7 @@
#include "net/net.h"
#include "utils/copynpaste.h"
+#include "utils/delete2.h"
#include "utils/gettext.h"
#include "resources/resourcemanager.h"
@@ -266,12 +267,9 @@ ChatWindow::~ChatWindow()
saveState();
config.setValue("ReturnToggles", mReturnToggles);
removeAllWhispers();
- delete mItemLinkHandler;
- mItemLinkHandler = nullptr;
- delete mColorPicker;
- mColorPicker = nullptr;
- delete mColorListModel;
- mColorListModel = nullptr;
+ delete2(mItemLinkHandler);
+ delete2(mColorPicker);
+ delete2(mColorListModel);
}
void ChatWindow::postInit()
@@ -646,8 +644,7 @@ void ChatWindow::ignoreAllWhispers()
PlayerRelation::IGNORED);
}
- delete (iter->second);
- iter->second = nullptr;
+ delete2 (iter->second)
}
}
diff --git a/src/gui/windows/debugwindow.cpp b/src/gui/windows/debugwindow.cpp
index 50dc5dbe5..438103f0a 100644
--- a/src/gui/windows/debugwindow.cpp
+++ b/src/gui/windows/debugwindow.cpp
@@ -42,6 +42,7 @@
#include "net/packetcounters.h"
+#include "utils/delete2.h"
#include "utils/gettext.h"
#include "utils/stringutils.h"
#include "utils/timer.h"
@@ -88,12 +89,9 @@ DebugWindow::DebugWindow() :
DebugWindow::~DebugWindow()
{
- delete mMapWidget;
- mMapWidget = nullptr;
- delete mTargetWidget;
- mTargetWidget = nullptr;
- delete mNetWidget;
- mNetWidget = nullptr;
+ delete2(mMapWidget);
+ delete2(mTargetWidget);
+ delete2(mNetWidget);
}
void DebugWindow::postInit()
diff --git a/src/gui/windows/emotewindow.cpp b/src/gui/windows/emotewindow.cpp
index 3a7141533..0f286b145 100644
--- a/src/gui/windows/emotewindow.cpp
+++ b/src/gui/windows/emotewindow.cpp
@@ -28,6 +28,7 @@
#include "gui/widgets/scrollarea.h"
#include "gui/widgets/tabbedarea.h"
+#include "utils/delete2.h"
#include "utils/gettext.h"
#include "resources/image.h"
@@ -121,20 +122,13 @@ EmoteWindow::~EmoteWindow()
{
mTabs->removeAll(false);
mTabs->removeTab(mTabs->getTabByIndex(0));
- delete mEmotePage;
- mEmotePage = nullptr;
- delete mColorPage;
- mColorPage = nullptr;
- delete mColorModel;
- mColorModel = nullptr;
- delete mScrollColorPage;
- mScrollColorPage = nullptr;
- delete mFontPage;
- mFontPage = nullptr;
- delete mFontModel;
- mFontModel = nullptr;
- delete mScrollFontPage;
- mScrollFontPage = nullptr;
+ delete2(mEmotePage);
+ delete2(mColorPage);
+ delete2(mColorModel);
+ delete2(mScrollColorPage);
+ delete2(mFontPage);
+ delete2(mFontModel);
+ delete2(mScrollFontPage);
if (mImageSet)
{
mImageSet->decRef();
diff --git a/src/gui/windows/equipmentwindow.cpp b/src/gui/windows/equipmentwindow.cpp
index 47e7e8b7d..4c026281b 100644
--- a/src/gui/windows/equipmentwindow.cpp
+++ b/src/gui/windows/equipmentwindow.cpp
@@ -44,6 +44,7 @@
#include "resources/imageset.h"
+#include "utils/delete2.h"
#include "utils/dtor.h"
#include "utils/gettext.h"
@@ -132,14 +133,12 @@ void EquipmentWindow::postInit()
EquipmentWindow::~EquipmentWindow()
{
- delete mItemPopup;
- mItemPopup = nullptr;
+ delete2(mItemPopup);
if (this == beingEquipmentWindow)
{
if (mEquipment)
delete mEquipment->getBackend();
- delete mEquipment;
- mEquipment = nullptr;
+ delete2(mEquipment)
}
delete_all(mBoxes);
mBoxes.clear();
@@ -152,8 +151,7 @@ EquipmentWindow::~EquipmentWindow()
mSlotBackground->decRef();
if (mSlotHighlightedBackground)
mSlotHighlightedBackground->decRef();
- delete mVertexes;
- mVertexes = nullptr;
+ delete2(mVertexes);
}
void EquipmentWindow::draw(Graphics *graphics)
diff --git a/src/gui/windows/inventorywindow.cpp b/src/gui/windows/inventorywindow.cpp
index b9bdf6ad9..c2a4b4636 100644
--- a/src/gui/windows/inventorywindow.cpp
+++ b/src/gui/windows/inventorywindow.cpp
@@ -59,6 +59,8 @@
#include "net/inventoryhandler.h"
#include "net/net.h"
+#include "utils/delete2.h"
+
#include <string>
#include "debug.h"
@@ -274,8 +276,7 @@ InventoryWindow::~InventoryWindow()
invInstances.front()->updateDropButton();
mSortDropDown->hideDrop(false);
- delete mSortModel;
- mSortModel = nullptr;
+ delete2(mSortModel);
mTextPopup = nullptr;
}
diff --git a/src/gui/windows/itemamountwindow.cpp b/src/gui/windows/itemamountwindow.cpp
index 7db944695..472057060 100644
--- a/src/gui/windows/itemamountwindow.cpp
+++ b/src/gui/windows/itemamountwindow.cpp
@@ -48,6 +48,7 @@
#include "gui/widgets/label.h"
#include "gui/widgets/slider.h"
+#include "utils/delete2.h"
#include "utils/gettext.h"
#include "debug.h"
@@ -261,8 +262,7 @@ void ItemAmountWindow::postInit()
ItemAmountWindow::~ItemAmountWindow()
{
- delete mItemPopup;
- mItemPopup = nullptr;
+ delete2(mItemPopup);
}
// Show ItemTooltip
diff --git a/src/gui/windows/logindialog.cpp b/src/gui/windows/logindialog.cpp
index 4db58e911..984006204 100644
--- a/src/gui/windows/logindialog.cpp
+++ b/src/gui/windows/logindialog.cpp
@@ -46,6 +46,7 @@
#include "net/loginhandler.h"
#include "net/net.h"
+#include "utils/delete2.h"
#include "utils/gettext.h"
#include "utils/paths.h"
#include "utils/process.h"
@@ -208,10 +209,8 @@ void LoginDialog::postInit()
LoginDialog::~LoginDialog()
{
- delete mUpdateTypeModel;
- mUpdateTypeModel = nullptr;
- delete mUpdateListModel;
- mUpdateListModel = nullptr;
+ delete2(mUpdateTypeModel);
+ delete2(mUpdateListModel);
}
void LoginDialog::action(const ActionEvent &event)
diff --git a/src/gui/windows/minimap.cpp b/src/gui/windows/minimap.cpp
index 583a37746..9be6d7304 100644
--- a/src/gui/windows/minimap.cpp
+++ b/src/gui/windows/minimap.cpp
@@ -39,6 +39,7 @@
#include "resources/imagehelper.h"
#include "resources/resourcemanager.h"
+#include "utils/delete2.h"
#include "utils/gettext.h"
#include "utils/sdlcheckutils.h"
@@ -97,8 +98,7 @@ Minimap::~Minimap()
mMapImage->decRef();
mMapImage = nullptr;
}
- delete mTextPopup;
- mTextPopup = nullptr;
+ delete2(mTextPopup);
}
void Minimap::setMap(const Map *const map)
diff --git a/src/gui/windows/ministatuswindow.cpp b/src/gui/windows/ministatuswindow.cpp
index d8f28535f..885ea619b 100644
--- a/src/gui/windows/ministatuswindow.cpp
+++ b/src/gui/windows/ministatuswindow.cpp
@@ -42,6 +42,7 @@
#include "net/playerhandler.h"
#include "net/gamehandler.h"
+#include "utils/delete2.h"
#include "utils/dtor.h"
#include "utils/gettext.h"
@@ -147,10 +148,8 @@ MiniStatusWindow::MiniStatusWindow() :
MiniStatusWindow::~MiniStatusWindow()
{
- delete mTextPopup;
- mTextPopup = nullptr;
- delete mStatusPopup;
- mStatusPopup = nullptr;
+ delete2(mTextPopup);
+ delete2(mStatusPopup);
delete_all(mIcons);
mIcons.clear();
diff --git a/src/gui/windows/npcdialog.cpp b/src/gui/windows/npcdialog.cpp
index 17ff9a8c1..56306a90f 100644
--- a/src/gui/windows/npcdialog.cpp
+++ b/src/gui/windows/npcdialog.cpp
@@ -57,6 +57,7 @@
#include "net/npchandler.h"
#include "utils/copynpaste.h"
+#include "utils/delete2.h"
#include "utils/gettext.h"
#include "debug.h"
@@ -216,44 +217,23 @@ NpcDialog::~NpcDialog()
delete mPlayerBox;
}
- delete mTextBox;
- mTextBox = nullptr;
- delete mClearButton;
- mClearButton = nullptr;
- delete mButton;
- mButton = nullptr;
- delete mButton2;
- mButton2 = nullptr;
- delete mButton3;
- mButton3 = nullptr;
-
- // These might not actually be in the layout, so lets be safe
- delete mScrollArea;
- mScrollArea = nullptr;
- delete mItemList;
- mItemList = nullptr;
- delete mTextField;
- mTextField = nullptr;
- delete mIntField;
- mIntField = nullptr;
- delete mResetButton;
- mResetButton = nullptr;
- delete mPlusButton;
- mPlusButton = nullptr;
- delete mMinusButton;
- mMinusButton = nullptr;
- delete mItemLinkHandler;
- mItemLinkHandler = nullptr;
-
- delete mItemContainer;
- mItemContainer = nullptr;
- delete mInventory;
- mInventory = nullptr;
- delete mItemScrollArea;
- mItemScrollArea = nullptr;
-
- delete mListScrollArea;
- mListScrollArea = nullptr;
+ delete2(mTextBox);
+ delete2(mClearButton);
+ delete2(mButton);
+ delete2(mButton2);
+ delete2(mButton3);
+ delete2(mScrollArea);
+ delete2(mItemList);
+ delete2(mTextField);
+ delete2(mIntField);
+ delete2(mResetButton);
+ delete2(mPlusButton);
+ delete2(mMinusButton);
+ delete2(mItemLinkHandler);
+ delete2(mItemContainer);
+ delete2(mInventory);
+ delete2(mItemScrollArea);
+ delete2(mListScrollArea);
FOR_EACH (ImageVectorIter, it, mImages)
{
@@ -896,8 +876,7 @@ void NpcDialog::showAvatar(const uint16_t avatarId)
}
else
{
- delete mAvatarBeing;
- mAvatarBeing = nullptr;
+ delete2(mAvatarBeing)
mPlayerBox->setPlayer(nullptr);
}
if (needShow != mShowAvatar)
diff --git a/src/gui/windows/questswindow.cpp b/src/gui/windows/questswindow.cpp
index 8d4eae9c8..b57ed9bd7 100644
--- a/src/gui/windows/questswindow.cpp
+++ b/src/gui/windows/questswindow.cpp
@@ -38,6 +38,7 @@
#include "gui/widgets/itemlinkhandler.h"
#include "gui/widgets/scrollarea.h"
+#include "utils/delete2.h"
#include "utils/dtor.h"
#include "utils/gettext.h"
@@ -178,8 +179,7 @@ QuestsWindow::QuestsWindow() :
QuestsWindow::~QuestsWindow()
{
- delete mQuestsModel;
- mQuestsModel = nullptr;
+ delete2(mQuestsModel);
for (std::map<int, std::vector<QuestItem*> >::iterator it
= mQuests.begin(), it_end = mQuests.end(); it != it_end; ++ it)
@@ -194,8 +194,7 @@ QuestsWindow::~QuestsWindow()
delete_all(mAllEffects);
mAllEffects.clear();
- delete mItemLinkHandler;
- mItemLinkHandler = nullptr;
+ delete2(mItemLinkHandler);
mQuests.clear();
mQuestLinks.clear();
if (mCompleteIcon)
diff --git a/src/gui/windows/quitdialog.cpp b/src/gui/windows/quitdialog.cpp
index 560968311..5205db1e6 100644
--- a/src/gui/windows/quitdialog.cpp
+++ b/src/gui/windows/quitdialog.cpp
@@ -42,6 +42,7 @@
#include "net/gamehandler.h"
#include "net/net.h"
+#include "utils/delete2.h"
#include "utils/gettext.h"
#include "utils/process.h"
@@ -131,14 +132,10 @@ QuitDialog::~QuitDialog()
{
if (mMyPointer)
*mMyPointer = nullptr;
- delete mForceQuit;
- mForceQuit = nullptr;
- delete mLogoutQuit;
- mLogoutQuit = nullptr;
- delete mSwitchAccountServer;
- mSwitchAccountServer = nullptr;
- delete mSwitchCharacter;
- mSwitchCharacter = nullptr;
+ delete2(mForceQuit);
+ delete2(mLogoutQuit);
+ delete2(mSwitchAccountServer);
+ delete2(mSwitchCharacter);
}
void QuitDialog::placeOption(ContainerPlacer &placer,
diff --git a/src/gui/windows/registerdialog.cpp b/src/gui/windows/registerdialog.cpp
index 9c74cbc0d..55a328fa8 100644
--- a/src/gui/windows/registerdialog.cpp
+++ b/src/gui/windows/registerdialog.cpp
@@ -40,6 +40,7 @@
#include "net/loginhandler.h"
#include "net/net.h"
+#include "utils/delete2.h"
#include "utils/gettext.h"
#include "debug.h"
@@ -169,8 +170,7 @@ void RegisterDialog::postInit()
RegisterDialog::~RegisterDialog()
{
- delete mWrongDataNoticeListener;
- mWrongDataNoticeListener = nullptr;
+ delete2(mWrongDataNoticeListener);
}
void RegisterDialog::action(const ActionEvent &event)
diff --git a/src/gui/windows/selldialog.cpp b/src/gui/windows/selldialog.cpp
index ebee65d1e..604caa72e 100644
--- a/src/gui/windows/selldialog.cpp
+++ b/src/gui/windows/selldialog.cpp
@@ -45,6 +45,7 @@
#include "resources/iteminfo.h"
+#include "utils/delete2.h"
#include "utils/gettext.h"
#include "debug.h"
@@ -162,8 +163,7 @@ void SellDialog::init()
SellDialog::~SellDialog()
{
- delete mShopItems;
- mShopItems = nullptr;
+ delete2(mShopItems);
instances.remove(this);
}
diff --git a/src/gui/windows/serverdialog.cpp b/src/gui/windows/serverdialog.cpp
index 33b6f1599..9e85f5c89 100644
--- a/src/gui/windows/serverdialog.cpp
+++ b/src/gui/windows/serverdialog.cpp
@@ -46,6 +46,7 @@
#include "gui/widgets/listbox.h"
#include "gui/widgets/scrollarea.h"
+#include "utils/delete2.h"
#include "utils/gettext.h"
#include "utils/langs.h"
@@ -295,11 +296,9 @@ ServerDialog::~ServerDialog()
if (mDownload)
{
mDownload->cancel();
- delete mDownload;
- mDownload = nullptr;
+ delete2(mDownload)
}
- delete mServersListModel;
- mServersListModel = nullptr;
+ delete2(mServersListModel);
}
void ServerDialog::connectToSelectedServer()
@@ -517,8 +516,7 @@ void ServerDialog::downloadServerList()
if (mDownload)
{
mDownload->cancel();
- delete mDownload;
- mDownload = nullptr;
+ delete2(mDownload)
}
mDownload = new Net::Download(this, listFile,
diff --git a/src/gui/windows/setupwindow.cpp b/src/gui/windows/setupwindow.cpp
index 1760d00bd..7239061ff 100644
--- a/src/gui/windows/setupwindow.cpp
+++ b/src/gui/windows/setupwindow.cpp
@@ -48,6 +48,7 @@
#include "gui/widgets/label.h"
#include "gui/widgets/tabbedarea.h"
+#include "utils/delete2.h"
#include "utils/dtor.h"
#include "utils/gettext.h"
@@ -223,8 +224,7 @@ void SetupWindow::unloadModTab()
mTabs.remove(mModsTab);
Tab *const tab = mPanel->getTab(mModsTab->getName());
mPanel->removeTab(tab);
- delete mModsTab;
- mModsTab = nullptr;
+ delete2(mModsTab)
}
}
diff --git a/src/gui/windows/shopwindow.cpp b/src/gui/windows/shopwindow.cpp
index 923511baa..b44dcc19e 100644
--- a/src/gui/windows/shopwindow.cpp
+++ b/src/gui/windows/shopwindow.cpp
@@ -58,6 +58,7 @@
#include "resources/iteminfo.h"
+#include "utils/delete2.h"
#include "utils/gettext.h"
#include <sstream>
@@ -197,11 +198,8 @@ ShopWindow::~ShopWindow()
{
saveList();
- delete mBuyShopItems;
- mBuyShopItems = nullptr;
-
- delete mSellShopItems;
- mSellShopItems = nullptr;
+ delete2(mBuyShopItems);
+ delete2(mSellShopItems);
instances.remove(this);
}
diff --git a/src/gui/windows/shortcutwindow.cpp b/src/gui/windows/shortcutwindow.cpp
index 6ec442cd5..8387d7e91 100644
--- a/src/gui/windows/shortcutwindow.cpp
+++ b/src/gui/windows/shortcutwindow.cpp
@@ -30,6 +30,8 @@
#include "gui/widgets/shortcutcontainer.h"
#include "gui/widgets/tabs/tab.h"
+#include "utils/delete2.h"
+
#include "debug.h"
static const int SCROLL_PADDING = 0;
@@ -152,10 +154,8 @@ ShortcutWindow::~ShortcutWindow()
{
if (mTabs)
mTabs->removeAll();
- delete mTabs;
- mTabs = nullptr;
- delete mItems;
- mItems = nullptr;
+ delete2(mTabs);
+ delete2(mItems);
}
void ShortcutWindow::addTab(const std::string &name,
diff --git a/src/gui/windows/skilldialog.cpp b/src/gui/windows/skilldialog.cpp
index ebad47b98..f077341bf 100644
--- a/src/gui/windows/skilldialog.cpp
+++ b/src/gui/windows/skilldialog.cpp
@@ -50,6 +50,7 @@
#include "net/playerhandler.h"
#include "net/skillhandler.h"
+#include "utils/delete2.h"
#include "utils/dtor.h"
#include "utils/gettext.h"
@@ -83,10 +84,8 @@ class SkillListBox final : public ListBox
~SkillListBox()
{
- delete mModel;
- mModel = nullptr;
- delete mPopup;
- mPopup = nullptr;
+ delete2(mModel)
+ delete2(mPopup)
}
SkillInfo *getSelectedInfo() const
@@ -256,8 +255,7 @@ class SkillTab final : public Tab
~SkillTab()
{
- delete mListBox;
- mListBox = nullptr;
+ delete2(mListBox)
}
SkillInfo *getSelectedInfo() const
diff --git a/src/gui/windows/socialwindow.cpp b/src/gui/windows/socialwindow.cpp
index 520184364..3f6fe663d 100644
--- a/src/gui/windows/socialwindow.cpp
+++ b/src/gui/windows/socialwindow.cpp
@@ -57,6 +57,7 @@
#include "net/guildhandler.h"
#include "net/partyhandler.h"
+#include "utils/delete2.h"
#include "utils/gettext.h"
#include "debug.h"
@@ -206,10 +207,8 @@ public:
~SocialGuildTab()
{
- delete mList;
- mList = nullptr;
- delete mScroll;
- mScroll = nullptr;
+ delete2(mList)
+ delete2(mScroll)
}
void action(const ActionEvent &event) override final
@@ -342,10 +341,8 @@ public:
~SocialGuildTab2()
{
- delete mList;
- mList = nullptr;
- delete mScroll;
- mScroll = nullptr;
+ delete2(mList)
+ delete2(mScroll)
}
void action(const ActionEvent &event A_UNUSED) override final
@@ -411,10 +408,8 @@ public:
~SocialPartyTab()
{
- delete mList;
- mList = nullptr;
- delete mScroll;
- mScroll = nullptr;
+ delete2(mList)
+ delete2(mScroll)
}
void action(const ActionEvent &event) override final
@@ -530,12 +525,9 @@ public:
~SocialPlayersTab()
{
- delete mList;
- mList = nullptr;
- delete mScroll;
- mScroll = nullptr;
- delete mBeings;
- mBeings = nullptr;
+ delete2(mList)
+ delete2(mScroll)
+ delete2(mBeings)
}
void updateList() override final
@@ -697,12 +689,9 @@ public:
~SocialNavigationTab()
{
- delete mList;
- mList = nullptr;
- delete mScroll;
- mScroll = nullptr;
- delete mBeings;
- mBeings = nullptr;
+ delete2(mList)
+ delete2(mScroll)
+ delete2(mBeings)
}
void updateList() override final
@@ -1026,12 +1015,9 @@ public:
~SocialAttackTab()
{
- delete mList;
- mList = nullptr;
- delete mScroll;
- mScroll = nullptr;
- delete mBeings;
- mBeings = nullptr;
+ delete2(mList)
+ delete2(mScroll)
+ delete2(mBeings)
}
void updateList() override final
@@ -1073,12 +1059,9 @@ public:
~SocialPickupTab()
{
- delete mList;
- mList = nullptr;
- delete mScroll;
- mScroll = nullptr;
- delete mBeings;
- mBeings = nullptr;
+ delete2(mList)
+ delete2(mScroll)
+ delete2(mBeings)
}
void updateList() override final
@@ -1120,12 +1103,9 @@ public:
~SocialFriendsTab()
{
- delete mList;
- mList = nullptr;
- delete mScroll;
- mScroll = nullptr;
- delete mBeings;
- mBeings = nullptr;
+ delete2(mList)
+ delete2(mScroll)
+ delete2(mBeings)
}
void updateList() override final
@@ -1371,18 +1351,12 @@ SocialWindow::~SocialWindow()
mPartyInviter.clear();
}
- delete mCreatePopup;
- mCreatePopup = nullptr;
- delete mPlayers;
- mPlayers = nullptr;
- delete mNavigation;
- mNavigation = nullptr;
- delete mAttackFilter;
- mAttackFilter = nullptr;
- delete mPickupFilter;
- mPickupFilter = nullptr;
- delete mFriends;
- mFriends = nullptr;
+ delete2(mCreatePopup);
+ delete2(mPlayers);
+ delete2(mNavigation);
+ delete2(mAttackFilter);
+ delete2(mPickupFilter);
+ delete2(mFriends);
}
bool SocialWindow::addTab(Guild *const guild)
diff --git a/src/gui/windows/statuswindow.cpp b/src/gui/windows/statuswindow.cpp
index 7fb4496cc..98d3ea82e 100644
--- a/src/gui/windows/statuswindow.cpp
+++ b/src/gui/windows/statuswindow.cpp
@@ -49,6 +49,7 @@
#include "net/playerhandler.h"
#include "net/gamehandler.h"
+#include "utils/delete2.h"
#include "utils/gettext.h"
#include <SDL_timer.h>
@@ -791,8 +792,7 @@ AttrDisplay::AttrDisplay(const Widget2 *const widget,
AttrDisplay::~AttrDisplay()
{
- delete mLayout;
- mLayout = nullptr;
+ delete2(mLayout);
}
std::string AttrDisplay::update()
diff --git a/src/gui/windows/textcommandeditor.cpp b/src/gui/windows/textcommandeditor.cpp
index dead469bc..2eccb255d 100644
--- a/src/gui/windows/textcommandeditor.cpp
+++ b/src/gui/windows/textcommandeditor.cpp
@@ -38,6 +38,7 @@
#include "gui/widgets/layout.h"
#include "gui/widgets/radiobutton.h"
+#include "utils/delete2.h"
#include "utils/gettext.h"
#include "debug.h"
@@ -191,12 +192,9 @@ void TextCommandEditor::postInit()
TextCommandEditor::~TextCommandEditor()
{
- delete mIconsModel;
- mIconsModel = nullptr;
- delete mTargetTypeModel;
- mTargetTypeModel = nullptr;
- delete mMagicSchoolModel;
- mMagicSchoolModel = nullptr;
+ delete2(mIconsModel);
+ delete2(mTargetTypeModel);
+ delete2(mMagicSchoolModel);
}
void TextCommandEditor::action(const ActionEvent &event)
diff --git a/src/gui/windows/unregisterdialog.cpp b/src/gui/windows/unregisterdialog.cpp
index 3326ca2bb..bb309c6f1 100644
--- a/src/gui/windows/unregisterdialog.cpp
+++ b/src/gui/windows/unregisterdialog.cpp
@@ -35,6 +35,7 @@
#include "net/loginhandler.h"
#include "net/net.h"
+#include "utils/delete2.h"
#include "utils/gettext.h"
#include <string>
@@ -97,8 +98,7 @@ void UnRegisterDialog::postInit()
UnRegisterDialog::~UnRegisterDialog()
{
- delete mWrongDataNoticeListener;
- mWrongDataNoticeListener = nullptr;
+ delete2(mWrongDataNoticeListener);
}
void UnRegisterDialog::action(const ActionEvent &event)
diff --git a/src/gui/windows/updaterwindow.cpp b/src/gui/windows/updaterwindow.cpp
index 70af8e7ea..cd0e7e0d8 100644
--- a/src/gui/windows/updaterwindow.cpp
+++ b/src/gui/windows/updaterwindow.cpp
@@ -42,6 +42,7 @@
#include "resources/db/moddb.h"
+#include "utils/delete2.h"
#include "utils/gettext.h"
#include "utils/mkdir.h"
#include "utils/paths.h"
@@ -242,8 +243,7 @@ UpdaterWindow::~UpdaterWindow()
{
mDownload->cancel();
- delete mDownload;
- mDownload = nullptr;
+ delete2(mDownload)
}
free(mMemoryBuffer);
}
diff --git a/src/gui/windows/worldselectdialog.cpp b/src/gui/windows/worldselectdialog.cpp
index 963da8f22..5cd0a3b2f 100644
--- a/src/gui/windows/worldselectdialog.cpp
+++ b/src/gui/windows/worldselectdialog.cpp
@@ -38,6 +38,7 @@
#include "net/loginhandler.h"
#include "net/net.h"
+#include "utils/delete2.h"
#include "utils/gettext.h"
#include "debug.h"
@@ -95,8 +96,7 @@ void WorldSelectDialog::postInit()
WorldSelectDialog::~WorldSelectDialog()
{
- delete mWorldListModel;
- mWorldListModel = nullptr;
+ delete2(mWorldListModel);
}
void WorldSelectDialog::action(const ActionEvent &event)