mirror of
https://invent.kde.org/marcoa/shift-shell.git
synced 2026-04-29 15:03:09 +00:00
quicksettings/screenrotation: Don't call rotate in signal handler
This is a workaround for https://invent.kde.org/plasma/plasma-mobile/-/issues/405, where if the caller gets deleted by the screen rotation, the entire shell crashes. Eventually, we need to implement https://invent.kde.org/plasma/plasma-mobile/-/issues/406 to reduce the amount of oddities we have from recreating the quick settings panel during screen rotation.
This commit is contained in:
parent
fbdd90066d
commit
1ac2745bfb
2 changed files with 17 additions and 5 deletions
|
|
@ -13,6 +13,7 @@
|
||||||
|
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QOrientationSensor>
|
#include <QOrientationSensor>
|
||||||
|
#include <QTimer>
|
||||||
|
|
||||||
ScreenRotationUtil::ScreenRotationUtil(QObject *parent)
|
ScreenRotationUtil::ScreenRotationUtil(QObject *parent)
|
||||||
: QObject{parent}
|
: QObject{parent}
|
||||||
|
|
@ -57,6 +58,20 @@ bool ScreenRotationUtil::autoScreenRotationEnabled()
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScreenRotationUtil::setAutoScreenRotationEnabled(bool value)
|
void ScreenRotationUtil::setAutoScreenRotationEnabled(bool value)
|
||||||
|
{
|
||||||
|
// Don't execute immediately, in case the screen rotation
|
||||||
|
// deletes the caller mid-function call, causing a crash.
|
||||||
|
QTimer::singleShot(0, this, [this, value]() {
|
||||||
|
actuallySetAutoScreenRotationEnabled(value);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ScreenRotationUtil::isAvailable()
|
||||||
|
{
|
||||||
|
return m_sensor->connectToBackend();
|
||||||
|
}
|
||||||
|
|
||||||
|
void ScreenRotationUtil::actuallySetAutoScreenRotationEnabled(bool value)
|
||||||
{
|
{
|
||||||
if (!m_config) {
|
if (!m_config) {
|
||||||
return;
|
return;
|
||||||
|
|
@ -76,8 +91,3 @@ void ScreenRotationUtil::setAutoScreenRotationEnabled(bool value)
|
||||||
|
|
||||||
Q_EMIT autoScreenRotationEnabledChanged();
|
Q_EMIT autoScreenRotationEnabledChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ScreenRotationUtil::isAvailable()
|
|
||||||
{
|
|
||||||
return m_sensor->connectToBackend();
|
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -27,6 +27,8 @@ Q_SIGNALS:
|
||||||
void availableChanged();
|
void availableChanged();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
void actuallySetAutoScreenRotationEnabled(bool value);
|
||||||
|
|
||||||
KScreen::ConfigPtr m_config;
|
KScreen::ConfigPtr m_config;
|
||||||
QOrientationSensor *m_sensor;
|
QOrientationSensor *m_sensor;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue