mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-14 22:05:44 +00:00
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:
parent
d9f9aad50c
commit
902990a097
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -74,8 +74,8 @@ protected:
|
||||
|
||||
bool mInited;
|
||||
|
||||
CFRunLoopSourceRef mSleepWakeNotifcationRLS;
|
||||
|
||||
CFRunLoopSourceRef mSleepWakeNotificationRLS;
|
||||
io_object_t mPowerNotifier;
|
||||
};
|
||||
|
||||
extern nsToolkitBase* NS_CreateToolkitInstance();
|
||||
|
Loading…
Reference in New Issue
Block a user