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.
This commit is contained in:
Devin Lin 2025-11-03 22:11:57 -05:00
parent a74fa5593b
commit ca79509706
2 changed files with 12 additions and 9 deletions

View file

@ -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<KScreen::GetConfigOperation *>(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();
}
}

View file

@ -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();
});
}