forked from Mirrorlandia_minetest/minetest
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(chat_id, L"Chat", "chat_btn.png");
|
||||||
m_rarecontrolsbar.addButton(inventory_id, L"inv", "inventory_btn.png");
|
m_rarecontrolsbar.addButton(inventory_id, L"inv", "inventory_btn.png");
|
||||||
m_rarecontrolsbar.addButton(drop_id, L"drop", "drop_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)
|
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)
|
void TouchScreenGUI::translateEvent(const SEvent &event)
|
||||||
{
|
{
|
||||||
|
if (!m_initialized)
|
||||||
|
return;
|
||||||
if (!m_visible) {
|
if (!m_visible) {
|
||||||
infostream
|
infostream
|
||||||
<< "TouchScreenGUI::translateEvent got event but not visible!"
|
<< "TouchScreenGUI::translateEvent got event but not visible!"
|
||||||
@ -1071,6 +1075,9 @@ void TouchScreenGUI::applyJoystickStatus()
|
|||||||
|
|
||||||
TouchScreenGUI::~TouchScreenGUI()
|
TouchScreenGUI::~TouchScreenGUI()
|
||||||
{
|
{
|
||||||
|
if (!m_initialized)
|
||||||
|
return;
|
||||||
|
|
||||||
for (auto &button : m_buttons) {
|
for (auto &button : m_buttons) {
|
||||||
if (button.guibutton) {
|
if (button.guibutton) {
|
||||||
button.guibutton->drop();
|
button.guibutton->drop();
|
||||||
@ -1096,6 +1103,9 @@ TouchScreenGUI::~TouchScreenGUI()
|
|||||||
|
|
||||||
void TouchScreenGUI::step(float dtime)
|
void TouchScreenGUI::step(float dtime)
|
||||||
{
|
{
|
||||||
|
if (!m_initialized)
|
||||||
|
return;
|
||||||
|
|
||||||
// simulate keyboard repeats
|
// simulate keyboard repeats
|
||||||
for (auto &button : m_buttons) {
|
for (auto &button : m_buttons) {
|
||||||
if (!button.ids.empty()) {
|
if (!button.ids.empty()) {
|
||||||
@ -1180,6 +1190,9 @@ void TouchScreenGUI::registerHudItem(int index, const rect<s32> &rect)
|
|||||||
|
|
||||||
void TouchScreenGUI::Toggle(bool visible)
|
void TouchScreenGUI::Toggle(bool visible)
|
||||||
{
|
{
|
||||||
|
if (!m_initialized)
|
||||||
|
return;
|
||||||
|
|
||||||
m_visible = visible;
|
m_visible = visible;
|
||||||
for (auto &button : m_buttons) {
|
for (auto &button : m_buttons) {
|
||||||
if (button.guibutton)
|
if (button.guibutton)
|
||||||
|
@ -201,6 +201,7 @@ public:
|
|||||||
void show();
|
void show();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
bool m_initialized = false;
|
||||||
IrrlichtDevice *m_device;
|
IrrlichtDevice *m_device;
|
||||||
IGUIEnvironment *m_guienv;
|
IGUIEnvironment *m_guienv;
|
||||||
IEventReceiver *m_receiver;
|
IEventReceiver *m_receiver;
|
||||||
|
Loading…
Reference in New Issue
Block a user