From ff10b54405fe8980a022e98cd79d912c1f0ac353 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sun, 21 Feb 2016 02:12:14 +0300 Subject: Add missing checks. --- src/gui/widgets/characterdisplay.cpp | 2 +- src/gui/widgets/layoutcell.cpp | 4 ++++ src/gui/widgets/selldialog.cpp | 10 +++++++--- src/gui/widgets/setupitem.cpp | 9 +++++---- 4 files changed, 17 insertions(+), 8 deletions(-) (limited to 'src/gui/widgets') diff --git a/src/gui/widgets/characterdisplay.cpp b/src/gui/widgets/characterdisplay.cpp index 7aed3469c..560e1cb54 100644 --- a/src/gui/widgets/characterdisplay.cpp +++ b/src/gui/widgets/characterdisplay.cpp @@ -121,7 +121,7 @@ void CharacterDisplay::mouseExited(MouseEvent &event A_UNUSED) void CharacterDisplay::mouseMoved(MouseEvent &event A_UNUSED) { - if (!gui || !textPopup) + if (!gui || !textPopup || !mCharacter) return; int mouseX = 0; diff --git a/src/gui/widgets/layoutcell.cpp b/src/gui/widgets/layoutcell.cpp index 2ab016ca4..1e46c1ca7 100644 --- a/src/gui/widgets/layoutcell.cpp +++ b/src/gui/widgets/layoutcell.cpp @@ -43,7 +43,11 @@ LayoutArray &LayoutCell::getArray() if (mType == WIDGET) return tempArray; if (mType == ARRAY) + { + if (!mArray) + return tempArray; return *mArray; + } mArray = new LayoutArray; mType = ARRAY; diff --git a/src/gui/widgets/selldialog.cpp b/src/gui/widgets/selldialog.cpp index 189babc89..17664ed78 100644 --- a/src/gui/widgets/selldialog.cpp +++ b/src/gui/widgets/selldialog.cpp @@ -199,7 +199,8 @@ SellDialog::~SellDialog() void SellDialog::reset() { mShopItems->clear(); - mSlider->setValue(0); + if (mSlider) + mSlider->setValue(0); mShopItemList->setSelected(-1); updateButtonsAndLabels(); } @@ -256,8 +257,11 @@ void SellDialog::action(const ActionEvent &event) if (eventId == "slider") { - mAmountItems = CAST_S32(mSlider->getValue()); - updateButtonsAndLabels(); + if (mSlider) + { + mAmountItems = CAST_S32(mSlider->getValue()); + updateButtonsAndLabels(); + } } else if (eventId == "inc" && mSlider && mAmountItems < mMaxItems) { diff --git a/src/gui/widgets/setupitem.cpp b/src/gui/widgets/setupitem.cpp index be9f2000f..511ab90ab 100644 --- a/src/gui/widgets/setupitem.cpp +++ b/src/gui/widgets/setupitem.cpp @@ -406,7 +406,7 @@ void SetupItemTextField::action(const ActionEvent &event) return; const std::string &eventId = event.getId(); - if (eventId == mWidget->getActionEventId()) + if (mWidget && eventId == mWidget->getActionEventId()) { fromWidget(); } @@ -544,7 +544,7 @@ void SetupItemIntTextField::action(const ActionEvent &event) return; const std::string &eventId = event.getId(); - if (eventId == mWidget->getActionEventId()) + if (mWidget && eventId == mWidget->getActionEventId()) { fromWidget(); } @@ -1153,14 +1153,15 @@ void SetupItemSound::addMoreControls() { mButton = new Button(this, BUTTON_PLAY, 16, 16, mEventName + "_PLAY", this); - mHorizont->add(mButton); + if (mHorizont) + mHorizont->add(mButton); } void SetupItemSound::action(const ActionEvent &event) { if (event.getId() == mEventName + "_PLAY") { - if (mSlider->getSelected()) + if (mSlider && mSlider->getSelected()) { soundManager.playGuiSfx(branding.getStringValue("systemsounds") .append(mSlider->getSelectedString()).append(".ogg")); -- cgit v1.2.3-70-g09d2