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)
This commit is contained in:
pinkerton%aol.net 2004-01-19 23:48:15 +00:00
parent d9f9aad50c
commit 902990a097
2 changed files with 11 additions and 11 deletions

View File

@ -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, &notifyPortRef, ToolkitSleepWakeCallback, &anIterator);
gRootPort = ::IORegisterForSystemPower(0, &notifyPortRef, 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;
}
}

View File

@ -74,8 +74,8 @@ protected:
bool mInited;
CFRunLoopSourceRef mSleepWakeNotifcationRLS;
CFRunLoopSourceRef mSleepWakeNotificationRLS;
io_object_t mPowerNotifier;
};
extern nsToolkitBase* NS_CreateToolkitInstance();