Bug 1372777 - Check that the native pointer has not been detached from the java object when dispatched to different thread r=esawin

MozReview-Commit-ID: DyeZDaHeWdL
This commit is contained in:
Randall Barker 2017-06-19 11:57:27 -07:00
Родитель 23446e3a7b
Коммит b31215e1b7
2 изменённых файлов: 15 добавлений и 10 удалений

Просмотреть файл

@ -404,9 +404,10 @@ class ProxyNativeCall : public AbstractCall
Call(const typename Owner::LocalRef& inst,
mozilla::IndexSequence<Indices...>) const
{
Impl* const impl = NativePtr<Impl>::Get(inst);
MOZ_CATCH_JNI_EXCEPTION(inst.Env());
(impl->*mNativeCall)(inst, mozilla::Get<Indices>(mArgs)...);
if (Impl* const impl = NativePtr<Impl>::Get(inst)) {
MOZ_CATCH_JNI_EXCEPTION(inst.Env());
(impl->*mNativeCall)(inst, mozilla::Get<Indices>(mArgs)...);
}
}
template<bool Static, bool ThisArg, size_t... Indices>
@ -414,9 +415,10 @@ class ProxyNativeCall : public AbstractCall
Call(const typename Owner::LocalRef& inst,
mozilla::IndexSequence<Indices...>) const
{
Impl* const impl = NativePtr<Impl>::Get(inst);
MOZ_CATCH_JNI_EXCEPTION(inst.Env());
(impl->*mNativeCall)(mozilla::Get<Indices>(mArgs)...);
if (Impl* const impl = NativePtr<Impl>::Get(inst)) {
MOZ_CATCH_JNI_EXCEPTION(inst.Env());
(impl->*mNativeCall)(mozilla::Get<Indices>(mArgs)...);
}
}
template<size_t... Indices>

Просмотреть файл

@ -983,11 +983,14 @@ public:
MOZ_ASSERT(NS_IsMainThread());
JNIEnv* const env = jni::GetGeckoThreadEnv();
LayerViewSupport* const lvs = GetNative(
LayerView::Compositor::LocalRef(env, mCompositor));
MOZ_CATCH_JNI_EXCEPTION(env);
// Make sure LayerViewSupport hasn't been detached from the
// Java object since this event was dispatched.
if (LayerViewSupport* const lvs = GetNative(
LayerView::Compositor::LocalRef(env, mCompositor))) {
MOZ_CATCH_JNI_EXCEPTION(env);
lvs->OnResumedCompositor();
lvs->OnResumedCompositor();
}
}
};