mirror of
https://github.com/luanti-org/luanti.git
synced 2025-06-27 16:36:03 +00:00
Fix Android segfault when game exits before TouchScreenGUI is initalized
This commit is contained in:
parent
15445a0fbe
commit
15fb4cab15
2 changed files with 14 additions and 0 deletions
|
@ -563,6 +563,8 @@ void TouchScreenGUI::init(ISimpleTextureSource *tsrc)
|
|||
m_rarecontrolsbar.addButton(chat_id, L"Chat", "chat_btn.png");
|
||||
m_rarecontrolsbar.addButton(inventory_id, L"inv", "inventory_btn.png");
|
||||
m_rarecontrolsbar.addButton(drop_id, L"drop", "drop_btn.png");
|
||||
|
||||
m_initialized = true;
|
||||
}
|
||||
|
||||
touch_gui_button_id TouchScreenGUI::getButtonID(s32 x, s32 y)
|
||||
|
@ -725,6 +727,8 @@ void TouchScreenGUI::handleReleaseEvent(size_t evt_id)
|
|||
|
||||
void TouchScreenGUI::translateEvent(const SEvent &event)
|
||||
{
|
||||
if (!m_initialized)
|
||||
return;
|
||||
if (!m_visible) {
|
||||
infostream
|
||||
<< "TouchScreenGUI::translateEvent got event but not visible!"
|
||||
|
@ -1071,6 +1075,9 @@ void TouchScreenGUI::applyJoystickStatus()
|
|||
|
||||
TouchScreenGUI::~TouchScreenGUI()
|
||||
{
|
||||
if (!m_initialized)
|
||||
return;
|
||||
|
||||
for (auto &button : m_buttons) {
|
||||
if (button.guibutton) {
|
||||
button.guibutton->drop();
|
||||
|
@ -1096,6 +1103,9 @@ TouchScreenGUI::~TouchScreenGUI()
|
|||
|
||||
void TouchScreenGUI::step(float dtime)
|
||||
{
|
||||
if (!m_initialized)
|
||||
return;
|
||||
|
||||
// simulate keyboard repeats
|
||||
for (auto &button : m_buttons) {
|
||||
if (!button.ids.empty()) {
|
||||
|
@ -1180,6 +1190,9 @@ void TouchScreenGUI::registerHudItem(int index, const rect<s32> &rect)
|
|||
|
||||
void TouchScreenGUI::Toggle(bool visible)
|
||||
{
|
||||
if (!m_initialized)
|
||||
return;
|
||||
|
||||
m_visible = visible;
|
||||
for (auto &button : m_buttons) {
|
||||
if (button.guibutton)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue