[SCM] kdeconnect packaging branch, master, updated. debian/0.9g-1-1183-g9d69498
Maximiliano Curia
maxy at moszumanska.debian.org
Fri Oct 14 14:27:33 UTC 2016
Gitweb-URL: http://git.debian.org/?p=pkg-kde/kde-extras/kdeconnect.git;a=commitdiff;h=c8a9796
The following commit has been merged in the master branch:
commit c8a979609395e453c8a19fe569cc6b2ebe15e375
Author: Àlex Fiestas <afiestas at kde.org>
Date: Tue Apr 15 20:14:22 2014 +0200
Avoid doing qobject_cast on an already destroyed QObject
QObject::destroyed is emitted from the QObject destructor, because of
that the object that inherit from it (in this case DeviceLink) will not
exist anymore, hence we can't cast to it.
So we are saving the needed information in an QObject property so we
do not have to do any cast.
---
kded/backends/devicelink.cpp | 3 +++
kded/backends/lan/lanlinkprovider.cpp | 10 +++-------
kded/backends/lan/lanlinkprovider.h | 2 +-
3 files changed, 7 insertions(+), 8 deletions(-)
diff --git a/kded/backends/devicelink.cpp b/kded/backends/devicelink.cpp
index aaeb289..1a61a31 100644
--- a/kded/backends/devicelink.cpp
+++ b/kded/backends/devicelink.cpp
@@ -26,6 +26,9 @@ DeviceLink::DeviceLink(const QString& deviceId, LinkProvider* parent)
, mDeviceId(deviceId)
, mLinkProvider(parent)
{
+ Q_ASSERT(!deviceId.isEmpty());
+
+ setProperty("deviceId", deviceId);
//gcc complains if we don't add something to compile on a class with virtual functions
}
diff --git a/kded/backends/lan/lanlinkprovider.cpp b/kded/backends/lan/lanlinkprovider.cpp
index ca3ca0c..2369dc4 100644
--- a/kded/backends/lan/lanlinkprovider.cpp
+++ b/kded/backends/lan/lanlinkprovider.cpp
@@ -280,16 +280,12 @@ void LanLinkProvider::dataReceived()
disconnect(socket,SIGNAL(readyRead()),this,SLOT(dataReceived()));
}
-void LanLinkProvider::deviceLinkDestroyed(QObject* uncastedDeviceLink)
+void LanLinkProvider::deviceLinkDestroyed(QObject* destroyedDeviceLink)
{
//kDebug(kdeconnect_kded()) << "deviceLinkDestroyed";
-
- DeviceLink* deviceLink = qobject_cast<DeviceLink*>(uncastedDeviceLink);
- Q_ASSERT(deviceLink);
-
- const QString& id = deviceLink->deviceId();
+ const QString id = destroyedDeviceLink->property("deviceId").toString();
QMap< QString, DeviceLink* >::iterator oldLinkIterator = mLinks.find(id);
- if (oldLinkIterator != mLinks.end() && oldLinkIterator.value() == deviceLink) {
+ if (oldLinkIterator != mLinks.end() && oldLinkIterator.value() == destroyedDeviceLink) {
mLinks.erase(oldLinkIterator);
}
diff --git a/kded/backends/lan/lanlinkprovider.h b/kded/backends/lan/lanlinkprovider.h
index 2153a5f..1b9af8e 100644
--- a/kded/backends/lan/lanlinkprovider.h
+++ b/kded/backends/lan/lanlinkprovider.h
@@ -51,7 +51,7 @@ private Q_SLOTS:
void newUdpConnection();
void newConnection();
void dataReceived();
- void deviceLinkDestroyed(QObject*);
+ void deviceLinkDestroyed(QObject* destroyedDeviceLink);
private:
static void configureSocket(QTcpSocket* socket);
--
kdeconnect packaging
More information about the pkg-kde-commits
mailing list