Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Don't try to initialize EmulatorView before a TermSession is attached

This avoids a crash when the view is inflated from XML and a TermSession
isn't attached right away.

Because onSizeChanged() no longer tries to initialize the view if no
TermSession is attached, we now need to call initialize() in
attachSession() if the view hasn't been initialized at that point.
  • Loading branch information...
commit de3838810310341ef61563d4c1f65138ee8aba96 1 parent 14866d3
@steven676 steven676 authored
View
16 libraries/emulatorview/src/jackpal/androidterm/emulatorview/EmulatorView.java
@@ -73,6 +73,9 @@
*/
private boolean mKnownSize;
+ // Set if initialization was deferred because a TermSession wasn't attached
+ private boolean mDeferInit = false;
+
private int mVisibleWidth;
private int mVisibleHeight;
@@ -286,6 +289,13 @@ public void attachSession(TermSession session) {
mTermSession = session;
mKeyListener = new TermKeyListener(session);
+
+ // Do init now if it was deferred until a TermSession was attached
+ if (mDeferInit) {
+ mDeferInit = false;
+ mKnownSize = true;
+ initialize();
+ }
}
/**
@@ -1053,6 +1063,12 @@ private void updateText() {
*/
@Override
protected void onSizeChanged(int w, int h, int oldw, int oldh) {
+ if (mTermSession == null) {
+ // Not ready, defer until TermSession is attached
+ mDeferInit = true;
+ return;
+ }
+
if (!mKnownSize) {
mKnownSize = true;
initialize();
Please sign in to comment.
Something went wrong with that request. Please try again.