mirror of
https://invent.kde.org/system/dolphin
synced 2024-10-28 03:21:56 +00:00
Summary: Fixes crash when hiding devices
Summary: Fixes crash when hiding devices. The crash is caused by KStandardItem::setDataValue which calls the KStandardItemModel::onItemChanged function, and that function will delete the KStandardItem if the data value being set is the hidden attribute being set to true. To fix this KStandardItem now derives QObject so that we can use deleteLater. Test Plan: Right click a device in the places panel and select hide Right click the places panel and select show hidden Right click the hidden device and select show Right click the same device and select hide BUG: 403064 Reviewers: #dolphin, elvisangelaccio Reviewed By: #dolphin, elvisangelaccio Subscribers: kfm-devel Tags: #dolphin Differential Revision: https://phabricator.kde.org/D21050
This commit is contained in:
parent
2fac50f5f5
commit
78540e4921
|
@ -21,16 +21,14 @@
|
|||
#include "kstandarditemmodel.h"
|
||||
|
||||
KStandardItem::KStandardItem(KStandardItem* parent) :
|
||||
m_parent(parent),
|
||||
m_children(),
|
||||
QObject(parent),
|
||||
m_model(nullptr),
|
||||
m_data()
|
||||
{
|
||||
}
|
||||
|
||||
KStandardItem::KStandardItem(const QString& text, KStandardItem* parent) :
|
||||
m_parent(parent),
|
||||
m_children(),
|
||||
QObject(parent),
|
||||
m_model(nullptr),
|
||||
m_data()
|
||||
{
|
||||
|
@ -38,8 +36,7 @@ KStandardItem::KStandardItem(const QString& text, KStandardItem* parent) :
|
|||
}
|
||||
|
||||
KStandardItem::KStandardItem(const QString& icon, const QString& text, KStandardItem* parent) :
|
||||
m_parent(parent),
|
||||
m_children(),
|
||||
QObject(parent),
|
||||
m_model(nullptr),
|
||||
m_data()
|
||||
{
|
||||
|
@ -47,14 +44,6 @@ KStandardItem::KStandardItem(const QString& icon, const QString& text, KStandard
|
|||
setText(text);
|
||||
}
|
||||
|
||||
KStandardItem::KStandardItem(const KStandardItem& item) :
|
||||
m_parent(item.m_parent),
|
||||
m_children(item.m_children),
|
||||
m_model(item.m_model),
|
||||
m_data(item.m_data)
|
||||
{
|
||||
}
|
||||
|
||||
KStandardItem::~KStandardItem()
|
||||
{
|
||||
}
|
||||
|
@ -123,17 +112,6 @@ QVariant KStandardItem::dataValue(const QByteArray& role) const
|
|||
return m_data[role];
|
||||
}
|
||||
|
||||
void KStandardItem::setParent(KStandardItem* parent)
|
||||
{
|
||||
// TODO: not implemented yet
|
||||
m_parent = parent;
|
||||
}
|
||||
|
||||
KStandardItem* KStandardItem::parent() const
|
||||
{
|
||||
return m_parent;
|
||||
}
|
||||
|
||||
void KStandardItem::setData(const QHash<QByteArray, QVariant>& values)
|
||||
{
|
||||
const QHash<QByteArray, QVariant> previous = m_data;
|
||||
|
@ -146,11 +124,6 @@ QHash<QByteArray, QVariant> KStandardItem::data() const
|
|||
return m_data;
|
||||
}
|
||||
|
||||
QList<KStandardItem*> KStandardItem::children() const
|
||||
{
|
||||
return m_children;
|
||||
}
|
||||
|
||||
void KStandardItem::onDataValueChanged(const QByteArray& role,
|
||||
const QVariant& current,
|
||||
const QVariant& previous)
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
|
||||
#include <QByteArray>
|
||||
#include <QHash>
|
||||
#include <QList>
|
||||
#include <QObject>
|
||||
#include <QVariant>
|
||||
|
||||
class KStandardItemModel;
|
||||
|
@ -36,14 +36,13 @@ class KStandardItemModel;
|
|||
* used roles. It is possible to assign values for custom
|
||||
* roles by using setDataValue().
|
||||
*/
|
||||
class DOLPHIN_EXPORT KStandardItem
|
||||
class DOLPHIN_EXPORT KStandardItem : public QObject
|
||||
{
|
||||
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit KStandardItem(KStandardItem* parent = nullptr);
|
||||
explicit KStandardItem(const QString& text, KStandardItem* parent = nullptr);
|
||||
KStandardItem(const QString& icon, const QString& text, KStandardItem* parent = nullptr);
|
||||
KStandardItem(const KStandardItem& item);
|
||||
virtual ~KStandardItem();
|
||||
|
||||
/**
|
||||
|
@ -70,14 +69,9 @@ public:
|
|||
void setDataValue(const QByteArray& role, const QVariant& value);
|
||||
QVariant dataValue(const QByteArray& role) const;
|
||||
|
||||
void setParent(KStandardItem* parent);
|
||||
KStandardItem* parent() const;
|
||||
|
||||
void setData(const QHash<QByteArray, QVariant>& values);
|
||||
QHash<QByteArray, QVariant> data() const;
|
||||
|
||||
QList<KStandardItem*> children() const;
|
||||
|
||||
protected:
|
||||
virtual void onDataValueChanged(const QByteArray& role,
|
||||
const QVariant& current,
|
||||
|
@ -87,8 +81,6 @@ protected:
|
|||
const QHash<QByteArray, QVariant>& previous);
|
||||
|
||||
private:
|
||||
KStandardItem* m_parent;
|
||||
QList<KStandardItem*> m_children;
|
||||
KStandardItemModel* m_model;
|
||||
|
||||
QHash<QByteArray, QVariant> m_data;
|
||||
|
|
|
@ -112,7 +112,7 @@ void KStandardItemModel::removeItem(int index)
|
|||
|
||||
onItemRemoved(index, item);
|
||||
|
||||
delete item;
|
||||
item->deleteLater();
|
||||
item = nullptr;
|
||||
|
||||
emit itemsRemoved(KItemRangeList() << KItemRange(index, 1));
|
||||
|
|
Loading…
Reference in a new issue