┌   ┐
54
└   ┘

summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorElvis Angelaccio <[email protected]>2018-06-03 13:08:51 +0200
committerElvis Angelaccio <[email protected]>2018-06-03 13:08:51 +0200
commit588abbf1b6994245d987c0d07c2b074cb76fc034 (patch)
treea38c305e908f04e3dd95f961544af667b597d902
parent45e9fc22d9364cd76caa7bc9f835957295d8ea79 (diff)
Fix crash in PlacesItem::setUrl()
Connections to lambda slots without context/receiver argument can lead to crashes, because if the receiver is deleted Qt won't delete the connection as it normally would when the receiver is specified. This patch moves the slot from the lambda in PlacesItem (which is not a QObject) to PlacesItemSignalHandler. This fixes the `dolphinmainwindowtest` crash we currently have on master, and should also fix bug #394507 which has the very same stacktrace. BUG: 394507 FIXED-IN: 18.04.2
-rw-r--r--src/panels/places/placesitem.cpp4
-rw-r--r--src/panels/places/placesitemsignalhandler.cpp7
-rw-r--r--src/panels/places/placesitemsignalhandler.h2
3 files changed, 10 insertions, 3 deletions
diff --git a/src/panels/places/placesitem.cpp b/src/panels/places/placesitem.cpp
index ee168e4a3..10b87086c 100644
--- a/src/panels/places/placesitem.cpp
+++ b/src/panels/places/placesitem.cpp
@@ -61,9 +61,7 @@ void PlacesItem::setUrl(const QUrl &url)
if (dataValue("url").toUrl() != url) {
delete m_trashDirLister;
if (url.scheme() == QLatin1String("trash")) {
- QObject::connect(&Trash::instance(), &Trash::emptinessChanged, [this](bool isTrashEmpty){
- setIcon(isTrashEmpty ? QStringLiteral("user-trash") : QStringLiteral("user-trash-full"));
- });
+ QObject::connect(&Trash::instance(), &Trash::emptinessChanged, m_signalHandler.data(), &PlacesItemSignalHandler::onTrashEmptinessChanged);
}
setDataValue("url", url);
diff --git a/src/panels/places/placesitemsignalhandler.cpp b/src/panels/places/placesitemsignalhandler.cpp
index c85c8336e..b313f838f 100644
--- a/src/panels/places/placesitemsignalhandler.cpp
+++ b/src/panels/places/placesitemsignalhandler.cpp
@@ -51,3 +51,10 @@ void PlacesItemSignalHandler::onTearDownRequested(const QString& udi)
}
}
+void PlacesItemSignalHandler::onTrashEmptinessChanged(bool isTrashEmpty)
+{
+ if (m_item) {
+ m_item->setIcon(isTrashEmpty ? QStringLiteral("user-trash") : QStringLiteral("user-trash-full"));
+ }
+}
+
diff --git a/src/panels/places/placesitemsignalhandler.h b/src/panels/places/placesitemsignalhandler.h
index 6158d7180..1d0cf9ccd 100644
--- a/src/panels/places/placesitemsignalhandler.h
+++ b/src/panels/places/placesitemsignalhandler.h
@@ -58,6 +58,8 @@ public slots:
void onTearDownRequested(const QString& udi);
+ void onTrashEmptinessChanged(bool isTrashEmpty);
+
signals:
void tearDownExternallyRequested(const QString& udi);