Native platform modifies exit process (#14141)

This commit is contained in:
qiuguohua
2023-02-15 17:11:28 +08:00
committed by GitHub
parent 9390d05525
commit ee86fc40bd
37 changed files with 228 additions and 109 deletions
@@ -255,7 +255,6 @@ public:
addTouchEvent(i, motionEvent);
}
}
events::Touch::broadcast(touchEvent);
touchEvent.touches.clear();
return true;
@@ -383,7 +382,6 @@ public:
WindowEvent ev;
ev.type = WindowEvent::Type::CLOSE;
events::WindowEvent::broadcast(ev);
_androidPlatform->onDestroy();
break;
}
case APP_CMD_STOP: {
@@ -583,6 +581,10 @@ int32_t AndroidPlatform::run(int /*argc*/, const char ** /*argv*/) {
return 0;
}
void AndroidPlatform::exit() {
_app->destroyRequested = 1;
}
int32_t AndroidPlatform::loop() {
IXRInterface *xr = getInterface<IXRInterface>();
while (true) {
@@ -599,10 +601,13 @@ int32_t AndroidPlatform::loop() {
// Exit the game loop when the Activity is destroyed
if (_app->destroyRequested) {
return 0;
break;
}
}
// Exit the game loop when the Activity is destroyed
if (_app->destroyRequested) {
break;
}
if (xr && !xr->platformLoopStart()) continue;
_inputProxy->handleInput();
if (_inputProxy->isAnimating() && (xr ? xr->getXRConfig(xr::XRConfigKey::SESSION_RUNNING).getBool() : true)) {
@@ -626,6 +631,8 @@ int32_t AndroidPlatform::loop() {
#endif
if (xr) xr->platformLoopEnd();
}
onDestroy();
return 0;
}
void AndroidPlatform::pollEvent() {