quicksettings: Add kscreen usage null checks

There are cases where the config is nullptr, ensure we're checking for
this.
This commit is contained in:
Devin Lin 2025-10-07 20:30:48 -04:00
parent 0545ee5e65
commit 0da9ca21f8
2 changed files with 12 additions and 0 deletions

View file

@ -15,11 +15,18 @@ KScreenOSDUtil::KScreenOSDUtil(QObject *parent)
: QObject{parent} : QObject{parent}
{ {
connect(KScreen::ConfigMonitor::instance(), &KScreen::ConfigMonitor::configurationChanged, this, [this]() { connect(KScreen::ConfigMonitor::instance(), &KScreen::ConfigMonitor::configurationChanged, this, [this]() {
if (!m_config) {
return;
}
setOutputs(m_config->outputs().size()); setOutputs(m_config->outputs().size());
}); });
connect(new KScreen::GetConfigOperation(), &KScreen::GetConfigOperation::finished, this, [this](auto *op) { connect(new KScreen::GetConfigOperation(), &KScreen::GetConfigOperation::finished, this, [this](auto *op) {
m_config = qobject_cast<KScreen::GetConfigOperation *>(op)->config(); m_config = qobject_cast<KScreen::GetConfigOperation *>(op)->config();
if (!m_config) {
qDebug() << "kscreenosdutil: Unable to obtain kscreen config";
return;
}
KScreen::ConfigMonitor::instance()->addConfig(m_config); KScreen::ConfigMonitor::instance()->addConfig(m_config);
setOutputs(m_config->outputs().size()); setOutputs(m_config->outputs().size());
}); });

View file

@ -28,6 +28,11 @@ ScreenRotationUtil::ScreenRotationUtil(QObject *parent)
connect(new KScreen::GetConfigOperation(), &KScreen::GetConfigOperation::finished, this, [this](auto *op) { connect(new KScreen::GetConfigOperation(), &KScreen::GetConfigOperation::finished, this, [this](auto *op) {
m_config = qobject_cast<KScreen::GetConfigOperation *>(op)->config(); m_config = qobject_cast<KScreen::GetConfigOperation *>(op)->config();
if (!m_config) {
qDebug() << "screenrotationutil: Unable to obtain kscreen config";
return;
}
KScreen::ConfigMonitor::instance()->addConfig(m_config); KScreen::ConfigMonitor::instance()->addConfig(m_config);
// update all screens with event connect // update all screens with event connect