Resolves #753429 - battery plasmoid displays extremely incorrect information

Resolves #766399 - KDE battery monitor not working with new upower
This commit is contained in:
Lukas Tinkl 2011-12-12 21:03:59 +01:00
parent df1ac53552
commit 532963568a
3 changed files with 35 additions and 59 deletions

View File

@ -1,57 +0,0 @@
commit 1b6f332c3c539a45f6ed5a85897ecf8a65fbb216
Author: Lukas Tinkl <lukas@kde.org>
Date: Mon Dec 12 20:03:43 2011 +0100
disconnect the battery signals when it gets removed
see https://bugzilla.redhat.com/show_bug.cgi?id=753429 and
https://bugzilla.redhat.com/show_bug.cgi?id=766399
diff --git a/plasma/generic/dataengines/powermanagement/powermanagementengine.cpp b/plasma/generic/dataengines/powermanagement/powermanagementengine.cpp
index a5344da..2bee9a7 100644
--- a/plasma/generic/dataengines/powermanagement/powermanagementengine.cpp
+++ b/plasma/generic/dataengines/powermanagement/powermanagementengine.cpp
@@ -105,8 +105,7 @@ QStringList PowermanagementEngine::sources() const
bool PowermanagementEngine::sourceRequestEvent(const QString &name)
{
if (name == "Battery") {
- const QList<Solid::Device> listBattery =
- Solid::Device::listFromType(Solid::DeviceInterface::Battery, QString());
+ const QList<Solid::Device> listBattery = Solid::Device::listFromType(Solid::DeviceInterface::Battery);
m_batterySources.clear();
if (listBattery.isEmpty()) {
@@ -160,7 +159,7 @@ bool PowermanagementEngine::sourceRequestEvent(const QString &name)
} else if (name == "AC Adapter") {
bool isPlugged = false;
- const QList<Solid::Device> list_ac = Solid::Device::listFromType(Solid::DeviceInterface::AcAdapter, QString());
+ const QList<Solid::Device> list_ac = Solid::Device::listFromType(Solid::DeviceInterface::AcAdapter);
foreach (Solid::Device device_ac, list_ac) {
Solid::AcAdapter* acadapter = device_ac.as<Solid::AcAdapter>();
isPlugged |= acadapter->isPlugged();
@@ -232,6 +231,11 @@ void PowermanagementEngine::updateAcPlugState(bool newState)
void PowermanagementEngine::deviceRemoved(const QString& udi)
{
if (m_batterySources.contains(udi)) {
+ Solid::Device device(udi);
+ Solid::Battery* battery = device.as<Solid::Battery>();
+ if (battery)
+ battery->disconnect();
+
const QString source = m_batterySources[udi];
m_batterySources.remove(udi);
removeSource(source);
diff --git a/plasma/generic/dataengines/powermanagement/powermanagementengine.h b/plasma/generic/dataengines/powermanagement/powermanagementengine.h
index 4dcc0d9..96ffd45 100644
--- a/plasma/generic/dataengines/powermanagement/powermanagementengine.h
+++ b/plasma/generic/dataengines/powermanagement/powermanagementengine.h
@@ -63,7 +63,7 @@ private:
QStringList m_sources;
- QHash<QString, QString> m_batterySources;
+ QHash<QString, QString> m_batterySources; // <udi, Battery0>
};

View File

@ -0,0 +1,33 @@
commit a8b49bc65afb1d05e7de0148c3116f2f6a1f98de
Author: Aaron Seigo <aseigo@kde.org>
Date: Wed Nov 30 09:17:01 2011 +0100
grab the source name before removing the iterator
the previous fix, which i accidentally reverted while cleaning up this code,
was actually wrong (so in a way i'm glad i caught it): the signal MUST be emitted
AFTER the item is removed from the collection otherwise any code that checks to
see if that source exists will see that it does still exist even though it was
just signaled as being removed. order sometimes really matters :)
CCMAIL:kde@rusu.info
BUG:287795
diff --git a/plasma/dataengine.cpp b/plasma/dataengine.cpp
index 718dfba..364b15e 100644
--- a/plasma/dataengine.cpp
+++ b/plasma/dataengine.cpp
@@ -331,10 +331,11 @@ void DataEngine::removeAllSources()
while (it.hasNext()) {
it.next();
Plasma::DataContainer *s = it.value();
+ const QString &source = it.key();
+ it.remove();
s->disconnect(this);
s->deleteLater();
- emit sourceRemoved(it.key());
- it.remove();
+ emit sourceRemoved(source);
}
}

View File

@ -131,7 +131,7 @@ Patch52: kdelibs-4.7.4-SOLID_UPNP.patch
Patch53: kdelibs-4.7.2-kjs-s390.patch
## upstream
Patch100: kdelibs-4.7.5-batteryplasmoid.patch
Patch100: kdelibs-4.7.5-dataengine-source-removed.patch
## security fix
# Not Upstreamed? why not ? -- Rex
@ -323,7 +323,7 @@ sed -i -e "s|@@VERSION_RELEASE@@|%{version}-%{release}|" kio/kio/kprotocolmanage
%endif
# upstream patches
%patch100 -p1 -b .batteryplasmoid
%patch100 -p1 -b .dataengine-source-removed
# upstreamable patches
%patch50 -p1 -b .knewstuff2_gpg2