Bug 1558103 - Don't try to dispatch XPCOM events during shutdown. r=aklotz

XPCOM complains when events are dispatched during shutdown. Since we're
shutting down, there's no really any point in dispatching these messages
anyway, so we can safely ignore them.

Differential Revision: https://phabricator.services.mozilla.com/D113203
This commit is contained in:
Agi Sferro 2021-04-26 20:49:27 +00:00
Родитель 0bacfb352b
Коммит 5bd4ee0a35
1 изменённых файлов: 6 добавлений и 0 удалений

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

@ -25,6 +25,7 @@
#include "mozilla/dom/GeolocationPosition.h"
#include "mozilla/ArrayUtils.h"
#include "mozilla/AppShutdown.h"
#include "mozilla/Components.h"
#include "mozilla/Services.h"
#include "mozilla/Preferences.h"
@ -342,6 +343,11 @@ class XPCOMEventTargetWrapper final
public:
// Wraps a java runnable into an XPCOM runnable and dispatches it to mTarget.
void DispatchNative(mozilla::jni::Object::Param aJavaRunnable) {
if (AppShutdown::GetCurrentShutdownPhase() >=
ShutdownPhase::XPCOMShutdownThreads) {
// No point in trying to dispatch this if we're already shutting down.
return;
}
java::XPCOMEventTarget::JNIRunnable::GlobalRef r =
java::XPCOMEventTarget::JNIRunnable::Ref::From(aJavaRunnable);
mTarget->Dispatch(NS_NewRunnableFunction(