mirror of
https://invent.kde.org/system/dolphin
synced 2024-10-28 03:21:56 +00:00
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
This commit is contained in:
parent
45e9fc22d9
commit
588abbf1b6
|
@ -61,9 +61,7 @@ void PlacesItem::setUrl(const QUrl &url)
|
||||||
if (dataValue("url").toUrl() != url) {
|
if (dataValue("url").toUrl() != url) {
|
||||||
delete m_trashDirLister;
|
delete m_trashDirLister;
|
||||||
if (url.scheme() == QLatin1String("trash")) {
|
if (url.scheme() == QLatin1String("trash")) {
|
||||||
QObject::connect(&Trash::instance(), &Trash::emptinessChanged, [this](bool isTrashEmpty){
|
QObject::connect(&Trash::instance(), &Trash::emptinessChanged, m_signalHandler.data(), &PlacesItemSignalHandler::onTrashEmptinessChanged);
|
||||||
setIcon(isTrashEmpty ? QStringLiteral("user-trash") : QStringLiteral("user-trash-full"));
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
setDataValue("url", url);
|
setDataValue("url", url);
|
||||||
|
|
|
@ -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"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -58,6 +58,8 @@ public slots:
|
||||||
|
|
||||||
void onTearDownRequested(const QString& udi);
|
void onTearDownRequested(const QString& udi);
|
||||||
|
|
||||||
|
void onTrashEmptinessChanged(bool isTrashEmpty);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void tearDownExternallyRequested(const QString& udi);
|
void tearDownExternallyRequested(const QString& udi);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue