The monitor watcher list was not locked when broadcast a message.
Probably it caused #4151 git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31982 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -21,6 +21,7 @@ Monitor::~Monitor()
|
|||||||
status_t
|
status_t
|
||||||
Monitor::StartWatching(BHandler* target)
|
Monitor::StartWatching(BHandler* target)
|
||||||
{
|
{
|
||||||
|
BAutolock autolock(fListLocker);
|
||||||
if (fWatcherList.HasItem(target))
|
if (fWatcherList.HasItem(target))
|
||||||
return B_ERROR;
|
return B_ERROR;
|
||||||
|
|
||||||
@@ -32,6 +33,7 @@ Monitor::StartWatching(BHandler* target)
|
|||||||
status_t
|
status_t
|
||||||
Monitor::StopWatching(BHandler* target)
|
Monitor::StopWatching(BHandler* target)
|
||||||
{
|
{
|
||||||
|
BAutolock autolock(fListLocker);
|
||||||
return fWatcherList.RemoveItem(target);
|
return fWatcherList.RemoveItem(target);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -64,8 +66,6 @@ PowerStatusDriverInterface::~PowerStatusDriverInterface()
|
|||||||
status_t
|
status_t
|
||||||
PowerStatusDriverInterface::StartWatching(BHandler* target)
|
PowerStatusDriverInterface::StartWatching(BHandler* target)
|
||||||
{
|
{
|
||||||
BAutolock autolock(fListLocker);
|
|
||||||
|
|
||||||
status_t status = Monitor::StartWatching(target);
|
status_t status = Monitor::StartWatching(target);
|
||||||
|
|
||||||
if (status != B_OK)
|
if (status != B_OK)
|
||||||
@@ -95,8 +95,6 @@ PowerStatusDriverInterface::StartWatching(BHandler* target)
|
|||||||
status_t
|
status_t
|
||||||
PowerStatusDriverInterface::StopWatching(BHandler* target)
|
PowerStatusDriverInterface::StopWatching(BHandler* target)
|
||||||
{
|
{
|
||||||
BAutolock autolock(fListLocker);
|
|
||||||
|
|
||||||
if (fThreadId < 0)
|
if (fThreadId < 0)
|
||||||
return B_BAD_VALUE;
|
return B_BAD_VALUE;
|
||||||
|
|
||||||
|
|||||||
@@ -42,6 +42,7 @@ public:
|
|||||||
virtual void Broadcast(uint32 message);
|
virtual void Broadcast(uint32 message);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
BLocker fListLocker;
|
||||||
WatcherList fWatcherList;
|
WatcherList fWatcherList;
|
||||||
|
|
||||||
};
|
};
|
||||||
@@ -72,8 +73,6 @@ private:
|
|||||||
static int32 _ThreadWatchPowerFunction(void* data);
|
static int32 _ThreadWatchPowerFunction(void* data);
|
||||||
|
|
||||||
thread_id fThreadId;
|
thread_id fThreadId;
|
||||||
|
|
||||||
BLocker fListLocker;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -400,7 +400,7 @@ PowerStatusReplicant::PowerStatusReplicant(BMessage* archive)
|
|||||||
|
|
||||||
PowerStatusReplicant::~PowerStatusReplicant()
|
PowerStatusReplicant::~PowerStatusReplicant()
|
||||||
{
|
{
|
||||||
if (fExtWindowMessenger)
|
if (fMessengerExist)
|
||||||
delete fExtWindowMessenger;
|
delete fExtWindowMessenger;
|
||||||
|
|
||||||
fDriverInterface->StopWatching(this);
|
fDriverInterface->StopWatching(this);
|
||||||
@@ -536,6 +536,7 @@ PowerStatusReplicant::_Init()
|
|||||||
}
|
}
|
||||||
|
|
||||||
fExtendedWindow = NULL;
|
fExtendedWindow = NULL;
|
||||||
|
fMessengerExist = false;
|
||||||
fExtWindowMessenger = NULL;
|
fExtWindowMessenger = NULL;
|
||||||
|
|
||||||
fDriverInterface->StartWatching(this);
|
fDriverInterface->StartWatching(this);
|
||||||
@@ -566,7 +567,10 @@ PowerStatusReplicant::_OpenExtendedWindow()
|
|||||||
msg.AddSpecifier("Hidden", int32(0));
|
msg.AddSpecifier("Hidden", int32(0));
|
||||||
if (fExtWindowMessenger->SendMessage(&msg) == B_BAD_PORT_ID) {
|
if (fExtWindowMessenger->SendMessage(&msg) == B_BAD_PORT_ID) {
|
||||||
fExtendedWindow = new ExtendedInfoWindow(fDriverInterface);
|
fExtendedWindow = new ExtendedInfoWindow(fDriverInterface);
|
||||||
|
if (fMessengerExist)
|
||||||
|
delete fExtWindowMessenger;
|
||||||
fExtWindowMessenger = new BMessenger(NULL, fExtendedWindow);
|
fExtWindowMessenger = new BMessenger(NULL, fExtendedWindow);
|
||||||
|
fMessengerExist = true;
|
||||||
fExtendedWindow->Show();
|
fExtendedWindow->Show();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -86,6 +86,7 @@ class PowerStatusReplicant : public PowerStatusView
|
|||||||
void _OpenExtendedWindow();
|
void _OpenExtendedWindow();
|
||||||
|
|
||||||
BWindow* fExtendedWindow;
|
BWindow* fExtendedWindow;
|
||||||
|
bool fMessengerExist;
|
||||||
BMessenger* fExtWindowMessenger;
|
BMessenger* fExtWindowMessenger;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user