1
0
Fork 0

when shutting down, the MainView is now destroyed last, to prevent crashes; also destroyed on start, just in case

This commit is contained in:
sspanak 2025-03-07 15:18:03 +02:00 committed by Dimo Karaivanov
parent 3f1330f152
commit 6139517d75
4 changed files with 16 additions and 3 deletions

View file

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

View file

@ -217,6 +217,9 @@ public class TraditionalT9 extends MainViewHandler {
requestHideSelf(0); requestHideSelf(0);
cleanUp(); cleanUp();
stopSelf(); stopSelf();
if (mainView != null) {
mainView.destroy();
}
isDead = true; isDead = true;
} }
@ -238,6 +241,9 @@ public class TraditionalT9 extends MainViewHandler {
isDead = true; 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

@ -22,6 +22,8 @@ abstract class UiHandler extends AbstractHandler {
if (mainView == null) { if (mainView == null) {
mainView = new ResizableMainView(getFinalContext()); mainView = new ResizableMainView(getFinalContext());
initTray(); initTray();
} else {
mainView.destroy();
} }
} }

View file

@ -52,11 +52,16 @@ public class ResizableMainView extends MainView implements View.OnAttachStateCha
} }
@Override public void stopListeners() {
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();
} }