summaryrefslogtreecommitdiff
path: root/src/gui/windows/textcommandeditor.cpp
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 /src/gui/windows/textcommandeditor.cpp
parent841fe55e67ea467a8e2192dee5c169d282a35148 (diff)
downloadmanaverse-9d521a19be347703bfdbb7802d0397a59c3edd7a.tar.gz
manaverse-9d521a19be347703bfdbb7802d0397a59c3edd7a.tar.bz2
manaverse-9d521a19be347703bfdbb7802d0397a59c3edd7a.tar.xz
manaverse-9d521a19be347703bfdbb7802d0397a59c3edd7a.zip
Add missing checks in windows.
Diffstat (limited to 'src/gui/windows/textcommandeditor.cpp')
-rw-r--r--src/gui/windows/textcommandeditor.cpp34
1 files changed, 19 insertions, 15 deletions
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);