summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2015-06-24 14:55:44 +0300
committerAndrei Karas <akaras@inbox.ru>2015-06-25 20:06:07 +0300
commit9d521a19be347703bfdbb7802d0397a59c3edd7a (patch)
tree9a4e56edc84d5cfd8ebaea17fa19296c51e1e661
parent841fe55e67ea467a8e2192dee5c169d282a35148 (diff)
downloadmv-9d521a19be347703bfdbb7802d0397a59c3edd7a.tar.gz
mv-9d521a19be347703bfdbb7802d0397a59c3edd7a.tar.bz2
mv-9d521a19be347703bfdbb7802d0397a59c3edd7a.tar.xz
mv-9d521a19be347703bfdbb7802d0397a59c3edd7a.zip
Add missing checks in windows.
-rw-r--r--src/client.cpp12
-rw-r--r--src/gui/windows/changeemaildialog.cpp4
-rw-r--r--src/gui/windows/changeemaildialog.h2
-rw-r--r--src/gui/windows/changepassworddialog.cpp4
-rw-r--r--src/gui/windows/changepassworddialog.h2
-rw-r--r--src/gui/windows/charselectdialog.cpp6
-rw-r--r--src/gui/windows/charselectdialog.h2
-rw-r--r--src/gui/windows/equipmentwindow.cpp4
-rw-r--r--src/gui/windows/inventorywindow.cpp6
-rw-r--r--src/gui/windows/itemamountwindow.cpp8
-rw-r--r--src/gui/windows/logindialog.cpp6
-rw-r--r--src/gui/windows/logindialog.h3
-rw-r--r--src/gui/windows/maileditwindow.cpp5
-rw-r--r--src/gui/windows/mailviewwindow.h2
-rw-r--r--src/gui/windows/questswindow.cpp2
-rw-r--r--src/gui/windows/registerdialog.cpp4
-rw-r--r--src/gui/windows/registerdialog.h2
-rw-r--r--src/gui/windows/shortcutwindow.cpp32
-rw-r--r--src/gui/windows/skilldialog.cpp3
-rw-r--r--src/gui/windows/socialwindow.cpp3
-rw-r--r--src/gui/windows/statuswindow.cpp2
-rw-r--r--src/gui/windows/textcommandeditor.cpp34
-rw-r--r--src/gui/windows/tradewindow.cpp3
-rw-r--r--src/gui/windows/unregisterdialog.cpp4
-rw-r--r--src/gui/windows/unregisterdialog.h2
-rw-r--r--src/gui/windows/updaterwindow.cpp12
-rw-r--r--src/gui/windows/whoisonline.cpp4
27 files changed, 115 insertions, 58 deletions
diff --git a/src/client.cpp b/src/client.cpp
index e7aeed7e8..d23ec9586 100644
--- a/src/client.cpp
+++ b/src/client.cpp
@@ -1088,7 +1088,7 @@ int Client::gameExec()
|| settings.options.password.empty())
{
CREATEWIDGETV(mCurrentDialog, LoginDialog,
- &loginData,
+ loginData,
mCurrentServer.hostname,
&settings.options.updateHost);
}
@@ -1296,7 +1296,7 @@ int Client::gameExec()
theme->setMinimumOpacity(0.8F);
CREATEWIDGETV(mCurrentDialog, CharSelectDialog,
- &loginData);
+ loginData);
if (!(static_cast<CharSelectDialog*>(mCurrentDialog))
->selectByName(settings.options.character,
@@ -1434,7 +1434,7 @@ int Client::gameExec()
case STATE_REGISTER:
logger->log1("State: REGISTER");
CREATEWIDGETV(mCurrentDialog, RegisterDialog,
- &loginData);
+ loginData);
break;
case STATE_REGISTER_ATTEMPT:
@@ -1448,7 +1448,7 @@ int Client::gameExec()
BLOCK_START("Client::gameExec STATE_CHANGEPASSWORD")
logger->log1("State: CHANGE PASSWORD");
CREATEWIDGETV(mCurrentDialog, ChangePasswordDialog,
- &loginData);
+ loginData);
mCurrentDialog->setVisible(Visible_true);
BLOCK_END("Client::gameExec STATE_CHANGEPASSWORD")
break;
@@ -1488,7 +1488,7 @@ int Client::gameExec()
case STATE_CHANGEEMAIL:
logger->log1("State: CHANGE EMAIL");
CREATEWIDGETV(mCurrentDialog, ChangeEmailDialog,
- &loginData);
+ loginData);
mCurrentDialog->setVisible(Visible_true);
break;
@@ -1518,7 +1518,7 @@ int Client::gameExec()
case STATE_UNREGISTER:
logger->log1("State: UNREGISTER");
CREATEWIDGETV(mCurrentDialog, UnRegisterDialog,
- &loginData);
+ loginData);
break;
case STATE_UNREGISTER_ATTEMPT:
diff --git a/src/gui/windows/changeemaildialog.cpp b/src/gui/windows/changeemaildialog.cpp
index c5259e33a..1e069e6eb 100644
--- a/src/gui/windows/changeemaildialog.cpp
+++ b/src/gui/windows/changeemaildialog.cpp
@@ -43,7 +43,7 @@
#include "debug.h"
-ChangeEmailDialog::ChangeEmailDialog(LoginData *const data) :
+ChangeEmailDialog::ChangeEmailDialog(LoginData &data) :
// TRANSLATORS: change email dialog header
Window(_("Change Email Address"), Modal_true, nullptr, "changeemail.xml"),
ActionListener(),
@@ -55,7 +55,7 @@ ChangeEmailDialog::ChangeEmailDialog(LoginData *const data) :
// TRANSLATORS: button in change email dialog
mCancelButton(new Button(this, _("Cancel"), "cancel", this)),
mWrongDataNoticeListener(new WrongDataNoticeListener),
- mLoginData(data)
+ mLoginData(&data)
{
// TRANSLATORS: label in change email dialog
Label *const accountLabel = new Label(this, strprintf(_("Account: %s"),
diff --git a/src/gui/windows/changeemaildialog.h b/src/gui/windows/changeemaildialog.h
index b9d87c63a..1ea059972 100644
--- a/src/gui/windows/changeemaildialog.h
+++ b/src/gui/windows/changeemaildialog.h
@@ -46,7 +46,7 @@ class ChangeEmailDialog final : public Window,
*
* @see Window::Window
*/
- explicit ChangeEmailDialog(LoginData *const data);
+ explicit ChangeEmailDialog(LoginData &data);
A_DELETE_COPY(ChangeEmailDialog)
diff --git a/src/gui/windows/changepassworddialog.cpp b/src/gui/windows/changepassworddialog.cpp
index cd2207a9f..051448e6f 100644
--- a/src/gui/windows/changepassworddialog.cpp
+++ b/src/gui/windows/changepassworddialog.cpp
@@ -44,7 +44,7 @@
#include "debug.h"
-ChangePasswordDialog::ChangePasswordDialog(LoginData *const data) :
+ChangePasswordDialog::ChangePasswordDialog(LoginData &data) :
// TRANSLATORS: change password window name
Window(_("Change Password"), Modal_true, nullptr, "changepassword.xml"),
ActionListener(),
@@ -57,7 +57,7 @@ ChangePasswordDialog::ChangePasswordDialog(LoginData *const data) :
// TRANSLATORS: change password dialog button
mCancelButton(new Button(this, _("Cancel"), "cancel", this)),
mWrongDataNoticeListener(new WrongDataNoticeListener),
- mLoginData(data)
+ mLoginData(&data)
{
Label *const accountLabel = new Label(this,
// TRANSLATORS: change password dialog label
diff --git a/src/gui/windows/changepassworddialog.h b/src/gui/windows/changepassworddialog.h
index 58d268ec2..9acdee5c1 100644
--- a/src/gui/windows/changepassworddialog.h
+++ b/src/gui/windows/changepassworddialog.h
@@ -46,7 +46,7 @@ class ChangePasswordDialog final : public Window,
*
* @see Window::Window
*/
- explicit ChangePasswordDialog(LoginData *const data);
+ explicit ChangePasswordDialog(LoginData &data);
A_DELETE_COPY(ChangePasswordDialog)
diff --git a/src/gui/windows/charselectdialog.cpp b/src/gui/windows/charselectdialog.cpp
index 4981410e5..dd0205347 100644
--- a/src/gui/windows/charselectdialog.cpp
+++ b/src/gui/windows/charselectdialog.cpp
@@ -56,16 +56,16 @@
// Character slots per row in the dialog
static const int SLOTS_PER_ROW = 5;
-CharSelectDialog::CharSelectDialog(LoginData *const data) :
+CharSelectDialog::CharSelectDialog(LoginData &data) :
// TRANSLATORS: char select dialog name
Window(strprintf(_("Account %s (last login time %s)"),
- data->username.c_str(), data->lastLogin.c_str()),
+ data.username.c_str(), data.lastLogin.c_str()),
Modal_false,
nullptr,
"char.xml"),
ActionListener(),
KeyListener(),
- mLoginData(data),
+ mLoginData(&data),
// TRANSLATORS: char select dialog. button.
mSwitchLoginButton(new Button(this, _("Switch"), "switch", this)),
// TRANSLATORS: char select dialog. button.
diff --git a/src/gui/windows/charselectdialog.h b/src/gui/windows/charselectdialog.h
index 53d41facb..35e02eb35 100644
--- a/src/gui/windows/charselectdialog.h
+++ b/src/gui/windows/charselectdialog.h
@@ -52,7 +52,7 @@ class CharSelectDialog final : public Window,
/**
* Constructor.
*/
- explicit CharSelectDialog(LoginData *const data);
+ explicit CharSelectDialog(LoginData &data);
A_DELETE_COPY(CharSelectDialog)
diff --git a/src/gui/windows/equipmentwindow.cpp b/src/gui/windows/equipmentwindow.cpp
index 8e7d47f65..ef060ec83 100644
--- a/src/gui/windows/equipmentwindow.cpp
+++ b/src/gui/windows/equipmentwindow.cpp
@@ -672,6 +672,8 @@ void EquipmentWindow::addDefaultPage()
void EquipmentWindow::loadPage(const XmlNodePtr node)
{
+ if (!node)
+ return;
// TRANSLATORS: unknown equipment page name
const std::string &name = XML::langProperty(node, "name", _("Unknown"));
const int page = addPage(name);
@@ -698,6 +700,8 @@ void EquipmentWindow::loadSlot(const XmlNodePtr slotNode,
const ImageSet *const imageset,
const int page)
{
+ if (!imageset)
+ return;
const int slot = parseSlotName(XML::getProperty(slotNode, "name", ""));
if (slot < 0)
return;
diff --git a/src/gui/windows/inventorywindow.cpp b/src/gui/windows/inventorywindow.cpp
index 4c11f1603..a57565d7f 100644
--- a/src/gui/windows/inventorywindow.cpp
+++ b/src/gui/windows/inventorywindow.cpp
@@ -182,6 +182,12 @@ InventoryWindow::InventoryWindow(Inventory *const inventory) :
for (size_t f = 0; f < sz; f ++)
mFilter->addButton(tags[f], tags[f], false);
+ if (!mInventory)
+ {
+ invInstances.push_back(this);
+ return;
+ }
+
switch (mInventory->getType())
{
case InventoryType::INVENTORY:
diff --git a/src/gui/windows/itemamountwindow.cpp b/src/gui/windows/itemamountwindow.cpp
index 07c7d52a1..3a1892f00 100644
--- a/src/gui/windows/itemamountwindow.cpp
+++ b/src/gui/windows/itemamountwindow.cpp
@@ -59,6 +59,8 @@ void ItemAmountWindow::finish(const Item *const item,
const int price,
const Usage usage)
{
+ if (!item)
+ return;
switch (usage)
{
case TradeAdd:
@@ -106,8 +108,10 @@ void ItemAmountWindow::finish(const Item *const item,
}
}
-ItemAmountWindow::ItemAmountWindow(const Usage usage, Window *const parent,
- Item *const item, const int maxRange) :
+ItemAmountWindow::ItemAmountWindow(const Usage usage,
+ Window *const parent,
+ Item *const item,
+ const int maxRange) :
Window("", Modal_false, parent, "amount.xml"),
ActionListener(),
KeyListener(),
diff --git a/src/gui/windows/logindialog.cpp b/src/gui/windows/logindialog.cpp
index c783abed8..47e86471e 100644
--- a/src/gui/windows/logindialog.cpp
+++ b/src/gui/windows/logindialog.cpp
@@ -57,14 +57,14 @@ namespace
OpenUrlListener urlListener;
} // namespace
-LoginDialog::LoginDialog(LoginData *const data,
+LoginDialog::LoginDialog(LoginData &data,
std::string serverName,
std::string *const updateHost) :
// TRANSLATORS: login dialog name
Window(_("Login"), Modal_false, nullptr, "login.xml"),
ActionListener(),
KeyListener(),
- mLoginData(data),
+ mLoginData(&data),
mUserField(new TextField(this, mLoginData->username)),
mPassField(new PasswordField(this, mLoginData->password)),
// TRANSLATORS: login dialog label
@@ -104,7 +104,7 @@ LoginDialog::LoginDialog(LoginData *const data,
Label *const userLabel = new Label(this, _("Name:"));
// TRANSLATORS: login dialog label
Label *const passLabel = new Label(this, _("Password:"));
- if (mLoginData && mLoginData->updateHosts.size() > 1)
+ if (mLoginData->updateHosts.size() > 1)
{
// TRANSLATORS: login dialog label
mUpdateHostLabel = new Label(this, strprintf(_("Update host: %s"),
diff --git a/src/gui/windows/logindialog.h b/src/gui/windows/logindialog.h
index 6e53304ce..0870ab79e 100644
--- a/src/gui/windows/logindialog.h
+++ b/src/gui/windows/logindialog.h
@@ -52,7 +52,8 @@ class LoginDialog final : public Window,
*
* @see Window::Window
*/
- LoginDialog(LoginData *const data, std::string serverName,
+ LoginDialog(LoginData &data,
+ std::string serverName,
std::string *const updateHost);
A_DELETE_COPY(LoginDialog)
diff --git a/src/gui/windows/maileditwindow.cpp b/src/gui/windows/maileditwindow.cpp
index 74b214eb2..12ab097c0 100644
--- a/src/gui/windows/maileditwindow.cpp
+++ b/src/gui/windows/maileditwindow.cpp
@@ -160,8 +160,11 @@ void MailEditWindow::action(const ActionEvent &event)
}
}
-void MailEditWindow::addItem(const Item *const item, const int amount)
+void MailEditWindow::addItem(const Item *const item,
+ const int amount)
{
+ if (!item)
+ return;
mInventory->addItem(item->getId(),
item->getType(),
amount,
diff --git a/src/gui/windows/mailviewwindow.h b/src/gui/windows/mailviewwindow.h
index 70fcd35a8..c344d1c82 100644
--- a/src/gui/windows/mailviewwindow.h
+++ b/src/gui/windows/mailviewwindow.h
@@ -37,7 +37,7 @@ class MailViewWindow final : public Window,
public ActionListener
{
public:
- explicit MailViewWindow(const MailMessage *const message);
+ explicit MailViewWindow(const MailMessage *const message) A_NONNULL(2);
A_DELETE_COPY(MailViewWindow)
diff --git a/src/gui/windows/questswindow.cpp b/src/gui/windows/questswindow.cpp
index 144f9b3d0..24b11d308 100644
--- a/src/gui/windows/questswindow.cpp
+++ b/src/gui/windows/questswindow.cpp
@@ -197,6 +197,8 @@ void QuestsWindow::loadXmlFile(const std::string &fileName)
void QuestsWindow::loadQuest(const int var, const XmlNodePtr node)
{
+ if (!node)
+ return;
QuestItem *const quest = new QuestItem();
// TRANSLATORS: quests window quest name
quest->name = XML::langProperty(node, "name", _("unknown"));
diff --git a/src/gui/windows/registerdialog.cpp b/src/gui/windows/registerdialog.cpp
index 5d836f891..7a52a6129 100644
--- a/src/gui/windows/registerdialog.cpp
+++ b/src/gui/windows/registerdialog.cpp
@@ -46,12 +46,12 @@
#include "debug.h"
-RegisterDialog::RegisterDialog(LoginData *const data) :
+RegisterDialog::RegisterDialog(LoginData &data) :
// TRANSLATORS: register dialog name
Window(_("Register"), Modal_false, nullptr, "register.xml"),
ActionListener(),
KeyListener(),
- mLoginData(data),
+ mLoginData(&data),
mUserField(new TextField(this, mLoginData->username)),
mPasswordField(new PasswordField(this, mLoginData->password)),
mConfirmField(new PasswordField(this)),
diff --git a/src/gui/windows/registerdialog.h b/src/gui/windows/registerdialog.h
index 0adf45b74..f01d1ca45 100644
--- a/src/gui/windows/registerdialog.h
+++ b/src/gui/windows/registerdialog.h
@@ -50,7 +50,7 @@ class RegisterDialog final : public Window,
*
* @see Window::Window
*/
- explicit RegisterDialog(LoginData *const loginData);
+ explicit RegisterDialog(LoginData &loginData);
A_DELETE_COPY(RegisterDialog)
diff --git a/src/gui/windows/shortcutwindow.cpp b/src/gui/windows/shortcutwindow.cpp
index 87c539089..df9aced4c 100644
--- a/src/gui/windows/shortcutwindow.cpp
+++ b/src/gui/windows/shortcutwindow.cpp
@@ -68,27 +68,31 @@ ShortcutWindow::ShortcutWindow(const std::string &restrict title,
mDragOffsetX = 0;
mDragOffsetY = 0;
- content->setWidget2(this);
+ if (content)
+ content->setWidget2(this);
if (setupWindow)
setupWindow->registerWindowForReset(this);
- const int border = SCROLL_PADDING * 2 + getPadding() * 2;
- const int bw = mItems->getBoxWidth();
- const int bh = mItems->getBoxHeight();
- const int maxItems = mItems->getMaxItems();
setMinWidth(32);
setMinHeight(32);
- setMaxWidth(bw * maxItems + border);
- setMaxHeight(bh * maxItems + border);
+ const int border = SCROLL_PADDING * 2 + getPadding() * 2;
+ if (mItems)
+ {
+ const int bw = mItems->getBoxWidth();
+ const int bh = mItems->getBoxHeight();
+ const int maxItems = mItems->getMaxItems();
+ setMaxWidth(bw * maxItems + border);
+ setMaxHeight(bh * maxItems + border);
- if (width == 0)
- width = bw + border;
- if (height == 0)
- height = bh * maxItems + border;
+ if (width == 0)
+ width = bw + border;
+ if (height == 0)
+ height = bh * maxItems + border;
- setDefaultSize(width, height, ImageRect::LOWER_RIGHT);
+ setDefaultSize(width, height, ImageRect::LOWER_RIGHT);
- mBoxesWidth += bw + border;
+ mBoxesWidth += bw + border;
+ }
mScrollArea->setPosition(SCROLL_PADDING, SCROLL_PADDING);
mScrollArea->setHorizontalScrollPolicy(ScrollArea::SHOW_NEVER);
@@ -161,6 +165,8 @@ void ShortcutWindow::addButton(const std::string &text,
void ShortcutWindow::addTab(const std::string &name,
ShortcutContainer *const content)
{
+ if (!content)
+ return;
ScrollArea *const scroll = new ScrollArea(this, content, false);
scroll->setPosition(SCROLL_PADDING, SCROLL_PADDING);
scroll->setHorizontalScrollPolicy(ScrollArea::SHOW_NEVER);
diff --git a/src/gui/windows/skilldialog.cpp b/src/gui/windows/skilldialog.cpp
index 7f2d81740..8997220f1 100644
--- a/src/gui/windows/skilldialog.cpp
+++ b/src/gui/windows/skilldialog.cpp
@@ -703,6 +703,9 @@ void SkillDialog::useSkill(const SkillInfo *const info)
void SkillDialog::addSkillDuration(SkillInfo *const skill)
{
+ if (!skill)
+ return;
+
FOR_EACH (std::vector<SkillInfo*>::const_iterator, it, mDurations)
{
if ((*it)->id == skill->id)
diff --git a/src/gui/windows/socialwindow.cpp b/src/gui/windows/socialwindow.cpp
index f9827c35a..2353f98e8 100644
--- a/src/gui/windows/socialwindow.cpp
+++ b/src/gui/windows/socialwindow.cpp
@@ -183,6 +183,9 @@ SocialWindow::~SocialWindow()
bool SocialWindow::addTab(Guild *const guild)
{
+ if (!guild)
+ return false;
+
if (mGuilds.find(guild) != mGuilds.end())
return false;
diff --git a/src/gui/windows/statuswindow.cpp b/src/gui/windows/statuswindow.cpp
index 57f7d6f1e..ed7438736 100644
--- a/src/gui/windows/statuswindow.cpp
+++ b/src/gui/windows/statuswindow.cpp
@@ -652,6 +652,8 @@ std::string StatusWindow::translateLetter2(const std::string &letters)
void StatusWindow::updateStatusBar(ProgressBar *const bar,
const bool percent A_UNUSED) const
{
+ if (!bar)
+ return;
bar->setText(translateLetter2(GameModifiers::getMoveTypeString())
.append(translateLetter2(GameModifiers::getCrazyMoveTypeString()))
.append(translateLetter2(GameModifiers::getMoveToTargetTypeString()))
diff --git a/src/gui/windows/textcommandeditor.cpp b/src/gui/windows/textcommandeditor.cpp
index fdffe0e75..4269508aa 100644
--- a/src/gui/windows/textcommandeditor.cpp
+++ b/src/gui/windows/textcommandeditor.cpp
@@ -46,7 +46,8 @@ TextCommandEditor::TextCommandEditor(TextCommand *const command) :
// TRANSLATORS: command editor name
Window(_("Command Editor"), Modal_false, nullptr, "commandeditor.xml"),
ActionListener(),
- mIsMagicCommand(command->getCommandType() == TEXT_COMMAND_MAGIC),
+ mIsMagicCommand(command ?
+ (command->getCommandType() == TEXT_COMMAND_MAGIC) : false),
mCommand(command),
// TRANSLATORS: command editor button
mIsMagic(new RadioButton(this, _("magic"), "magic", mIsMagicCommand)),
@@ -128,20 +129,23 @@ TextCommandEditor::TextCommandEditor(TextCommand *const command) :
mCancelButton->adjustSize();
mDeleteButton->adjustSize();
- if (command->getCommandType() == TEXT_COMMAND_MAGIC)
- showControls(Visible_true);
- else
- showControls(Visible_false);
-
- mSymbolTextField->setText(command->getSymbol());
- mCommandTextField->setText(command->getCommand());
- mCommentTextField->setText(command->getComment());
- mManaField->setValue(command->getMana());
- mTypeDropDown->setSelected(static_cast<int>(command->getTargetType()));
- mMagicLvlField->setValue(command->getBaseLvl());
- mSchoolDropDown->setSelected(static_cast<int>(command->getSchool())
- - MAGIC_START_ID);
- mSchoolLvlField->setValue(command->getSchoolLvl());
+ if (command)
+ {
+ if (command->getCommandType() == TEXT_COMMAND_MAGIC)
+ showControls(Visible_true);
+ else
+ showControls(Visible_false);
+
+ mSymbolTextField->setText(command->getSymbol());
+ mCommandTextField->setText(command->getCommand());
+ mCommentTextField->setText(command->getComment());
+ mManaField->setValue(command->getMana());
+ mTypeDropDown->setSelected(static_cast<int>(command->getTargetType()));
+ mMagicLvlField->setValue(command->getBaseLvl());
+ mSchoolDropDown->setSelected(static_cast<int>(command->getSchool())
+ - MAGIC_START_ID);
+ mSchoolLvlField->setValue(command->getSchoolLvl());
+ }
ContainerPlacer placer;
placer = getPlacer(0, 0);
diff --git a/src/gui/windows/tradewindow.cpp b/src/gui/windows/tradewindow.cpp
index 7d1173856..bf4963daf 100644
--- a/src/gui/windows/tradewindow.cpp
+++ b/src/gui/windows/tradewindow.cpp
@@ -496,6 +496,9 @@ void TradeWindow::initTrade(const std::string &nick)
bool TradeWindow::checkItem(const Item *const item) const
{
+ if (!item)
+ return false;
+
const int itemId = item->getId();
if (PlayerInfo::isItemProtected(itemId))
return false;
diff --git a/src/gui/windows/unregisterdialog.cpp b/src/gui/windows/unregisterdialog.cpp
index c789de720..80a02a952 100644
--- a/src/gui/windows/unregisterdialog.cpp
+++ b/src/gui/windows/unregisterdialog.cpp
@@ -43,11 +43,11 @@
#include "debug.h"
-UnRegisterDialog::UnRegisterDialog(LoginData *const data) :
+UnRegisterDialog::UnRegisterDialog(LoginData &data) :
// TRANSLATORS: unregister dialog name
Window(_("Unregister"), Modal_true, nullptr, "unregister.xml"),
ActionListener(),
- mLoginData(data),
+ mLoginData(&data),
mPasswordField(new PasswordField(this, mLoginData->password)),
// TRANSLATORS: unregister dialog. button.
mUnRegisterButton(new Button(this, _("Unregister"), "unregister", this)),
diff --git a/src/gui/windows/unregisterdialog.h b/src/gui/windows/unregisterdialog.h
index 5f26348e6..db1937e1a 100644
--- a/src/gui/windows/unregisterdialog.h
+++ b/src/gui/windows/unregisterdialog.h
@@ -46,7 +46,7 @@ class UnRegisterDialog final : public Window,
*
* @see Window::Window
*/
- explicit UnRegisterDialog(LoginData *const loginData);
+ explicit UnRegisterDialog(LoginData &loginData);
A_DELETE_COPY(UnRegisterDialog)
diff --git a/src/gui/windows/updaterwindow.cpp b/src/gui/windows/updaterwindow.cpp
index 1ef2b7e2c..e221b73b9 100644
--- a/src/gui/windows/updaterwindow.cpp
+++ b/src/gui/windows/updaterwindow.cpp
@@ -541,6 +541,8 @@ size_t UpdaterWindow::memoryWrite(void *ptr, size_t size,
{
UpdaterWindow *const uw = reinterpret_cast<UpdaterWindow *>(stream);
const size_t totalMem = size * nmemb;
+ if (!uw)
+ return 0;
uw->mMemoryBuffer = static_cast<char*>(realloc(uw->mMemoryBuffer,
static_cast<size_t>(uw->mDownloadedBytes) + totalMem));
if (uw->mMemoryBuffer)
@@ -712,6 +714,8 @@ void UpdaterWindow::unloadUpdates(const std::string &dir)
void UpdaterWindow::loadManaPlusUpdates(const std::string &dir,
const ResourceManager *const resman)
{
+ if (!resman)
+ return;
std::string fixPath = dir + "/fix";
std::vector<UpdateFile> updateFiles = loadXMLFile(
std::string(fixPath).append("/").append(xmlUpdateFile), false);
@@ -737,6 +741,8 @@ void UpdaterWindow::loadManaPlusUpdates(const std::string &dir,
void UpdaterWindow::unloadManaPlusUpdates(const std::string &dir,
const ResourceManager *const resman)
{
+ if (!resman)
+ return;
const std::string fixPath = dir + "/fix";
const std::vector<UpdateFile> updateFiles = loadXMLFile(
std::string(fixPath).append("/").append(xmlUpdateFile), true);
@@ -762,6 +768,8 @@ void UpdaterWindow::addUpdateFile(const ResourceManager *const resman,
const std::string &restrict file,
const bool append)
{
+ if (!resman)
+ return;
const std::string tmpPath = std::string(path).append("/").append(file);
if (!append)
resman->addToSearchPath(tmpPath, append);
@@ -780,6 +788,8 @@ void UpdaterWindow::removeUpdateFile(const ResourceManager *const resman,
const std::string &restrict fixPath,
const std::string &restrict file)
{
+ if (!resman)
+ return;
resman->removeFromSearchPath(std::string(path).append("/").append(file));
const std::string fixFile = std::string(fixPath).append("/").append(file);
struct stat statbuf;
@@ -1070,6 +1080,8 @@ void UpdaterWindow::loadMods(const std::string &dir,
const ResourceManager *const resman,
const std::vector<UpdateFile> &updateFiles)
{
+ if (!resman)
+ return;
ModDB::load();
std::string modsString = serverConfig.getValue("mods", "");
std::set<std::string> modsList;
diff --git a/src/gui/windows/whoisonline.cpp b/src/gui/windows/whoisonline.cpp
index 9ff00cd34..65096f3e0 100644
--- a/src/gui/windows/whoisonline.cpp
+++ b/src/gui/windows/whoisonline.cpp
@@ -278,6 +278,8 @@ void WhoIsOnline::updateWindow(size_t numOnline)
void WhoIsOnline::handlerPlayerRelation(const std::string &nick,
OnlinePlayer *const player)
{
+ if (!player)
+ return;
switch (player_relations.getRelation(nick))
{
case Relation::NEUTRAL:
@@ -509,6 +511,8 @@ int WhoIsOnline::downloadThread(void *ptr)
{
int attempts = 0;
WhoIsOnline *const wio = reinterpret_cast<WhoIsOnline *>(ptr);
+ if (!wio)
+ return 0;
CURLcode res;
const std::string url(settings.onlineListUrl + "/online.txt");