Commit 59bf0f5a authored by Marco Martin's avatar Marco Martin Committed by Nate Graham
Browse files

Introduce a lock that blocks relayouts and config writes

The resize of the layout area can happen either by screen resolution
change or available screen area change (a panel appears or is resized)
This is not an atomic operation, as width and height are usually set in
2 different operations, and even worse the layout area is resized to
match the available one with an animation, so many intermediate resizes
that should never cause a relayout happen.

In normal operation an event compression timer limits the actual
relayouts to hopefully one, but if the system is really slowed down
(for instance, startup) the timer may expire and cause relayouts in
non useful sizes, losing the needed configuration.

In combination with

The lock blocks all relayout and config writes when the size of the
layout area doesn't correspond to corona availablescreenrect, which are
the only "settled" cases.


(cherry picked from commit ef57cd3d)
parent 02287d54
Pipeline #236129 passed with stage
in 6 minutes and 20 seconds
......@@ -60,9 +60,10 @@ AppletsLayout::AppletsLayout(QQuickItem *parent)
connect(m_layoutChangeTimer, &QTimer::timeout, this, [this]() {
// We can't assume m_containment to be valid: if we load in a plasmoid that can run also
// in "applet" mode, m_containment will never be valid
if (!m_containment) {
if (!m_containment || width() <= 0 || height() <= 0 || m_relayoutLock) {
const QString &serializedConfig = m_containment->config().readEntry(m_configKey, "");
if ((m_layoutChanges & ConfigKeyChange) && !serializedConfig.isEmpty()) {
if (!m_configKey.isEmpty() && m_containment) {
......@@ -173,6 +174,26 @@ void AppletsLayout::setFallbackConfigKey(const QString &key)
Q_EMIT fallbackConfigKeyChanged();
bool AppletsLayout::relayoutLock() const
return m_relayoutLock;
void AppletsLayout::setRelayoutLock(bool lock)
if (lock == m_relayoutLock) {
m_relayoutLock = lock;
if (!lock && m_layoutChanges != NoChange) {
Q_EMIT relayoutLockChanged();
QJSValue AppletsLayout::acceptsAppletCallback() const
return m_acceptsAppletCallback;
......@@ -484,7 +505,7 @@ void AppletsLayout::geometryChange(const QRectF &newGeometry, const QRectF &oldG
// Only do a layouting procedure if we received a valid size
if (!newGeometry.isEmpty()) {
if (!newGeometry.isEmpty() && newGeometry != oldGeometry) {
m_layoutChanges |= SizeChange;
......@@ -39,6 +39,8 @@ class AppletsLayout : public QQuickItem
// from the screen size and plasma starts on an "unexpected" size
Q_PROPERTY(QString fallbackConfigKey READ fallbackConfigKey WRITE setFallbackConfigKey NOTIFY fallbackConfigKeyChanged)
Q_PROPERTY(bool relayoutLock READ relayoutLock WRITE setRelayoutLock NOTIFY relayoutLockChanged)
Q_PROPERTY(PlasmaQuick::AppletQuickItem *containment READ containment WRITE setContainment NOTIFY containmentChanged)
Q_PROPERTY(QJSValue acceptsAppletCallback READ acceptsAppletCallback WRITE setAcceptsAppletCallback NOTIFY acceptsAppletCallbackChanged)
......@@ -103,6 +105,9 @@ public:
QString fallbackConfigKey() const;
void setFallbackConfigKey(const QString &key);
bool relayoutLock() const;
void setRelayoutLock(bool lock);
PlasmaQuick::AppletQuickItem *containment() const;
void setContainment(PlasmaQuick::AppletQuickItem *containment);
......@@ -162,6 +167,7 @@ Q_SIGNALS:
void configKeyChanged();
void fallbackConfigKeyChanged();
void relayoutLockChanged();
void containmentChanged();
void minimumItemWidthChanged();
void minimumItemHeightChanged();
......@@ -230,6 +236,7 @@ private:
QPointF m_mouseDownPosition = QPoint(-1, -1);
bool m_mouseDownWasEditMode = false;
bool m_editMode = false;
bool m_relayoutLock = false;
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment