diff options
-rw-r--r-- | src/gui/viewport.cpp | 19 | ||||
-rw-r--r-- | src/gui/widgets/characterdisplay.cpp | 2 | ||||
-rw-r--r-- | src/gui/widgets/layoutcell.cpp | 4 | ||||
-rw-r--r-- | src/gui/widgets/selldialog.cpp | 10 | ||||
-rw-r--r-- | src/gui/widgets/setupitem.cpp | 9 | ||||
-rw-r--r-- | src/gui/windows/setupwindow.cpp | 3 | ||||
-rw-r--r-- | src/gui/windows/shortcutwindow.cpp | 2 | ||||
-rw-r--r-- | src/gui/windows/socialwindow.cpp | 6 | ||||
-rw-r--r-- | src/gui/windows/textcommandeditor.cpp | 7 | ||||
-rw-r--r-- | src/gui/windows/textdialog.cpp | 10 | ||||
-rw-r--r-- | src/gui/windows/updaterwindow.cpp | 7 | ||||
-rw-r--r-- | src/input/keyboardconfig.cpp | 10 |
12 files changed, 65 insertions, 24 deletions
diff --git a/src/gui/viewport.cpp b/src/gui/viewport.cpp index 1a8231780..e0d5d217f 100644 --- a/src/gui/viewport.cpp +++ b/src/gui/viewport.cpp @@ -491,13 +491,16 @@ bool Viewport::leftMouseAction() } else if (stopAttack) { - const int mouseTileX = (mMouseX + mPixelViewX) - / mMap->getTileWidth(); - const int mouseTileY = (mMouseY + mPixelViewY) - / mMap->getTileHeight(); - inputManager.executeChatCommand(InputAction::PET_MOVE, - strprintf("%d %d", mouseTileX, mouseTileY), - nullptr); + if (mMap) + { + const int mouseTileX = (mMouseX + mPixelViewX) + / mMap->getTileWidth(); + const int mouseTileY = (mMouseY + mPixelViewY) + / mMap->getTileHeight(); + inputManager.executeChatCommand(InputAction::PET_MOVE, + strprintf("%d %d", mouseTileX, mouseTileY), + nullptr); + } return true; } // Just walk around @@ -587,6 +590,8 @@ void Viewport::getMouseTile(int &destX, int &destY) void Viewport::getMouseTile(const int x, const int y, int &destX, int &destY) const { + if (!mMap) + return; const int tw = mMap->getTileWidth(); const int th = mMap->getTileHeight(); destX = CAST_S32(x + mPixelViewX) 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")); diff --git a/src/gui/windows/setupwindow.cpp b/src/gui/windows/setupwindow.cpp index 9deb27f65..29f9cf126 100644 --- a/src/gui/windows/setupwindow.cpp +++ b/src/gui/windows/setupwindow.cpp @@ -207,7 +207,8 @@ void SetupWindow::action(const ActionEvent &event) void SetupWindow::setInGame(const bool inGame) { - mResetWindows->setEnabled(inGame); + if (mResetWindows) + mResetWindows->setEnabled(inGame); } void SetupWindow::externalUpdate() diff --git a/src/gui/windows/shortcutwindow.cpp b/src/gui/windows/shortcutwindow.cpp index 774545cd6..ba3b97b46 100644 --- a/src/gui/windows/shortcutwindow.cpp +++ b/src/gui/windows/shortcutwindow.cpp @@ -167,7 +167,7 @@ void ShortcutWindow::addButton(const std::string &text, void ShortcutWindow::addTab(const std::string &name, ShortcutContainer *const content) { - if (!content) + if (!content || !mTabs) return; ScrollArea *const scroll = new ScrollArea(this, content, false); scroll->setPosition(SCROLL_PADDING, SCROLL_PADDING); diff --git a/src/gui/windows/socialwindow.cpp b/src/gui/windows/socialwindow.cpp index fe8aaacbf..63a88c06f 100644 --- a/src/gui/windows/socialwindow.cpp +++ b/src/gui/windows/socialwindow.cpp @@ -352,6 +352,9 @@ void SocialWindow::action(const ActionEvent &event) if (!serverFeatures->haveNativeGuilds()) return; + if (!mGuildCreateDialog) + return; + std::string name = mGuildCreateDialog->getText(); if (name.size() > 16) @@ -374,6 +377,9 @@ void SocialWindow::action(const ActionEvent &event) } else if (eventId == "create party") { + if (!mPartyCreateDialog) + return; + std::string name = mPartyCreateDialog->getText(); if (name.size() > 24) diff --git a/src/gui/windows/textcommandeditor.cpp b/src/gui/windows/textcommandeditor.cpp index c2a5d66c9..5c59cd389 100644 --- a/src/gui/windows/textcommandeditor.cpp +++ b/src/gui/windows/textcommandeditor.cpp @@ -133,7 +133,8 @@ TextCommandEditor::TextCommandEditor(TextCommand *const command) : mIconDropDown->setActionEventId("icon"); mIconDropDown->addActionListener(this); - mIconDropDown->setSelectedString(mCommand->getIcon()); + if (mCommand) + mIconDropDown->setSelectedString(mCommand->getIcon()); mSaveButton->adjustSize(); mCancelButton->adjustSize(); @@ -291,6 +292,8 @@ void TextCommandEditor::scheduleDelete() void TextCommandEditor::save() { + if (!mCommand) + return; #ifdef TMWA_SUPPORT if (mIsMagicCommand) mCommand->setCommandType(TextCommandType::Magic); @@ -318,6 +321,8 @@ void TextCommandEditor::save() void TextCommandEditor::deleteCommand() { + if (!mCommand) + return; mCommand->setSymbol(""); mCommand->setCommand(""); mCommand->setComment(""); diff --git a/src/gui/windows/textdialog.cpp b/src/gui/windows/textdialog.cpp index 442cd5c67..f72f60d4e 100644 --- a/src/gui/windows/textdialog.cpp +++ b/src/gui/windows/textdialog.cpp @@ -36,6 +36,11 @@ int TextDialog::instances = 0; +namespace +{ + const std::string emptyStr; +} // namespace + TextDialog::TextDialog(const std::string &restrict title, const std::string &restrict msg, Window *const parent, @@ -110,15 +115,16 @@ const std::string &TextDialog::getText() const { if (mTextField) return mTextField->getText(); - else + else if (mPasswordField) return mPasswordField->getText(); + return emptyStr; } void TextDialog::setText(const std::string &text) { if (mTextField) mTextField->setText(text); - else + else if (mPasswordField) mPasswordField->setText(text); } diff --git a/src/gui/windows/updaterwindow.cpp b/src/gui/windows/updaterwindow.cpp index 242e32911..7d2e0c4f8 100644 --- a/src/gui/windows/updaterwindow.cpp +++ b/src/gui/windows/updaterwindow.cpp @@ -312,7 +312,8 @@ void UpdaterWindow::action(const ActionEvent &event) // Skip the updating process if (mDownloadStatus != UPDATE_COMPLETE) { - mDownload->cancel(); + if (mDownload) + mDownload->cancel(); mDownloadStatus = UPDATE_ERROR; } } @@ -846,8 +847,8 @@ void UpdaterWindow::logic() mBrowserBox->addRow(_("##1 It is strongly recommended that")); // TRANSLATORS: Begins "It is strongly recommended that". mBrowserBox->addRow(_("##1 you try again later.")); - - mBrowserBox->addRow(mDownload->getError()); + if (mDownload) + mBrowserBox->addRow(mDownload->getError()); mScrollArea->setVerticalScrollAmount( mScrollArea->getVerticalMaxScroll()); mDownloadStatus = UPDATE_COMPLETE; diff --git a/src/input/keyboardconfig.cpp b/src/input/keyboardconfig.cpp index 2c821807b..81b16ecf2 100644 --- a/src/input/keyboardconfig.cpp +++ b/src/input/keyboardconfig.cpp @@ -184,7 +184,7 @@ InputActionT KeyboardConfig::getActionId(const SDL_Event &event) bool KeyboardConfig::isActionActive(const InputActionT index) const { - if (!mActiveKeys) + if (!mActiveKeys || !mActiveKeys2) return false; const InputFunction &key = inputManager.getKey(index); @@ -217,6 +217,8 @@ void KeyboardConfig::update() void KeyboardConfig::handleActicateKey(const SDL_Event &event) { + if (!mActiveKeys2) + return; const int key = getKeyValueFromEvent(event); if (key < -1 && key > -500) mActiveKeys2[-key] = 1; @@ -225,6 +227,8 @@ void KeyboardConfig::handleActicateKey(const SDL_Event &event) void KeyboardConfig::handleActicateKey(const int key) { + if (!mActiveKeys2) + return; if (key < -1 && key > -500) mActiveKeys2[-key] = 1; resetRepeat(key); @@ -232,6 +236,8 @@ void KeyboardConfig::handleActicateKey(const int key) void KeyboardConfig::handleDeActicateKey(const SDL_Event &event) { + if (!mActiveKeys2) + return; const int key = getKeyValueFromEvent(event); if (key < -1 && key > -500) mActiveKeys2[-key] = 0; @@ -240,6 +246,8 @@ void KeyboardConfig::handleDeActicateKey(const SDL_Event &event) void KeyboardConfig::handleDeActicateKey(const int key) { + if (!mActiveKeys2) + return; if (key < -1 && key > -500) mActiveKeys2[-key] = 0; resetRepeat(key); |