summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Edmundson <kde@davidedmundson.co.uk>2017-02-10 09:52:48 (GMT)
committerDavid Edmundson <kde@davidedmundson.co.uk>2017-02-10 13:01:09 (GMT)
commit70d2fb2378d636ef6d052da08417b27c99182fb0 (patch)
treed3fb8242c3542a5520b4d02febe0fab5d0c8c3dd
parent5a87fa3f92cfc29944b8dc66c2320e3062b532ee (diff)
Avoid a crash on Kwin decoration KCM teardown
Summary: As described in https://bugreports.qt.io/browse/QTBUG-57714 exposing a QWidget as a context item to QtQuick can crash. Especially as the engine's context property gets deleted whilst deleting the parent item. This patch reworks the code so that the models are exposed to QML directly rather than going through a QWidget. CCBUG: 373628 Test Plan: Pressing back whilst in the decoration KCM used to crash every time, now it doesn't. I still have the buttons. Reviewers: #plasma, graesslin Reviewed By: #plasma, graesslin Subscribers: graesslin, cfeck, plasma-devel Tags: #plasma Differential Revision: https://phabricator.kde.org/D4533
-rw-r--r--kcmkwin/kwindecoration/kcm.cpp20
-rw-r--r--kcmkwin/kwindecoration/kcm.h7
-rw-r--r--kcmkwin/kwindecoration/qml/Buttons.qml6
3 files changed, 7 insertions, 26 deletions
diff --git a/kcmkwin/kwindecoration/kcm.cpp b/kcmkwin/kwindecoration/kcm.cpp
index 035bc8b..231b3e6 100644
--- a/kcmkwin/kwindecoration/kcm.cpp
+++ b/kcmkwin/kwindecoration/kcm.cpp
@@ -100,7 +100,10 @@ ConfigurationModule::ConfigurationModule(QWidget *parent, const QVariantList &ar
m_quickView->rootContext()->setContextProperty(QStringLiteral("decorationsModel"), m_proxyModel);
updateColors();
m_quickView->rootContext()->setContextProperty("_borderSizesIndex", 3); // 3 is normal
- m_quickView->rootContext()->setContextProperty("configurationModule", this);
+ m_quickView->rootContext()->setContextProperty("leftButtons", m_leftButtons);
+ m_quickView->rootContext()->setContextProperty("rightButtons", m_rightButtons);
+ m_quickView->rootContext()->setContextProperty("availableButtons", m_availableButtons);
+
m_quickView->rootContext()->setContextProperty("titleFont", QFontDatabase::systemFont(QFontDatabase::TitleFont));
m_quickView->setResizeMode(QQuickView::SizeRootObjectToView);
m_quickView->setSource(QUrl::fromLocalFile(QStandardPaths::locate(QStandardPaths::GenericDataLocation, QStringLiteral("kwin/kcm_kwindecoration/main.qml"))));
@@ -406,21 +409,6 @@ void ConfigurationModule::showKNS(const QString &config)
delete downloadDialog;
}
-QAbstractItemModel *ConfigurationModule::leftButtons() const
-{
- return m_leftButtons;
-}
-
-QAbstractItemModel *ConfigurationModule::rightButtons() const
-{
- return m_rightButtons;
-}
-
-QAbstractItemModel *ConfigurationModule::availableButtons() const
-{
- return m_availableButtons;
-}
-
bool ConfigurationModule::eventFilter(QObject *watched, QEvent *e)
{
if (watched != m_ui) {
diff --git a/kcmkwin/kwindecoration/kcm.h b/kcmkwin/kwindecoration/kcm.h
index 1d7ee73..99fa431 100644
--- a/kcmkwin/kwindecoration/kcm.h
+++ b/kcmkwin/kwindecoration/kcm.h
@@ -47,17 +47,10 @@ public:
class ConfigurationModule : public KCModule
{
Q_OBJECT
- Q_PROPERTY(QAbstractItemModel* leftButtons READ leftButtons CONSTANT)
- Q_PROPERTY(QAbstractItemModel* rightButtons READ rightButtons CONSTANT)
- Q_PROPERTY(QAbstractItemModel* availableButtons READ availableButtons CONSTANT)
public:
explicit ConfigurationModule(QWidget *parent = nullptr, const QVariantList &args = QVariantList());
virtual ~ConfigurationModule();
- QAbstractItemModel *leftButtons() const;
- QAbstractItemModel *rightButtons() const;
- QAbstractItemModel *availableButtons() const;
-
bool eventFilter(QObject *watched, QEvent *e) override;
public Q_SLOTS:
diff --git a/kcmkwin/kwindecoration/qml/Buttons.qml b/kcmkwin/kwindecoration/qml/Buttons.qml
index 2e64873..64ab0f9 100644
--- a/kcmkwin/kwindecoration/qml/Buttons.qml
+++ b/kcmkwin/kwindecoration/qml/Buttons.qml
@@ -63,7 +63,7 @@ Item {
id: leftButtonsView
anchors.left: parent.left;
height: buttonPreviewRow.height
- model: configurationModule.leftButtons
+ model: leftButtons
key: "decoButtonLeft"
}
Item {
@@ -81,7 +81,7 @@ Item {
id: rightButtonsView
anchors.right: parent.right;
height: buttonPreviewRow.height
- model: configurationModule.rightButtons
+ model: rightButtons
key: "decoButtonRight"
}
DropArea {
@@ -144,7 +144,7 @@ Item {
GridView {
id: availableGrid
Layout.fillWidth: true
- model: configurationModule.availableButtons
+ model: availableButtons
interactive: false
cellWidth: iconLabel.implicitWidth
cellHeight: units.iconSizes.small + iCannotBelieveIDoThis.implicitHeight + 4*units.smallSpacing