[plasma/plasma-workspace/Plasma/6.6] components/containmentlayoutmanager: containmentlayoutmanager: guard against non-finite item geometry
Nate Graham <[email protected]>
| Newsgroups | gmane.comp.kde.cvs |
|---|---|
| Message-ID | <[email protected]> |
Git commit 738dd48e65eeee39308a70e54e48abdf39c7b982 by Nate Graham. Committed on 23/07/2026 at 03:55. Pushed by ngraham into branch 'Plasma/6.6'. containmentlayoutmanager: guard against non-finite item geometry containmentlayoutmanager: guard against non-finite item geometry A malformed ItemGeometries entry containing "inf"/NaN was parsed via QString::toDouble() straight into the applet geometry and then applied as an infinite item size. That sends the desktop layout into a CPU-pegged loop, freezing plasmashell and breaking session D-Bus services (kuiserver etc.), which in turn crashes dependent apps. Reject non-finite values on both sides: - when parsing the saved layout, skip such entries so an existing corrupt config can no longer wedge the layout (the applet falls back to automatic placement); - when serializing, skip items whose geometry is non-finite so the layout manager does not write such a value back to the config. BUG: 522039 ### (cherry picked from commit b2b8fc265f38a1304aebff299e71d1131ff02767) 7fbe9879 containmentlayoutmanager: guard against non-finite item geometry Co-authored-by: Shouvik Kar <[email protected]> M +12 -1 components/containmentlayoutmanager/gridlayoutmanager.cpp M +5 -0 components/containmentlayoutmanager/itemcontainer.cpp M +2 -0 components/containmentlayoutmanager/itemcontainer.h https://invent.kde.org/plasma/plasma-workspace/-/commit/738dd48e65eeee39308a70e54e48abdf39c7b982 diff --git a/components/containmentlayoutmanager/gridlayoutmanager.cpp b/components/containmentlayoutmanager/gridlayoutmanager.cpp index d2b7b8b760..510aae0ff9 100644 --- a/components/containmentlayoutmanager/gridlayoutmanager.cpp +++ b/components/containmentlayoutmanager/gridlayoutmanager.cpp @@ -24,6 +24,9 @@ QString GridLayoutManager::serializeLayout() const for (auto *item : layout()->childItems()) { auto *itemCont = qobject_cast<ItemContainer *>(item); if (itemCont && itemCont != layout()->placeHolder()) { + if (!ItemContainer::hasValidGeometry(itemCont->x(), itemCont->y(), itemCont->width(), itemCont->height(), itemCont->rotation())) { + continue; + } result += itemCont->key() + QLatin1Char(':') + QString::number(itemCont->x()) + QLatin1Char(',') + QString::number(itemCont->y()) + QLatin1Char(',') + QString::number(itemCont->width()) + QLatin1Char(',') + QString::number(itemCont->height()) + QLatin1Char(',') + QString::number(itemCont->rotation()) + QLatin1Char(';'); @@ -50,7 +53,15 @@ void GridLayoutManager::parseLayout(const QString &savedLayout) continue; } - m_parsedConfig[id] = {itemGeom[0].toDouble(), itemGeom[1].toDouble(), itemGeom[2].toDouble(), itemGeom[3].toDouble(), itemGeom[4].toDouble()}; + const qreal gx = itemGeom[0].toDouble(); + const qreal gy = itemGeom[1].toDouble(); + const qreal gwidth = itemGeom[2].toDouble(); + const qreal gheight = itemGeom[3].toDouble(); + const qreal grotation = itemGeom[4].toDouble(); + if (!ItemContainer::hasValidGeometry(gx, gy, gwidth, gheight, grotation)) { + continue; + } + m_parsedConfig[id] = {gx, gy, gwidth, gheight, grotation}; } } diff --git a/components/containmentlayoutmanager/itemcontainer.cpp b/components/containmentlayoutmanager/itemcontainer.cpp index f949497e18..e23678ef37 100644 --- a/components/containmentlayoutmanager/itemcontainer.cpp +++ b/components/containmentlayoutmanager/itemcontainer.cpp @@ -827,4 +827,9 @@ int ItemContainer::contentHeight() const return height() - m_topPadding - m_bottomPadding; } +bool ItemContainer::hasValidGeometry(qreal x, qreal y, qreal width, qreal height, qreal rotation) +{ + return std::isfinite(x) && std::isfinite(y) && std::isfinite(width) && std::isfinite(height) && std::isfinite(rotation); +} + #include "moc_itemcontainer.cpp" diff --git a/components/containmentlayoutmanager/itemcontainer.h b/components/containmentlayoutmanager/itemcontainer.h index 63fa6e8476..aa59704cf8 100644 --- a/components/containmentlayoutmanager/itemcontainer.h +++ b/components/containmentlayoutmanager/itemcontainer.h @@ -74,6 +74,8 @@ public: ItemContainer(QQuickItem *parent = nullptr); ~ItemContainer(); + static bool hasValidGeometry(qreal x, qreal y, qreal width, qreal height, qreal rotation); + QQmlListProperty<QObject> contentData(); QString key() const;