summaryrefslogtreecommitdiff
path: root/src/gui
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/login.cpp3
-rw-r--r--src/gui/minimap.cpp4
-rw-r--r--src/gui/serverdialog.cpp18
-rw-r--r--src/gui/setup_players.cpp16
-rw-r--r--src/gui/setup_video.cpp1
-rw-r--r--src/gui/skilldialog.cpp6
-rw-r--r--src/gui/socialwindow.cpp19
-rw-r--r--src/gui/statuswindow.cpp7
-rw-r--r--src/gui/theme.cpp1
-rw-r--r--src/gui/truetypefont.cpp12
10 files changed, 64 insertions, 23 deletions
diff --git a/src/gui/login.cpp b/src/gui/login.cpp
index bfad5c32..b243fd04 100644
--- a/src/gui/login.cpp
+++ b/src/gui/login.cpp
@@ -91,7 +91,8 @@ LoginDialog::LoginDialog(LoginData *loginData):
mPassField->requestFocus();
mLoginButton->setEnabled(canSubmit());
- mRegisterButton->setEnabled(Net::getLoginHandler()->isRegistrationEnabled());
+ mRegisterButton->setEnabled(Net::getLoginHandler()
+ ->isRegistrationEnabled());
}
LoginDialog::~LoginDialog()
diff --git a/src/gui/minimap.cpp b/src/gui/minimap.cpp
index e973fa54..1d01f48c 100644
--- a/src/gui/minimap.cpp
+++ b/src/gui/minimap.cpp
@@ -97,15 +97,13 @@ void Minimap::setMap(Map *map)
if (map)
{
std::string tempname =
- "graphics/minimaps/"+(*map->getFilename())+".png";
+ "graphics/minimaps/" + map->getFilename() + ".png";
ResourceManager *resman = ResourceManager::getInstance();
minimapName = map->getProperty("minimap");
if (minimapName.empty() && resman->exists(tempname))
- {
minimapName = tempname;
- }
mMapImage = resman->getImage(minimapName);
}
diff --git a/src/gui/serverdialog.cpp b/src/gui/serverdialog.cpp
index 25725a80..ad8ab3c8 100644
--- a/src/gui/serverdialog.cpp
+++ b/src/gui/serverdialog.cpp
@@ -26,6 +26,7 @@
#include "configuration.h"
#include "gui.h"
#include "log.h"
+#include "main.h"
#include "gui/okdialog.h"
#include "gui/sdlinput.h"
@@ -527,6 +528,15 @@ void ServerDialog::loadServers()
std::string type = XML::getProperty(serverNode, "type", "unknown");
server.type = ServerInfo::parseType(type);
+
+ // Ignore unknown server types
+ if (server.type == ServerInfo::UNKNOWN)
+ {
+ logger->log("Ignoring server entry with unknown type: %s",
+ type.c_str());
+ continue;
+ }
+
server.name = XML::getProperty(serverNode, "name", std::string());
std::string version = XML::getProperty(serverNode, "minimumVersion",
@@ -538,15 +548,11 @@ void ServerDialog::loadServers()
// For display in the list
if (meetsMinimumVersion)
version.clear();
+ else if (version.empty())
+ version = _("requires a newer version");
else
version = strprintf(_("requires v%s"), version.c_str());
- if (server.type == ServerInfo::UNKNOWN)
- {
- logger->log("Unknown server type: %s", type.c_str());
- continue;
- }
-
for_each_xml_child_node(subNode, serverNode)
{
if (xmlStrEqual(subNode->name, BAD_CAST "connection"))
diff --git a/src/gui/setup_players.cpp b/src/gui/setup_players.cpp
index 15cc787a..f7a39240 100644
--- a/src/gui/setup_players.cpp
+++ b/src/gui/setup_players.cpp
@@ -35,6 +35,7 @@
#include "gui/widgets/scrollarea.h"
#include "gui/widgets/table.h"
+#include "utils/dtor.h"
#include "utils/gettext.h"
#include <string>
@@ -88,7 +89,8 @@ class PlayerTableModel : public TableModel
{
public:
PlayerTableModel() :
- mPlayers(NULL)
+ mPlayers(NULL),
+ mListModel(new PlayerRelationListModel)
{
playerRelationsUpdated();
}
@@ -96,6 +98,7 @@ public:
virtual ~PlayerTableModel()
{
freeWidgets();
+ delete mListModel;
if (mPlayers)
delete mPlayers;
}
@@ -139,9 +142,8 @@ public:
std::string name = (*player_names)[r];
gcn::Widget *widget = new Label(name);
mWidgets.push_back(widget);
- gcn::ListModel *playerRelation = new PlayerRelationListModel;
- gcn::DropDown *choicebox = new DropDown(playerRelation);
+ gcn::DropDown *choicebox = new DropDown(mListModel);
choicebox->setSelected(player_relations.getRelation(name));
mWidgets.push_back(choicebox);
}
@@ -170,12 +172,7 @@ public:
delete mPlayers;
mPlayers = NULL;
- for (std::vector<gcn::Widget *>::const_iterator it = mWidgets.begin();
- it != mWidgets.end(); it++)
- {
- delete *it;
- }
-
+ delete_all(mWidgets);
mWidgets.clear();
}
@@ -187,6 +184,7 @@ public:
protected:
std::vector<std::string> *mPlayers;
std::vector<gcn::Widget *> mWidgets;
+ PlayerRelationListModel *mListModel;
};
/**
diff --git a/src/gui/setup_video.cpp b/src/gui/setup_video.cpp
index ebe53261..81ce8107 100644
--- a/src/gui/setup_video.cpp
+++ b/src/gui/setup_video.cpp
@@ -380,6 +380,7 @@ Setup_Video::Setup_Video():
Setup_Video::~Setup_Video()
{
delete mModeListModel;
+ delete mModeList;
delete mFontSizeListModel;
}
diff --git a/src/gui/skilldialog.cpp b/src/gui/skilldialog.cpp
index 1a265589..683a6d43 100644
--- a/src/gui/skilldialog.cpp
+++ b/src/gui/skilldialog.cpp
@@ -185,6 +185,12 @@ public:
setCaption(name);
}
+ ~SkillTab()
+ {
+ delete mListBox;
+ mListBox = 0;
+ }
+
SkillInfo *getSelectedInfo()
{
return mListBox->getSelectedInfo();
diff --git a/src/gui/socialwindow.cpp b/src/gui/socialwindow.cpp
index 2043da52..25447f30 100644
--- a/src/gui/socialwindow.cpp
+++ b/src/gui/socialwindow.cpp
@@ -61,7 +61,7 @@ protected:
mConfirmDialog(NULL)
{}
- ~SocialTab()
+ virtual ~SocialTab()
{
// Cleanup dialogs
if (mInviteDialog)
@@ -106,6 +106,14 @@ public:
mScroll->setVerticalScrollPolicy(gcn::ScrollArea::SHOW_ALWAYS);
}
+ ~GuildTab()
+ {
+ delete mList;
+ mList = 0;
+ delete mScroll;
+ mScroll = 0;
+ }
+
void action(const gcn::ActionEvent &event)
{
if (event.getId() == "do invite")
@@ -179,6 +187,14 @@ public:
mScroll->setVerticalScrollPolicy(gcn::ScrollArea::SHOW_ALWAYS);
}
+ ~PartyTab()
+ {
+ delete mList;
+ mList = 0;
+ delete mScroll;
+ mScroll = 0;
+ }
+
void action(const gcn::ActionEvent &event)
{
if (event.getId() == "do invite")
@@ -350,6 +366,7 @@ SocialWindow::~SocialWindow()
mPartyInviter = "";
}
+ delete mCreatePopup;
}
bool SocialWindow::addTab(Guild *guild)
diff --git a/src/gui/statuswindow.cpp b/src/gui/statuswindow.cpp
index ad9c0ed7..c8ebdc98 100644
--- a/src/gui/statuswindow.cpp
+++ b/src/gui/statuswindow.cpp
@@ -51,6 +51,8 @@ class AttrDisplay : public Container
DERIVED, CHANGEABLE, UNKNOWN
};
+ ~AttrDisplay();
+
virtual std::string update();
virtual Type getType() { return UNKNOWN; }
@@ -404,6 +406,11 @@ AttrDisplay::AttrDisplay(int id, const std::string &name):
mLayout = new LayoutHelper(this);
}
+AttrDisplay::~AttrDisplay()
+{
+ delete mLayout;
+}
+
std::string AttrDisplay::update()
{
int base = player_node->getAttributeBase(mId);
diff --git a/src/gui/theme.cpp b/src/gui/theme.cpp
index 1406a0d0..e46616e0 100644
--- a/src/gui/theme.cpp
+++ b/src/gui/theme.cpp
@@ -228,6 +228,7 @@ Skin *Theme::readSkin(const std::string &filename)
Image *dBorders = Theme::getImageFromTheme(skinSetImage);
ImageRect border;
+ memset(&border, 0, sizeof(ImageRect));
// iterate <widget>'s
for_each_xml_child_node(widgetNode, rootNode)
diff --git a/src/gui/truetypefont.cpp b/src/gui/truetypefont.cpp
index 3bf1febe..e2ae5b93 100644
--- a/src/gui/truetypefont.cpp
+++ b/src/gui/truetypefont.cpp
@@ -26,9 +26,11 @@
#include "resources/image.h"
+#include "utils/stringutils.h"
+
#include <guichan/exception.hpp>
-#define CACHE_SIZE 256
+const unsigned int CACHE_SIZE = 256;
class TextChunk
{
@@ -55,8 +57,10 @@ class TextChunk
sdlCol.r = color.r;
sdlCol.g = color.g;
+ const char* str = getSafeUtf8String(text);
SDL_Surface *surface = TTF_RenderUTF8_Blended(
- font, text.c_str(), sdlCol);
+ font, str, sdlCol);
+ delete[] str;
if (!surface)
{
@@ -175,7 +179,9 @@ int TrueTypeFont::getWidth(const std::string &text) const
}
int w, h;
- TTF_SizeUTF8(mFont, text.c_str(), &w, &h);
+ const char* str = getSafeUtf8String(text);
+ TTF_SizeUTF8(mFont, str, &w, &h);
+ delete[] str;
return w;
}