diff options
author | Robin Burchell <robin.burchell@jollamobile.com> | 2014-07-24 11:04:08 +0000 |
---|---|---|
committer | Robin Burchell <robin+qt@viroteck.net> | 2014-07-26 14:53:52 +0200 |
commit | b68ca43f22c3b34c95515ae086ed689d1893c6f8 (patch) | |
tree | 08b58e3dde20bbf4a99f76518001342258e1b8ab /src | |
parent | ce369e5a7401828d0ad14ce6dd7344828ec5a2fd (diff) |
QUPowerInterface: dead code removal.
changed() signal was only connected to a completely empty handler.
onBattery and getProperty are also unused, only called by the commented-out
bits removed here.
getProperty also had a fun memory leak/efficiency issue (always creating a new
QDBusInterface, which always involves blocking calls on creation,
and never freeing it)
Change-Id: I597f52d152afb2d605698cab48d3b8a916ddf33e
Reviewed-by: Alex Blasche <alexander.blasche@digia.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/systeminfo/linux/qbatteryinfo_upower.cpp | 44 | ||||
-rw-r--r-- | src/systeminfo/linux/qbatteryinfo_upower_p.h | 1 | ||||
-rw-r--r-- | src/systeminfo/linux/qdevicekitservice_linux.cpp | 41 | ||||
-rw-r--r-- | src/systeminfo/linux/qdevicekitservice_linux_p.h | 6 |
4 files changed, 2 insertions, 90 deletions
diff --git a/src/systeminfo/linux/qbatteryinfo_upower.cpp b/src/systeminfo/linux/qbatteryinfo_upower.cpp index 0cd88b02..0d5d4e12 100644 --- a/src/systeminfo/linux/qbatteryinfo_upower.cpp +++ b/src/systeminfo/linux/qbatteryinfo_upower.cpp @@ -353,48 +353,6 @@ float QBatteryInfoPrivate::temperature() return temperature(index); } -void QBatteryInfoPrivate::upowerChanged() -{ -// QUPowerInterface *uPower = qobject_cast<QUPowerInterface*>(sender()); -// if (uPower->onBattery()) { -// chargerTypeChanged(); -// } -//// if (uPowerAvailable()) { -// QBatteryInfo::ChargingState pState = QBatteryInfo::UnknownChargingState; - -// QUPowerInterface power(this); -// foreach (const QDBusObjectPath &objpath, power.enumerateDevices()) { -// QUPowerDeviceInterface powerDevice(objpath.path(),this); -// if (powerDevice.getType() == 2) { -// switch (powerDevice.getState()) { -// case 0: -// break; -// case 1: -// case 5: -// pState = QBatteryInfo::Charging; -// break; -// case 2: -// case 6: -// pState = QBatteryInfo::Discharging; -// break; -// case 4: -// pState = QBatteryInfo::IdleChargingState; -// break; -// default: -// pState = QBatteryInfo::UnknownChargingState; -// }; -// } -// } -// if (!power.onBattery() && pState == QBatteryInfo::UnknownChargingState) -// pState = QBatteryInfo::IdleChargingState; -// if (curPowerState != pState) { -// curPowerState = pState; -// Q_EMIT powerStateChanged(pState); -// } -// return pState; - // } -} - void QBatteryInfoPrivate::upowerDeviceChanged() { QUPowerDeviceInterface *uPowerDevice = qobject_cast<QUPowerDeviceInterface*>(sender()); @@ -539,8 +497,6 @@ void QBatteryInfoPrivate::getBatteryStats() QUPowerInterface *power; power = new QUPowerInterface(this); - connect(power,SIGNAL(changed()), - this,SLOT(upowerChanged())); connect(power,SIGNAL(deviceAdded(QString)), this,SLOT(deviceAdded(QString))); connect(power,SIGNAL(deviceRemoved(QString)), diff --git a/src/systeminfo/linux/qbatteryinfo_upower_p.h b/src/systeminfo/linux/qbatteryinfo_upower_p.h index 2747984c..8ac86ff2 100644 --- a/src/systeminfo/linux/qbatteryinfo_upower_p.h +++ b/src/systeminfo/linux/qbatteryinfo_upower_p.h @@ -123,7 +123,6 @@ protected: QBatteryInfo::ChargingState cState; private Q_SLOTS: void upowerDeviceChanged(); - void upowerChanged(); void uPowerBatteryPropertyChanged(const QString & prop, const QVariant &v); void getBatteryStats(); void deviceAdded(const QString &path); diff --git a/src/systeminfo/linux/qdevicekitservice_linux.cpp b/src/systeminfo/linux/qdevicekitservice_linux.cpp index 15faae13..c7f35075 100644 --- a/src/systeminfo/linux/qdevicekitservice_linux.cpp +++ b/src/systeminfo/linux/qdevicekitservice_linux.cpp @@ -70,34 +70,11 @@ QList<QDBusObjectPath> QUPowerInterface::enumerateDevices() return reply.value(); } -QVariant QUPowerInterface::getProperty(const QString &property) -{ - QVariant var; - QDBusInterface *interface = new QDBusInterface(QStringLiteral(UPOWER_SERVICE), - QStringLiteral(UPOWER_PATH), - QStringLiteral("org.freedesktop.DBus.Properties"), - QDBusConnection::systemBus()); - if (interface && interface->isValid()) { - QDBusReply<QVariant> r = interface->call(QStringLiteral("Get"), QStringLiteral(UPOWER_PATH), property); - var = r.value(); - } - return var; -} - void QUPowerInterface::connectNotify(const QMetaMethod &signal) { - static const QMetaMethod changedSignal = QMetaMethod::fromSignal(&QUPowerInterface::changed); static const QMetaMethod addedSignal = QMetaMethod::fromSignal(&QUPowerInterface::deviceAdded); static const QMetaMethod removedSignal = QMetaMethod::fromSignal(&QUPowerInterface::deviceRemoved); - if (signal == changedSignal) { - if (!connection().connect(QStringLiteral(UPOWER_SERVICE), - QStringLiteral(UPOWER_PATH), - QStringLiteral(UPOWER_SERVICE), - QStringLiteral("Changed"), - this, SIGNAL(changed()))) { - qDebug() << "Error"<<connection().lastError().message(); - } - } + if (signal == addedSignal) { if (!connection().connect(QStringLiteral(UPOWER_SERVICE), QStringLiteral(UPOWER_PATH), @@ -121,18 +98,9 @@ void QUPowerInterface::connectNotify(const QMetaMethod &signal) void QUPowerInterface::disconnectNotify(const QMetaMethod &signal) { - static const QMetaMethod changedSignal = QMetaMethod::fromSignal(&QUPowerInterface::changed); static const QMetaMethod addedSignal = QMetaMethod::fromSignal(&QUPowerInterface::deviceAdded); static const QMetaMethod removedSignal = QMetaMethod::fromSignal(&QUPowerInterface::deviceRemoved); - if (signal == changedSignal) { - if (!connection().disconnect(QStringLiteral(UPOWER_SERVICE), - QStringLiteral(UPOWER_PATH), - QStringLiteral(UPOWER_SERVICE), - QStringLiteral("Changed"), - this, SIGNAL(changed()))) { - qDebug() << "Error"<<connection().lastError().message(); - } - } + if (signal == addedSignal) { if (!connection().disconnect(QStringLiteral(UPOWER_SERVICE), QStringLiteral(UPOWER_PATH), @@ -155,11 +123,6 @@ void QUPowerInterface::disconnectNotify(const QMetaMethod &signal) } -bool QUPowerInterface::onBattery() -{ - return getProperty(QStringLiteral("OnBattery")).toBool(); -} - void QUPowerInterface::onDeviceAdded(const QDBusObjectPath &path) { Q_EMIT deviceAdded(path.path()); diff --git a/src/systeminfo/linux/qdevicekitservice_linux_p.h b/src/systeminfo/linux/qdevicekitservice_linux_p.h index a5407203..daf2c5a7 100644 --- a/src/systeminfo/linux/qdevicekitservice_linux_p.h +++ b/src/systeminfo/linux/qdevicekitservice_linux_p.h @@ -66,12 +66,9 @@ public: QUPowerInterface(QObject *parent = 0); ~QUPowerInterface(); - bool onBattery(); - QList<QDBusObjectPath> enumerateDevices(); Q_SIGNALS: - void changed(); void deviceAdded(const QString &path); void deviceRemoved(const QString &path); @@ -79,9 +76,6 @@ protected: void connectNotify(const QMetaMethod &signal); void disconnectNotify(const QMetaMethod &signal); -private: - QVariant getProperty(const QString &property); - private Q_SLOTS: void onDeviceAdded(const QDBusObjectPath &path); void onDeviceRemoved(const QDBusObjectPath &path); |