Aside from I locked the wrong (base) class. The problem was more that the driver interface was deleted to early.
Using a Referenceable seems to fix it now. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31992 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
3fccf0679f
commit
0814569216
@ -21,7 +21,6 @@ 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;
|
||||||
|
|
||||||
@ -33,7 +32,6 @@ 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);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -57,15 +55,17 @@ PowerStatusDriverInterface::PowerStatusDriverInterface()
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
PowerStatusDriverInterface::~PowerStatusDriverInterface()
|
PowerStatusDriverInterface::~PowerStatusDriverInterface()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
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)
|
||||||
@ -74,7 +74,6 @@ PowerStatusDriverInterface::StartWatching(BHandler* target)
|
|||||||
if (fThreadId > 0)
|
if (fThreadId > 0)
|
||||||
return B_OK;
|
return B_OK;
|
||||||
|
|
||||||
printf("spawn\n");
|
|
||||||
fThreadId = spawn_thread(&_ThreadWatchPowerFunction, "PowerStatusThread",
|
fThreadId = spawn_thread(&_ThreadWatchPowerFunction, "PowerStatusThread",
|
||||||
B_LOW_PRIORITY, this);
|
B_LOW_PRIORITY, this);
|
||||||
if (fThreadId >= 0) {
|
if (fThreadId >= 0) {
|
||||||
@ -95,6 +94,7 @@ 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;
|
||||||
|
|
||||||
@ -110,6 +110,14 @@ PowerStatusDriverInterface::StopWatching(BHandler* target)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
PowerStatusDriverInterface::Broadcast(uint32 message)
|
||||||
|
{
|
||||||
|
BAutolock autolock(fListLocker);
|
||||||
|
Monitor::Broadcast(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
PowerStatusDriverInterface::Disconnect()
|
PowerStatusDriverInterface::Disconnect()
|
||||||
{
|
{
|
||||||
|
@ -9,9 +9,10 @@
|
|||||||
#ifndef DRIVER_INTERFACE_H
|
#ifndef DRIVER_INTERFACE_H
|
||||||
#define DRIVER_INTERFACE_H
|
#define DRIVER_INTERFACE_H
|
||||||
|
|
||||||
|
#include <Handler.h>
|
||||||
#include <Locker.h>
|
#include <Locker.h>
|
||||||
#include <ObjectList.h>
|
#include <ObjectList.h>
|
||||||
#include <Handler.h>
|
#include <Referenceable.h>
|
||||||
|
|
||||||
#include "device/power_managment.h"
|
#include "device/power_managment.h"
|
||||||
|
|
||||||
@ -42,19 +43,20 @@ public:
|
|||||||
virtual void Broadcast(uint32 message);
|
virtual void Broadcast(uint32 message);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
BLocker fListLocker;
|
|
||||||
WatcherList fWatcherList;
|
WatcherList fWatcherList;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class PowerStatusDriverInterface : public Monitor
|
class PowerStatusDriverInterface : public Monitor, public Referenceable
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
PowerStatusDriverInterface();
|
PowerStatusDriverInterface();
|
||||||
~PowerStatusDriverInterface();
|
~PowerStatusDriverInterface();
|
||||||
|
|
||||||
virtual status_t StartWatching(BHandler* target);
|
virtual status_t StartWatching(BHandler* target);
|
||||||
virtual status_t StopWatching(BHandler* target);
|
virtual status_t StopWatching(BHandler* target);
|
||||||
|
virtual void Broadcast(uint32 message);
|
||||||
|
|
||||||
virtual status_t Connect() = 0;
|
virtual status_t Connect() = 0;
|
||||||
virtual void Disconnect();
|
virtual void Disconnect();
|
||||||
@ -73,6 +75,7 @@ private:
|
|||||||
static int32 _ThreadWatchPowerFunction(void* data);
|
static int32 _ThreadWatchPowerFunction(void* data);
|
||||||
|
|
||||||
thread_id fThreadId;
|
thread_id fThreadId;
|
||||||
|
BLocker fListLocker;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -338,6 +338,8 @@ ExtendedInfoWindow::ExtendedInfoWindow(PowerStatusDriverInterface* interface)
|
|||||||
fDriverInterface(interface),
|
fDriverInterface(interface),
|
||||||
fSelectedView(NULL)
|
fSelectedView(NULL)
|
||||||
{
|
{
|
||||||
|
fDriverInterface->AcquireReference();
|
||||||
|
|
||||||
BView *view = new BView(Bounds(), "view", B_FOLLOW_ALL, 0);
|
BView *view = new BView(Bounds(), "view", B_FOLLOW_ALL, 0);
|
||||||
view->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
|
view->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
|
||||||
AddChild(view);
|
AddChild(view);
|
||||||
@ -394,9 +396,10 @@ ExtendedInfoWindow::ExtendedInfoWindow(PowerStatusDriverInterface* interface)
|
|||||||
|
|
||||||
ExtendedInfoWindow::~ExtendedInfoWindow()
|
ExtendedInfoWindow::~ExtendedInfoWindow()
|
||||||
{
|
{
|
||||||
for (int i = 0; i < fBatteryViewList.CountItems(); i++) {
|
for (int i = 0; i < fBatteryViewList.CountItems(); i++)
|
||||||
fDriverInterface->StopWatching(fBatteryViewList.ItemAt(i));
|
fDriverInterface->StopWatching(fBatteryViewList.ItemAt(i));
|
||||||
}
|
|
||||||
|
fDriverInterface->ReleaseReference();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -400,12 +400,13 @@ PowerStatusReplicant::PowerStatusReplicant(BMessage* archive)
|
|||||||
|
|
||||||
PowerStatusReplicant::~PowerStatusReplicant()
|
PowerStatusReplicant::~PowerStatusReplicant()
|
||||||
{
|
{
|
||||||
if (fMessengerExist)
|
if (fMessengerExist) {
|
||||||
delete fExtWindowMessenger;
|
delete fExtWindowMessenger;
|
||||||
|
}
|
||||||
|
|
||||||
fDriverInterface->StopWatching(this);
|
fDriverInterface->StopWatching(this);
|
||||||
fDriverInterface->Disconnect();
|
fDriverInterface->Disconnect();
|
||||||
delete fDriverInterface;
|
fDriverInterface->ReleaseReference();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user