summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Edmundson <kde@davidedmundson.co.uk>2017-02-10 09:59:31 (GMT)
committerDavid Edmundson <kde@davidedmundson.co.uk>2017-02-10 12:59:32 (GMT)
commit2601fa10725284feb5bcc78006250c0aa92f92dd (patch)
tree11b198a5dd880a6687099e164ceec48b965c5752
parent951b0b1f7ece055419c82f45e380f8cd83faa336 (diff)
Fix crash in Screen Locker KCM on 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 exposed properties go through a proxy QObject. CCBUG: 373628 Test Plan: Pressing back whilst in the screenlocker KCM used to crash every time, now it doesn't. Also changed the wallpaper type, new settings appeared, I went from flat image to a specific wallpaper, and then locked my screen. Reviewers: #plasma, graesslin Reviewed By: #plasma, graesslin Subscribers: plasma-devel Tags: #plasma Differential Revision: https://phabricator.kde.org/D4535
-rw-r--r--kcm/kcm.cpp7
-rw-r--r--kcm/kcm.h33
2 files changed, 36 insertions, 4 deletions
diff --git a/kcm/kcm.cpp b/kcm/kcm.cpp
index aa8cf05..709b692 100644
--- a/kcm/kcm.cpp
+++ b/kcm/kcm.cpp
@@ -87,7 +87,12 @@ ScreenLockerKcm::ScreenLockerKcm(QWidget *parent, const QVariantList &args)
m_ui->wallpaperCombo->installEventFilter(this);
m_ui->wallpaperConfigWidget->setClearColor(m_ui->palette().color(QPalette::Active, QPalette::Window));
- m_ui->wallpaperConfigWidget->rootContext()->setContextProperty("configDialog", this);
+ auto proxy = new ScreenLockerProxy(this);
+ m_ui->wallpaperConfigWidget->rootContext()->setContextProperty("configDialog", proxy);
+
+ connect(this, &ScreenLockerKcm::wallpaperConfigurationChanged, proxy, &ScreenLockerProxy::wallpaperConfigurationChanged);
+ connect(this, &ScreenLockerKcm::currentWallpaperChanged, proxy, &ScreenLockerProxy::currentWallpaperChanged);
+
m_ui->wallpaperConfigWidget->setSource(QUrl(QStringLiteral("qrc:/kscreenlocker-kcm-resources/config.qml")));
connect(m_ui->wallpaperConfigWidget->rootObject(), SIGNAL(configurationChanged()), this, SLOT(changed()));
diff --git a/kcm/kcm.h b/kcm/kcm.h
index 8080209..096d17b 100644
--- a/kcm/kcm.h
+++ b/kcm/kcm.h
@@ -37,12 +37,10 @@ namespace KDeclarative
class ConfigPropertyMap;
}
+
class ScreenLockerKcm : public KCModule
{
Q_OBJECT
- Q_PROPERTY(KDeclarative::ConfigPropertyMap *wallpaperConfiguration READ wallpaperConfiguration NOTIFY wallpaperConfigurationChanged)
- Q_PROPERTY(QString currentWallpaper READ currentWallpaper NOTIFY currentWallpaperChanged)
-
public:
enum Roles {
PluginNameRole = Qt::UserRole +1,
@@ -76,3 +74,32 @@ private:
ScreenLockerKcmForm *m_ui;
ScreenLocker::WallpaperIntegration *m_wallpaperIntegration = nullptr;
};
+
+//see https://bugreports.qt.io/browse/QTBUG-57714, don't expose a QWidget as a context property
+class ScreenLockerProxy : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(KDeclarative::ConfigPropertyMap *wallpaperConfiguration READ wallpaperConfiguration NOTIFY wallpaperConfigurationChanged)
+ Q_PROPERTY(QString currentWallpaper READ currentWallpaper NOTIFY currentWallpaperChanged)
+public:
+ ScreenLockerProxy(ScreenLockerKcm *parent) :
+ QObject(parent),
+ q(parent)
+ {
+ }
+
+ KDeclarative::ConfigPropertyMap *wallpaperConfiguration() const {
+ return q->wallpaperConfiguration();
+ }
+
+ QString currentWallpaper() const {
+ return q->currentWallpaper();
+ }
+
+signals:
+ void wallpaperConfigurationChanged();
+ void currentWallpaperChanged();
+
+private:
+ ScreenLockerKcm* q;
+};