Bug 604712 - Followup - Make autoframes clean up unhandled exceptions. r=dougt a=blocking-fennec
authorMichael Wu <mwu@mozilla.com>
Sat, 20 Nov 2010 13:09:24 -0800
changeset 57957 91980a82eeae105a7e64d2c73fe23f9b97a3a90f
parent 57956 ca12132a0d8c4d8bd1d6d5ace24c9134a467c1f5
child 57958 64fdcad8cb1111c18e75face950d9c707b2b5673
push id1
push usershaver@mozilla.com
push dateTue, 04 Jan 2011 17:58:04 +0000
reviewersdougt, blocking-fennec
bugs604712
milestone2.0b8pre
Bug 604712 - Followup - Make autoframes clean up unhandled exceptions. r=dougt a=blocking-fennec
widget/src/android/AndroidBridge.h
--- a/widget/src/android/AndroidBridge.h
+++ b/widget/src/android/AndroidBridge.h
@@ -173,26 +173,35 @@ public:
     void SetFullScreen(PRBool aFullScreen);
 
     void ShowInputMethodPicker();
 
     void HideProgressDialogOnce();
 
     struct AutoLocalJNIFrame {
         AutoLocalJNIFrame(int nEntries = 128) : mEntries(nEntries) {
-            AndroidBridge::Bridge()->JNI()->PushLocalFrame(mEntries);
+            // Make sure there is enough space to store a local ref to the
+            // exception.  I am not completely sure this is needed, but does
+            // not hurt.
+            AndroidBridge::Bridge()->JNI()->PushLocalFrame(mEntries + 1);
         }
         // Note! Calling Purge makes all previous local refs created in
         // the AutoLocalJNIFrame's scope INVALID; be sure that you locked down
         // any local refs that you need to keep around in global refs!
         void Purge() {
             AndroidBridge::Bridge()->JNI()->PopLocalFrame(NULL);
             AndroidBridge::Bridge()->JNI()->PushLocalFrame(mEntries);
         }
         ~AutoLocalJNIFrame() {
+            jthrowable exception =
+                AndroidBridge::Bridge()->JNI()->ExceptionOccurred();
+            if (exception) {
+                AndroidBridge::Bridge()->JNI()->ExceptionDescribe();
+                AndroidBridge::Bridge()->JNI()->ExceptionClear();
+            }
             AndroidBridge::Bridge()->JNI()->PopLocalFrame(NULL);
         }
         int mEntries;
     };
 
     /* See GLHelpers.java as to why this is needed */
     void *CallEglCreateWindowSurface(void *dpy, void *config, AndroidGeckoSurfaceView& surfaceView);