Bug 1791531 - Do not assume that the battery listener has been registered correctly on macOS r=haik

Differential Revision: https://phabricator.services.mozilla.com/D157719
This commit is contained in:
Gabriele Svelto 2022-09-22 09:29:42 +00:00
parent 325aad0ef3
commit 8b0f8edb2c

View file

@ -195,13 +195,11 @@ void MacPowerInformationService::BeginListening() {
}
void MacPowerInformationService::StopListening() {
MOZ_ASSERT(mRunLoopSource,
"IOPS Notification Loop Source not set up. "
"(StopListening without BeginListening)");
::CFRunLoopRemoveSource(::CFRunLoopGetCurrent(), mRunLoopSource,
kCFRunLoopDefaultMode);
mRunLoopSource = nullptr;
if (mRunLoopSource) {
::CFRunLoopRemoveSource(::CFRunLoopGetCurrent(), mRunLoopSource,
kCFRunLoopDefaultMode);
mRunLoopSource = nullptr;
}
}
void MacPowerInformationService::HandleChange(void* aContext) {