Bug 1961648, avoid using ObserverService late during shutdown, a=RyanVM DONTBUILD

Original Revision: https://phabricator.services.mozilla.com/D265675

Differential Revision: https://phabricator.services.mozilla.com/D268905
This commit is contained in:
Olli Pettay
2025-10-18 17:59:14 +00:00
committed by rvandermeulen@mozilla.com
parent 45b12df108
commit 74ba37c339

View File

@@ -6,6 +6,7 @@
#include "EventStateManager.h"
#include "mozilla/AppShutdown.h"
#include "mozilla/AsyncEventDispatcher.h"
#include "mozilla/Attributes.h"
#include "mozilla/EditorBase.h"
@@ -302,7 +303,10 @@ NS_IMPL_ISUPPORTS(UITimerCallback, nsITimerCallback, nsINamed)
NS_IMETHODIMP
UITimerCallback::Notify(nsITimer* aTimer) {
nsCOMPtr<nsIObserverService> obs = mozilla::services::GetObserverService();
if (!obs) return NS_ERROR_FAILURE;
// ObserverService shutdown happens after XPCOMShutdownThreads.
if (!obs || AppShutdown::IsInOrBeyond(ShutdownPhase::XPCOMShutdownThreads)) {
return NS_ERROR_FAILURE;
}
if ((gMouseOrKeyboardEventCounter == mPreviousCount) || !aTimer) {
gMouseOrKeyboardEventCounter = 0;
obs->NotifyObservers(nullptr, "user-interaction-inactive", nullptr);