From 902990a097025c2f25b44ce882cc19cfa99f6ad2 Mon Sep 17 00:00:00 2001 From: "pinkerton%aol.net" Date: Mon, 19 Jan 2004 23:48:15 +0000 Subject: [PATCH] make sure we unregister our interest in being asked for sleep notification when there aren't any windows open. (r=josha/pink, sr=sfraser, bug 227680) --- widget/src/mac/nsToolkitBase.cpp | 18 +++++++++--------- widget/src/mac/nsToolkitBase.h | 4 ++-- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/widget/src/mac/nsToolkitBase.cpp b/widget/src/mac/nsToolkitBase.cpp index 141d49ad65a1..344f19bc9da3 100644 --- a/widget/src/mac/nsToolkitBase.cpp +++ b/widget/src/mac/nsToolkitBase.cpp @@ -72,7 +72,7 @@ static PRUintn gToolkitTLSIndex = 0; nsToolkitBase::nsToolkitBase() : mInited(false) -, mSleepWakeNotifcationRLS(nsnull) +, mSleepWakeNotificationRLS(nsnull) { } @@ -236,20 +236,19 @@ nsresult nsToolkitBase::RegisterForSleepWakeNotifcations() { IONotificationPortRef notifyPortRef; - io_object_t anIterator; - NS_ASSERTION(!mSleepWakeNotifcationRLS, "Already registered for sleep/wake"); + NS_ASSERTION(!mSleepWakeNotificationRLS, "Already registered for sleep/wake"); - gRootPort = ::IORegisterForSystemPower(0, ¬ifyPortRef, ToolkitSleepWakeCallback, &anIterator); + gRootPort = ::IORegisterForSystemPower(0, ¬ifyPortRef, ToolkitSleepWakeCallback, &mPowerNotifier); if (gRootPort == NULL) { NS_ASSERTION(0, "IORegisterForSystemPower failed"); return NS_ERROR_FAILURE; } - mSleepWakeNotifcationRLS = ::IONotificationPortGetRunLoopSource(notifyPortRef); + mSleepWakeNotificationRLS = ::IONotificationPortGetRunLoopSource(notifyPortRef); ::CFRunLoopAddSource(::CFRunLoopGetCurrent(), - mSleepWakeNotifcationRLS, + mSleepWakeNotificationRLS, kCFRunLoopDefaultMode); return NS_OK; @@ -259,13 +258,14 @@ nsToolkitBase::RegisterForSleepWakeNotifcations() void nsToolkitBase::RemoveSleepWakeNotifcations() { - if (mSleepWakeNotifcationRLS) + if (mSleepWakeNotificationRLS) { + IODeregisterForSystemPower(&mPowerNotifier); ::CFRunLoopRemoveSource(::CFRunLoopGetCurrent(), - mSleepWakeNotifcationRLS, + mSleepWakeNotificationRLS, kCFRunLoopDefaultMode); - mSleepWakeNotifcationRLS = nsnull; + mSleepWakeNotificationRLS = nsnull; } } diff --git a/widget/src/mac/nsToolkitBase.h b/widget/src/mac/nsToolkitBase.h index bd595b45b35b..4c9324a3683c 100644 --- a/widget/src/mac/nsToolkitBase.h +++ b/widget/src/mac/nsToolkitBase.h @@ -74,8 +74,8 @@ protected: bool mInited; - CFRunLoopSourceRef mSleepWakeNotifcationRLS; - + CFRunLoopSourceRef mSleepWakeNotificationRLS; + io_object_t mPowerNotifier; }; extern nsToolkitBase* NS_CreateToolkitInstance();