mirror of
https://github.com/minetest/minetest.git
synced 2024-11-23 08:03:45 +01:00
Fix Android segfault when game exits before TouchScreenGUI is initalized
This commit is contained in:
parent
15445a0fbe
commit
15fb4cab15
@ -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)
|
||||
|
@ -201,6 +201,7 @@ public:
|
||||
void show();
|
||||
|
||||
private:
|
||||
bool m_initialized = false;
|
||||
IrrlichtDevice *m_device;
|
||||
IGUIEnvironment *m_guienv;
|
||||
IEventReceiver *m_receiver;
|
||||
|
Loading…
Reference in New Issue
Block a user