plugin/bearer remove static QDBusConnection::systemBus() initialization

The static initialization of QDBusConnection::systemBus() can occur
before the creation of QCoreApplication. This causes a warning from
QDBusConnection and may cause the application to crash on exit.

Since QDBusConnection::systemBus() is just an accessor, there is no
real advantage to storing a static reference to it.

Task-number: QTBUG-39248
Change-Id: I4401810c7c2ffd21a30f9ffd41b3a46e7e09214c
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Alex Blasche <alexander.blasche@digia.com>
This commit is contained in:
Dyami Caliri 2014-05-24 10:18:48 -07:00 committed by The Qt Project
parent 50491efb0e
commit 8917179b47

View File

@ -58,8 +58,6 @@
QT_BEGIN_NAMESPACE
static QDBusConnection dbusConnection = QDBusConnection::systemBus();
class QNetworkManagerInterfacePrivate
{
public:
@ -74,7 +72,7 @@ QNetworkManagerInterface::QNetworkManagerInterface(QObject *parent)
d->connectionInterface = new QDBusInterface(QLatin1String(NM_DBUS_SERVICE),
QLatin1String(NM_DBUS_PATH),
QLatin1String(NM_DBUS_INTERFACE),
dbusConnection);
QDBusConnection::systemBus());
if (!d->connectionInterface->isValid()) {
d->valid = false;
return;
@ -103,6 +101,9 @@ bool QNetworkManagerInterface::setConnections()
{
if(!isValid() )
return false;
QDBusConnection dbusConnection = QDBusConnection::systemBus();
bool allOk = false;
if (!dbusConnection.connect(QLatin1String(NM_DBUS_SERVICE),
QLatin1String(NM_DBUS_PATH),
@ -198,7 +199,7 @@ QNetworkManagerInterfaceAccessPoint::QNetworkManagerInterfaceAccessPoint(const Q
d->connectionInterface = new QDBusInterface(QLatin1String(NM_DBUS_SERVICE),
d->path,
QLatin1String(NM_DBUS_INTERFACE_ACCESS_POINT),
dbusConnection);
QDBusConnection::systemBus());
if (!d->connectionInterface->isValid()) {
d->valid = false;
return;
@ -229,7 +230,7 @@ bool QNetworkManagerInterfaceAccessPoint::setConnections()
connect(nmDBusHelper, SIGNAL(pathForPropertiesChanged(QString,QMap<QString,QVariant>)),
this,SIGNAL(propertiesChanged(QString,QMap<QString,QVariant>)));
if(dbusConnection.connect(QLatin1String(NM_DBUS_SERVICE),
if (QDBusConnection::systemBus().connect(QLatin1String(NM_DBUS_SERVICE),
d->path,
QLatin1String(NM_DBUS_INTERFACE_ACCESS_POINT),
QLatin1String("PropertiesChanged"),
@ -306,7 +307,7 @@ QNetworkManagerInterfaceDevice::QNetworkManagerInterfaceDevice(const QString &de
d->connectionInterface = new QDBusInterface(QLatin1String(NM_DBUS_SERVICE),
d->path,
QLatin1String(NM_DBUS_INTERFACE_DEVICE),
dbusConnection);
QDBusConnection::systemBus());
if (!d->connectionInterface->isValid()) {
d->valid = false;
return;
@ -335,7 +336,7 @@ bool QNetworkManagerInterfaceDevice::setConnections()
nmDBusHelper = new QNmDBusHelper(this);
connect(nmDBusHelper,SIGNAL(pathForStateChanged(QString,quint32)),
this, SIGNAL(stateChanged(QString,quint32)));
if(dbusConnection.connect(QLatin1String(NM_DBUS_SERVICE),
if (QDBusConnection::systemBus().connect(QLatin1String(NM_DBUS_SERVICE),
d->path,
QLatin1String(NM_DBUS_INTERFACE_DEVICE),
QLatin1String("StateChanged"),
@ -397,7 +398,7 @@ QNetworkManagerInterfaceDeviceWired::QNetworkManagerInterfaceDeviceWired(const Q
d->connectionInterface = new QDBusInterface(QLatin1String(NM_DBUS_SERVICE),
d->path,
QLatin1String(NM_DBUS_INTERFACE_DEVICE_WIRED),
dbusConnection, parent);
QDBusConnection::systemBus(), parent);
if (!d->connectionInterface->isValid()) {
d->valid = false;
return;
@ -428,7 +429,7 @@ bool QNetworkManagerInterfaceDeviceWired::setConnections()
nmDBusHelper = new QNmDBusHelper(this);
connect(nmDBusHelper, SIGNAL(pathForPropertiesChanged(QString,QMap<QString,QVariant>)),
this,SIGNAL(propertiesChanged(QString,QMap<QString,QVariant>)));
if(dbusConnection.connect(QLatin1String(NM_DBUS_SERVICE),
if (QDBusConnection::systemBus().connect(QLatin1String(NM_DBUS_SERVICE),
d->path,
QLatin1String(NM_DBUS_INTERFACE_DEVICE_WIRED),
QLatin1String("PropertiesChanged"),
@ -474,7 +475,7 @@ QNetworkManagerInterfaceDeviceWireless::QNetworkManagerInterfaceDeviceWireless(c
d->connectionInterface = new QDBusInterface(QLatin1String(NM_DBUS_SERVICE),
d->path,
QLatin1String(NM_DBUS_INTERFACE_DEVICE_WIRELESS),
dbusConnection, parent);
QDBusConnection::systemBus(), parent);
if (!d->connectionInterface->isValid()) {
d->valid = false;
return;
@ -498,6 +499,7 @@ bool QNetworkManagerInterfaceDeviceWireless::setConnections()
if(!isValid() )
return false;
QDBusConnection dbusConnection = QDBusConnection::systemBus();
bool allOk = false;
delete nmDBusHelper;
nmDBusHelper = new QNmDBusHelper(this);
@ -591,7 +593,7 @@ QNetworkManagerSettings::QNetworkManagerSettings(const QString &settingsService,
d->connectionInterface = new QDBusInterface(settingsService,
QLatin1String(NM_DBUS_PATH_SETTINGS),
QLatin1String(NM_DBUS_IFACE_SETTINGS),
dbusConnection);
QDBusConnection::systemBus());
if (!d->connectionInterface->isValid()) {
d->valid = false;
return;
@ -614,7 +616,7 @@ bool QNetworkManagerSettings::setConnections()
{
bool allOk = false;
if (!dbusConnection.connect(d->path, QLatin1String(NM_DBUS_PATH_SETTINGS),
if (!QDBusConnection::systemBus().connect(d->path, QLatin1String(NM_DBUS_PATH_SETTINGS),
QLatin1String(NM_DBUS_IFACE_SETTINGS), QLatin1String("NewConnection"),
this, SIGNAL(newConnection(QDBusObjectPath)))) {
allOk = true;
@ -655,7 +657,7 @@ QNetworkManagerSettingsConnection::QNetworkManagerSettingsConnection(const QStri
d->connectionInterface = new QDBusInterface(settingsService,
d->path,
QLatin1String(NM_DBUS_IFACE_SETTINGS_CONNECTION),
dbusConnection, parent);
QDBusConnection::systemBus(), parent);
if (!d->connectionInterface->isValid()) {
d->valid = false;
return;
@ -681,6 +683,7 @@ bool QNetworkManagerSettingsConnection::setConnections()
if(!isValid() )
return false;
QDBusConnection dbusConnection = QDBusConnection::systemBus();
bool allOk = false;
if(!dbusConnection.connect(d->service, d->path,
QLatin1String(NM_DBUS_IFACE_SETTINGS_CONNECTION), QLatin1String("Updated"),
@ -808,7 +811,7 @@ QNetworkManagerConnectionActive::QNetworkManagerConnectionActive( const QString
d->connectionInterface = new QDBusInterface(QLatin1String(NM_DBUS_SERVICE),
d->path,
QLatin1String(NM_DBUS_INTERFACE_ACTIVE_CONNECTION),
dbusConnection, parent);
QDBusConnection::systemBus(), parent);
if (!d->connectionInterface->isValid()) {
d->valid = false;
return;
@ -837,7 +840,7 @@ bool QNetworkManagerConnectionActive::setConnections()
nmDBusHelper = new QNmDBusHelper(this);
connect(nmDBusHelper, SIGNAL(pathForPropertiesChanged(QString,QMap<QString,QVariant>)),
this,SIGNAL(propertiesChanged(QString,QMap<QString,QVariant>)));
if(dbusConnection.connect(QLatin1String(NM_DBUS_SERVICE),
if (QDBusConnection::systemBus().connect(QLatin1String(NM_DBUS_SERVICE),
d->path,
QLatin1String(NM_DBUS_INTERFACE_ACTIVE_CONNECTION),
QLatin1String("PropertiesChanged"),
@ -902,7 +905,7 @@ QNetworkManagerIp4Config::QNetworkManagerIp4Config( const QString &deviceObjectP
d->connectionInterface = new QDBusInterface(QLatin1String(NM_DBUS_SERVICE),
d->path,
QLatin1String(NM_DBUS_INTERFACE_IP4_CONFIG),
dbusConnection, parent);
QDBusConnection::systemBus(), parent);
if (!d->connectionInterface->isValid()) {
d->valid = false;
return;