From c347a3748af663da9e8e6ce5e233248b80217f96 Mon Sep 17 00:00:00 2001 From: Edward Welbourne Date: Thu, 19 May 2016 18:27:45 +0200 Subject: QBluetoothServiceDiscoveryAgent: set q_ptr in d_ptr's constructor. The agent class constructors were initializing the q_ptr member of their d_ptr; it is cleaner to pass this down to the d_ptr's constructor and let it do this itself. This also lets Coverity know that initialization actually does happen (CID 22330). In particular, it makes sure we can't leave it uninitialized, if an agent implementation happens to neglect to do so. Change-Id: Ie01046a5a113b5669e8e63c6a22f692cd3943ac0 Reviewed-by: Alex Blasche --- src/bluetooth/qbluetoothservicediscoveryagent_osx.mm | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'src/bluetooth/qbluetoothservicediscoveryagent_osx.mm') diff --git a/src/bluetooth/qbluetoothservicediscoveryagent_osx.mm b/src/bluetooth/qbluetoothservicediscoveryagent_osx.mm index 0cf77d9d..c3d4a0e6 100644 --- a/src/bluetooth/qbluetoothservicediscoveryagent_osx.mm +++ b/src/bluetooth/qbluetoothservicediscoveryagent_osx.mm @@ -62,7 +62,8 @@ public: ServiceDiscovery, }; - QBluetoothServiceDiscoveryAgentPrivate(const QBluetoothAddress &localAddress); + QBluetoothServiceDiscoveryAgentPrivate(QBluetoothServiceDiscoveryAgent *qp, + const QBluetoothAddress &localAddress); void startDeviceDiscovery(); void stopDeviceDiscovery(); @@ -110,8 +111,9 @@ private: OSXBluetooth::ObjCScopedPointer serviceInquiry; }; -QBluetoothServiceDiscoveryAgentPrivate::QBluetoothServiceDiscoveryAgentPrivate(const QBluetoothAddress &localAddress) : - q_ptr(0), +QBluetoothServiceDiscoveryAgentPrivate::QBluetoothServiceDiscoveryAgentPrivate( + QBluetoothServiceDiscoveryAgent *qp, const QBluetoothAddress &localAddress) : + q_ptr(qp), error(QBluetoothServiceDiscoveryAgent::NoError), singleDevice(false), localAdapterAddress(localAddress), @@ -423,15 +425,15 @@ void QBluetoothServiceDiscoveryAgentPrivate::serviceDiscoveryFinished() } QBluetoothServiceDiscoveryAgent::QBluetoothServiceDiscoveryAgent(QObject *parent) -: QObject(parent), d_ptr(new QBluetoothServiceDiscoveryAgentPrivate(QBluetoothAddress())) +: QObject(parent), + d_ptr(new QBluetoothServiceDiscoveryAgentPrivate(this, QBluetoothAddress())) { - d_ptr->q_ptr = this; } QBluetoothServiceDiscoveryAgent::QBluetoothServiceDiscoveryAgent(const QBluetoothAddress &deviceAdapter, QObject *parent) -: QObject(parent), d_ptr(new QBluetoothServiceDiscoveryAgentPrivate(deviceAdapter)) +: QObject(parent), + d_ptr(new QBluetoothServiceDiscoveryAgentPrivate(this, deviceAdapter)) { - d_ptr->q_ptr = this; if (!deviceAdapter.isNull()) { const QList localDevices = QBluetoothLocalDevice::allDevices(); foreach (const QBluetoothHostInfo &hostInfo, localDevices) { -- cgit v1.2.3