mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 910484 - Use a pointer to hold a global static variable to avoid assertion, r=mrbkap
In order to avoid the assertion, which occurs because we can't control the order of contruction of global static variables, I changed to use a pointer instead of an instance, so I can really allocate the memory block at the other place (in ctor of BluetoothDBusService).
This commit is contained in:
parent
2a276ae5ef
commit
3dc523f7dc
@ -178,11 +178,21 @@ static nsTArray<uint32_t> sAuthorizedServiceClass;
|
||||
static nsString sAdapterPath;
|
||||
static Atomic<int32_t> sIsPairing(0);
|
||||
static int sConnectedDeviceCount = 0;
|
||||
static Monitor sStopBluetoothMonitor("BluetoothService.sStopBluetoothMonitor");
|
||||
static StaticAutoPtr<Monitor> sStopBluetoothMonitor;
|
||||
|
||||
typedef void (*UnpackFunc)(DBusMessage*, DBusError*, BluetoothValue&, nsAString&);
|
||||
typedef bool (*FilterFunc)(const BluetoothValue&);
|
||||
|
||||
BluetoothDBusService::BluetoothDBusService()
|
||||
{
|
||||
sStopBluetoothMonitor = new Monitor("BluetoothService.sStopBluetoothMonitor");
|
||||
}
|
||||
|
||||
BluetoothDBusService::~BluetoothDBusService()
|
||||
{
|
||||
sStopBluetoothMonitor = nullptr;
|
||||
}
|
||||
|
||||
static bool
|
||||
GetConnectedDevicesFilter(const BluetoothValue& aValue)
|
||||
{
|
||||
@ -1493,15 +1503,13 @@ EventFilter(DBusConnection* aConn, DBusMessage* aMsg, void* aData)
|
||||
signal.value() = parameters;
|
||||
NS_DispatchToMainThread(new DistributeBluetoothSignalTask(signal));
|
||||
} else if (property.name().EqualsLiteral("Connected")) {
|
||||
MonitorAutoLock lock(sStopBluetoothMonitor);
|
||||
MonitorAutoLock lock(*sStopBluetoothMonitor);
|
||||
|
||||
if (property.value().get_bool()) {
|
||||
++sConnectedDeviceCount;
|
||||
} else {
|
||||
MOZ_ASSERT(sConnectedDeviceCount > 0);
|
||||
|
||||
--sConnectedDeviceCount;
|
||||
if (sConnectedDeviceCount == 0) {
|
||||
if (--sConnectedDeviceCount == 0) {
|
||||
lock.Notify();
|
||||
}
|
||||
}
|
||||
@ -1696,7 +1704,7 @@ BluetoothDBusService::StopInternal()
|
||||
MOZ_ASSERT(!NS_IsMainThread());
|
||||
|
||||
{
|
||||
MonitorAutoLock lock(sStopBluetoothMonitor);
|
||||
MonitorAutoLock lock(*sStopBluetoothMonitor);
|
||||
if (sConnectedDeviceCount > 0) {
|
||||
lock.Wait(PR_SecondsToInterval(TIMEOUT_FORCE_TO_DISABLE_BT));
|
||||
}
|
||||
|
@ -162,6 +162,9 @@ public:
|
||||
SendInputMessage(const nsAString& aDeviceAddresses,
|
||||
const nsAString& aMessage,
|
||||
BluetoothReplyRunnable* aRunnable) MOZ_OVERRIDE;
|
||||
protected:
|
||||
BluetoothDBusService();
|
||||
~BluetoothDBusService();
|
||||
|
||||
private:
|
||||
/**
|
||||
@ -196,7 +199,6 @@ private:
|
||||
void UpdateNotification(ControlEventId aEventId, uint64_t aData);
|
||||
|
||||
void DisconnectAllAcls(const nsAString& aAdapterPath);
|
||||
|
||||
};
|
||||
|
||||
END_BLUETOOTH_NAMESPACE
|
||||
|
Loading…
Reference in New Issue
Block a user