From ca79509706c992b6872e9c9080a72b74eb477cc8 Mon Sep 17 00:00:00 2001 From: Devin Lin Date: Mon, 3 Nov 2025 22:11:57 -0500 Subject: [PATCH] kscreen: Make async calls and nullptr check Don't block plasmashell when doing kscreen calls (make them async). Also add a nullptr check to rotationplugin, which potentially could be a fix for crashes on the PinePhone. --- components/rotationplugin/rotationutil.cpp | 15 +++++++++------ .../screenrotation/screenrotationutil.cpp | 6 +++--- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/components/rotationplugin/rotationutil.cpp b/components/rotationplugin/rotationutil.cpp index 51d9ccb6..c1ba46ee 100644 --- a/components/rotationplugin/rotationutil.cpp +++ b/components/rotationplugin/rotationutil.cpp @@ -51,11 +51,14 @@ RotationUtil::Rotation mapRotation(KScreen::Output::Rotation rotation) } RotationUtil::RotationUtil(QObject *parent) -: QObject{parent} -, m_sensor{new QOrientationSensor(this)} + : QObject{parent} + , m_sensor{new QOrientationSensor(this)} { connect(new KScreen::GetConfigOperation(), &KScreen::GetConfigOperation::finished, this, [this](auto *op) { m_config = qobject_cast(op)->config(); + if (!m_config) { + return; + } KScreen::ConfigMonitor::instance()->addConfig(m_config); // update all screens with event connect @@ -95,9 +98,9 @@ void RotationUtil::rotateToSuggestedRotation() } auto setop = new KScreen::SetConfigOperation(m_config, this); - setop->exec(); - - updateShowRotationButton(); + connect(setop, &KScreen::SetConfigOperation::finished, this, [this]() { + updateShowRotationButton(); + }); } bool RotationUtil::showRotationButton() const @@ -155,4 +158,4 @@ void RotationUtil::updateShowRotationButton() m_showRotationButton = false; Q_EMIT rotationChanged(); -} \ No newline at end of file +} diff --git a/quicksettings/screenrotation/screenrotationutil.cpp b/quicksettings/screenrotation/screenrotationutil.cpp index 3c5c8f3b..4e5ae0e2 100644 --- a/quicksettings/screenrotation/screenrotationutil.cpp +++ b/quicksettings/screenrotation/screenrotationutil.cpp @@ -101,7 +101,7 @@ void ScreenRotationUtil::actuallySetAutoScreenRotationEnabled(bool value) } auto setop = new KScreen::SetConfigOperation(m_config, this); - setop->exec(); - - Q_EMIT autoScreenRotationEnabledChanged(); + connect(setop, &KScreen::SetConfigOperation::finished, this, [this]() { + Q_EMIT autoScreenRotationEnabledChanged(); + }); }