1
0
Fork 0

a different attempt to clear the MainView in onDestroy(), again to prevent crashing

This commit is contained in:
sspanak 2025-03-17 11:56:08 +02:00 committed by Dimo Karaivanov
parent 15c618bc0b
commit 8420c6c961
3 changed files with 9 additions and 17 deletions

View file

@ -57,7 +57,7 @@ abstract public class MainViewHandler extends HotkeyHandler {
orientationListener = null; orientationListener = null;
} }
if (mainView != null) { if (mainView != null) {
mainView.stopListeners(); mainView.destroy();
} }
} }

View file

@ -217,9 +217,6 @@ public class TraditionalT9 extends MainViewHandler {
requestHideSelf(0); requestHideSelf(0);
cleanUp(); cleanUp();
stopSelf(); stopSelf();
if (mainView != null) {
mainView.destroy();
}
isDead = true; isDead = true;
} }
@ -236,14 +233,14 @@ public class TraditionalT9 extends MainViewHandler {
@Override @Override
public void onDestroy() { public void onDestroy() {
if (!isDead) { if (isDead) {
cleanUp(); Logger.w(LOG_TAG, "===> Already dead. Not destroying self.");
isDead = true; return;
} }
cleanUp();
isDead = true;
super.onDestroy(); super.onDestroy();
if (mainView != null) { // this run last because the MainView is used in super.onDestroy()
mainView.destroy();
}
Logger.d(LOG_TAG, "===> Shutdown completed"); Logger.d(LOG_TAG, "===> Shutdown completed");
} }

View file

@ -52,16 +52,11 @@ public class ResizableMainView extends MainView implements View.OnAttachStateCha
} }
public void stopListeners() { @Override
public void destroy() {
if (main != null && main.getView() != null) { if (main != null && main.getView() != null) {
main.getView().removeOnAttachStateChangeListener(this); main.getView().removeOnAttachStateChangeListener(this);
} }
}
@Override
public void destroy() {
stopListeners();
super.destroy(); super.destroy();
} }