mirror of
https://invent.kde.org/marcoa/shift-shell.git
synced 2026-04-26 14:23: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 <QOrientationSensor>
|
||||
#include <QTimer>
|
||||
|
||||
ScreenRotationUtil::ScreenRotationUtil(QObject *parent)
|
||||
: QObject{parent}
|
||||
|
|
@ -57,6 +58,20 @@ bool ScreenRotationUtil::autoScreenRotationEnabled()
|
|||
}
|
||||
|
||||
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) {
|
||||
return;
|
||||
|
|
@ -76,8 +91,3 @@ void ScreenRotationUtil::setAutoScreenRotationEnabled(bool value)
|
|||
|
||||
Q_EMIT autoScreenRotationEnabledChanged();
|
||||
}
|
||||
|
||||
bool ScreenRotationUtil::isAvailable()
|
||||
{
|
||||
return m_sensor->connectToBackend();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,6 +27,8 @@ Q_SIGNALS:
|
|||
void availableChanged();
|
||||
|
||||
private:
|
||||
void actuallySetAutoScreenRotationEnabled(bool value);
|
||||
|
||||
KScreen::ConfigPtr m_config;
|
||||
QOrientationSensor *m_sensor;
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue