You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
kwin/0004-kcmkwin-deco-Delay-del...

201 lines
7.3 KiB

From 484e4be7f66b6f6d4021f6adb4f43531df9649c5 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Martin=20Gr=C3=A4=C3=9Flin?= <mgraesslin@kde.org>
Date: Tue, 20 Oct 2015 14:22:05 +0200
Subject: [PATCH 4/6] [kcmkwin/deco] Delay deleting of PreviewBridge
Our decoration is deleted using deleteLater() and that might cause access
to the bridge. Given that we also need to deleteLater() the
PreviewBridge.
To do so the PreviewBridge is no longer directly exposed to QML, but
in a wrapper object which holds the bridge as only element.
BUG: 344278
FIXED-IN: 5.4.3
REVIEW: 125724
---
.../kwindecoration/declarative-plugin/plugin.cpp | 3 +-
.../declarative-plugin/previewbridge.cpp | 14 ++++++++
.../declarative-plugin/previewbridge.h | 42 ++++++++++++++++++++++
kcmkwin/kwindecoration/qml/ButtonGroup.qml | 2 +-
kcmkwin/kwindecoration/qml/Buttons.qml | 4 +--
kcmkwin/kwindecoration/qml/Previews.qml | 8 ++---
6 files changed, 65 insertions(+), 8 deletions(-)
diff --git a/kcmkwin/kwindecoration/declarative-plugin/plugin.cpp b/kcmkwin/kwindecoration/declarative-plugin/plugin.cpp
index 3df73c5..690aa13 100644
--- a/kcmkwin/kwindecoration/declarative-plugin/plugin.cpp
+++ b/kcmkwin/kwindecoration/declarative-plugin/plugin.cpp
@@ -38,7 +38,7 @@ namespace Preview
void Plugin::registerTypes(const char *uri)
{
Q_ASSERT(QLatin1String(uri) == QLatin1String("org.kde.kwin.private.kdecoration"));
- qmlRegisterType<KDecoration2::Preview::PreviewBridge>(uri, 1, 0, "Bridge");
+ qmlRegisterType<KDecoration2::Preview::BridgeItem>(uri, 1, 0, "Bridge");
qmlRegisterType<KDecoration2::Preview::Settings>(uri, 1, 0, "Settings");
qmlRegisterType<KDecoration2::Preview::PreviewItem>(uri, 1, 0, "Decoration");
qmlRegisterType<KDecoration2::Preview::PreviewButtonItem>(uri, 1, 0, "Button");
@@ -46,6 +46,7 @@ void Plugin::registerTypes(const char *uri)
qmlRegisterType<KDecoration2::Preview::PreviewClient>();
qmlRegisterType<KDecoration2::Decoration>();
qmlRegisterType<KDecoration2::DecorationShadow>();
+ qmlRegisterType<KDecoration2::Preview::PreviewBridge>();
}
}
diff --git a/kcmkwin/kwindecoration/declarative-plugin/previewbridge.cpp b/kcmkwin/kwindecoration/declarative-plugin/previewbridge.cpp
index d6d1ef5..7d201f3 100644
--- a/kcmkwin/kwindecoration/declarative-plugin/previewbridge.cpp
+++ b/kcmkwin/kwindecoration/declarative-plugin/previewbridge.cpp
@@ -237,5 +237,19 @@ void PreviewBridge::configure()
dialog.exec();
}
+BridgeItem::BridgeItem(QObject *parent)
+ : QObject(parent)
+ , m_bridge(new PreviewBridge())
+{
+ connect(m_bridge, &PreviewBridge::themeChanged, this, &BridgeItem::themeChanged);
+ connect(m_bridge, &PreviewBridge::pluginChanged, this, &BridgeItem::pluginChanged);
+ connect(m_bridge, &PreviewBridge::validChanged, this, &BridgeItem::validChanged);
+}
+
+BridgeItem::~BridgeItem()
+{
+ m_bridge->deleteLater();
+}
+
}
}
diff --git a/kcmkwin/kwindecoration/declarative-plugin/previewbridge.h b/kcmkwin/kwindecoration/declarative-plugin/previewbridge.h
index fc3c9e0..fe366eb 100644
--- a/kcmkwin/kwindecoration/declarative-plugin/previewbridge.h
+++ b/kcmkwin/kwindecoration/declarative-plugin/previewbridge.h
@@ -89,6 +89,48 @@ private:
bool m_valid;
};
+class BridgeItem : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(QString plugin READ plugin WRITE setPlugin NOTIFY pluginChanged)
+ Q_PROPERTY(QString theme READ theme WRITE setTheme NOTIFY themeChanged)
+ Q_PROPERTY(bool valid READ isValid NOTIFY validChanged)
+ Q_PROPERTY(KDecoration2::Preview::PreviewBridge *bridge READ bridge CONSTANT)
+
+public:
+ explicit BridgeItem(QObject *parent = nullptr);
+ virtual ~BridgeItem();
+
+ void setPlugin(const QString &plugin) {
+ m_bridge->setPlugin(plugin);
+ }
+ QString plugin() const {
+ return m_bridge->plugin();
+ }
+ void setTheme(const QString &theme) {
+ m_bridge->setTheme(theme);
+ }
+ QString theme() const {
+ return m_bridge->theme();
+ }
+ bool isValid() const {
+ return m_bridge->isValid();
+ }
+
+ PreviewBridge *bridge() const {
+ return m_bridge;
+ }
+
+Q_SIGNALS:
+ void pluginChanged();
+ void themeChanged();
+ void validChanged();
+
+private:
+ PreviewBridge *m_bridge;
+
+};
+
}
}
diff --git a/kcmkwin/kwindecoration/qml/ButtonGroup.qml b/kcmkwin/kwindecoration/qml/ButtonGroup.qml
index 1548732..a64f446 100644
--- a/kcmkwin/kwindecoration/qml/ButtonGroup.qml
+++ b/kcmkwin/kwindecoration/qml/ButtonGroup.qml
@@ -37,7 +37,7 @@ ListView {
id: button
property int itemIndex: index
property var buttonsModel: parent.ListView.view.model
- bridge: bridgeItem
+ bridge: bridgeItem.bridge
settings: settingsItem
type: model["button"]
anchors.fill: Drag.active ? undefined : parent
diff --git a/kcmkwin/kwindecoration/qml/Buttons.qml b/kcmkwin/kwindecoration/qml/Buttons.qml
index 7c6997c..33b6f64 100644
--- a/kcmkwin/kwindecoration/qml/Buttons.qml
+++ b/kcmkwin/kwindecoration/qml/Buttons.qml
@@ -32,7 +32,7 @@ Item {
}
KDecoration.Settings {
id: settingsItem
- bridge: bridgeItem
+ bridge: bridgeItem.bridge
}
Rectangle {
anchors.fill: parent
@@ -153,7 +153,7 @@ Item {
KDecoration.Button {
id: availableButton
anchors.centerIn: Drag.active ? undefined : parent
- bridge: bridgeItem
+ bridge: bridgeItem.bridge
settings: settingsItem
type: model["button"]
width: units.iconSizes.small
diff --git a/kcmkwin/kwindecoration/qml/Previews.qml b/kcmkwin/kwindecoration/qml/Previews.qml
index eabc666..bc8c56a 100644
--- a/kcmkwin/kwindecoration/qml/Previews.qml
+++ b/kcmkwin/kwindecoration/qml/Previews.qml
@@ -52,7 +52,7 @@ ScrollView {
}
KDecoration.Settings {
id: settingsItem
- bridge: bridgeItem
+ bridge: bridgeItem.bridge
borderSizesIndex: listView.borderSizesIndex
}
MouseArea {
@@ -67,7 +67,7 @@ ScrollView {
Item {
KDecoration.Decoration {
id: inactivePreview
- bridge: bridgeItem
+ bridge: bridgeItem.bridge
settings: settingsItem
anchors.fill: parent
Component.onCompleted: {
@@ -81,7 +81,7 @@ ScrollView {
}
KDecoration.Decoration {
id: activePreview
- bridge: bridgeItem
+ bridge: bridgeItem.bridge
settings: settingsItem
anchors.fill: parent
Component.onCompleted: {
@@ -107,7 +107,7 @@ ScrollView {
id: configureButton
enabled: model["configureable"]
iconName: "configure"
- onClicked: bridgeItem.configure()
+ onClicked: bridgeItem.bridge.configure()
}
}
}
--
1.9.3