mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-09 19:35:51 +00:00
Bug 751262 - Don't pop the JNI local ref frame if pushing it failed. r=kats
This commit is contained in:
parent
4cd96ac9ae
commit
b39fb82bfd
@ -549,14 +549,14 @@ protected:
|
||||
class AutoLocalJNIFrame {
|
||||
public:
|
||||
AutoLocalJNIFrame(int nEntries = 128)
|
||||
: mEntries(nEntries)
|
||||
: mEntries(nEntries), mHasFrameBeenPushed(false)
|
||||
{
|
||||
mJNIEnv = AndroidBridge::GetJNIEnv();
|
||||
Push();
|
||||
}
|
||||
|
||||
AutoLocalJNIFrame(JNIEnv* aJNIEnv, int nEntries = 128)
|
||||
: mEntries(nEntries)
|
||||
: mEntries(nEntries), mHasFrameBeenPushed(false)
|
||||
{
|
||||
mJNIEnv = aJNIEnv ? aJNIEnv : AndroidBridge::GetJNIEnv();
|
||||
|
||||
@ -568,7 +568,8 @@ public:
|
||||
// any local refs that you need to keep around in global refs!
|
||||
void Purge() {
|
||||
if (mJNIEnv) {
|
||||
mJNIEnv->PopLocalFrame(NULL);
|
||||
if (mHasFrameBeenPushed)
|
||||
mJNIEnv->PopLocalFrame(NULL);
|
||||
Push();
|
||||
}
|
||||
}
|
||||
@ -593,7 +594,8 @@ public:
|
||||
|
||||
CheckForException();
|
||||
|
||||
mJNIEnv->PopLocalFrame(NULL);
|
||||
if (mHasFrameBeenPushed)
|
||||
mJNIEnv->PopLocalFrame(NULL);
|
||||
}
|
||||
|
||||
private:
|
||||
@ -606,13 +608,15 @@ private:
|
||||
// not hurt.
|
||||
jint ret = mJNIEnv->PushLocalFrame(mEntries + 1);
|
||||
NS_ABORT_IF_FALSE(ret == 0, "Failed to push local JNI frame");
|
||||
if (ret < 0) {
|
||||
if (ret < 0)
|
||||
CheckForException();
|
||||
}
|
||||
else
|
||||
mHasFrameBeenPushed = true;
|
||||
}
|
||||
|
||||
int mEntries;
|
||||
JNIEnv* mJNIEnv;
|
||||
bool mHasFrameBeenPushed;
|
||||
};
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user