@@ -326,15 +326,6 @@ static void android_app_set_window(struct android_app* android_app,
326
326
ANativeWindow * window ) {
327
327
LOGV ("android_app_set_window called" );
328
328
pthread_mutex_lock (& android_app -> mutex );
329
-
330
- // NB: we have to consider that the native thread could have already
331
- // (gracefully) exit (setting android_app->destroyed) and so we need
332
- // to be careful to avoid a deadlock waiting for a thread that's
333
- // already exit.
334
- if (android_app -> destroyed ) {
335
- pthread_mutex_unlock (& android_app -> mutex );
336
- return ;
337
- }
338
329
if (android_app -> pendingWindow != NULL ) {
339
330
android_app_write_cmd (android_app , APP_CMD_TERM_WINDOW );
340
331
}
@@ -351,16 +342,9 @@ static void android_app_set_window(struct android_app* android_app,
351
342
static void android_app_set_activity_state (struct android_app * android_app ,
352
343
int8_t cmd ) {
353
344
pthread_mutex_lock (& android_app -> mutex );
354
-
355
- // NB: we have to consider that the native thread could have already
356
- // (gracefully) exit (setting android_app->destroyed) and so we need
357
- // to be careful to avoid a deadlock waiting for a thread that's
358
- // already exit.
359
- if (!android_app -> destroyed ) {
360
- android_app_write_cmd (android_app , cmd );
361
- while (android_app -> activityState != cmd ) {
362
- pthread_cond_wait (& android_app -> cond , & android_app -> mutex );
363
- }
345
+ android_app_write_cmd (android_app , cmd );
346
+ while (android_app -> activityState != cmd ) {
347
+ pthread_cond_wait (& android_app -> cond , & android_app -> mutex );
364
348
}
365
349
pthread_mutex_unlock (& android_app -> mutex );
366
350
}
@@ -369,14 +353,6 @@ static void android_app_free(struct android_app* android_app) {
369
353
int input_buf_idx = 0 ;
370
354
371
355
pthread_mutex_lock (& android_app -> mutex );
372
-
373
- // It's possible that onDestroy is called after we have already 'destroyed'
374
- // the app (via `android_app_destroy` due to `android_main` returning.
375
- //
376
- // In this case `->destroyed` will already be set (so we won't deadlock in
377
- // the loop below) but we still need to close the messaging fds and finish
378
- // freeing the android_app
379
-
380
356
android_app_write_cmd (android_app , APP_CMD_DESTROY );
381
357
while (!android_app -> destroyed ) {
382
358
pthread_cond_wait (& android_app -> cond , & android_app -> mutex );
@@ -424,16 +400,6 @@ static void onSaveInstanceState(GameActivity* activity,
424
400
425
401
struct android_app * android_app = ToApp (activity );
426
402
pthread_mutex_lock (& android_app -> mutex );
427
-
428
- // NB: we have to consider that the native thread could have already
429
- // (gracefully) exit (setting android_app->destroyed) and so we need
430
- // to be careful to avoid a deadlock waiting for a thread that's
431
- // already exit.
432
- if (android_app -> destroyed ) {
433
- pthread_mutex_unlock (& android_app -> mutex );
434
- return ;
435
- }
436
-
437
403
android_app -> stateSaved = 0 ;
438
404
android_app_write_cmd (android_app , APP_CMD_SAVE_STATE );
439
405
while (!android_app -> stateSaved ) {
@@ -539,15 +505,6 @@ static bool onTouchEvent(GameActivity* activity,
539
505
struct android_app * android_app = ToApp (activity );
540
506
pthread_mutex_lock (& android_app -> mutex );
541
507
542
- // NB: we have to consider that the native thread could have already
543
- // (gracefully) exit (setting android_app->destroyed) and so we need
544
- // to be careful to avoid a deadlock waiting for a thread that's
545
- // already exit.
546
- if (android_app -> destroyed ) {
547
- pthread_mutex_unlock (& android_app -> mutex );
548
- return false;
549
- }
550
-
551
508
if (android_app -> motionEventFilter != NULL &&
552
509
!android_app -> motionEventFilter (event )) {
553
510
pthread_mutex_unlock (& android_app -> mutex );
@@ -625,15 +582,6 @@ static bool onKey(GameActivity* activity, const GameActivityKeyEvent* event) {
625
582
struct android_app * android_app = ToApp (activity );
626
583
pthread_mutex_lock (& android_app -> mutex );
627
584
628
- // NB: we have to consider that the native thread could have already
629
- // (gracefully) exit (setting android_app->destroyed) and so we need
630
- // to be careful to avoid a deadlock waiting for a thread that's
631
- // already exit.
632
- if (android_app -> destroyed ) {
633
- pthread_mutex_unlock (& android_app -> mutex );
634
- return false;
635
- }
636
-
637
585
if (android_app -> keyEventFilter != NULL &&
638
586
!android_app -> keyEventFilter (event )) {
639
587
pthread_mutex_unlock (& android_app -> mutex );
@@ -672,9 +620,8 @@ static void onTextInputEvent(GameActivity* activity,
672
620
const GameTextInputState * state ) {
673
621
struct android_app * android_app = ToApp (activity );
674
622
pthread_mutex_lock (& android_app -> mutex );
675
- if (!android_app -> destroyed ) {
676
- android_app -> textInputState = 1 ;
677
- }
623
+
624
+ android_app -> textInputState = 1 ;
678
625
pthread_mutex_unlock (& android_app -> mutex );
679
626
}
680
627
0 commit comments