From 05cab5fdac545533e01d30ab37addb852acf3cff Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Wed, 12 Mar 2025 15:09:46 +0100 Subject: [PATCH] Mark QSimplex{,Constraint} final, AnchorData non-copyable These final touch-ups for CID 390828 make the code easier to understand and safer, because more unsafe operations are now forbidden (subclassing and copying). Coverity-Id: 390828 Pick-to: 6.8 6.5 Change-Id: I2e43be71d8c3db59d95e69ec16c41c1547a2f180 Reviewed-by: Magdalena Stojek Reviewed-by: Mate Barany (cherry picked from commit 912388b3068e831e4fbd9b3c31a62c79ee91c72d) Reviewed-by: Qt Cherry-pick Bot --- src/widgets/graphicsview/qgraphicsanchorlayout_p.h | 2 ++ src/widgets/graphicsview/qsimplex_p.h | 6 ++++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/widgets/graphicsview/qgraphicsanchorlayout_p.h b/src/widgets/graphicsview/qgraphicsanchorlayout_p.h index 3a049105b9d..d046cd93d21 100644 --- a/src/widgets/graphicsview/qgraphicsanchorlayout_p.h +++ b/src/widgets/graphicsview/qgraphicsanchorlayout_p.h @@ -75,6 +75,8 @@ struct AnchorVertex Represents an edge (anchor) in the internal graph. */ struct AnchorData : public QSimplexVariable { + Q_DISABLE_COPY_MOVE(AnchorData) + enum Type { Normal = 0, Sequential, diff --git a/src/widgets/graphicsview/qsimplex_p.h b/src/widgets/graphicsview/qsimplex_p.h index c45e728ccf9..4ae4e544ca5 100644 --- a/src/widgets/graphicsview/qsimplex_p.h +++ b/src/widgets/graphicsview/qsimplex_p.h @@ -43,8 +43,10 @@ struct QSimplexVariable Where (ci, Xi) are the pairs in "variables" and K the real "constant". */ -struct QSimplexConstraint +struct QSimplexConstraint final { + Q_DISABLE_COPY_MOVE(QSimplexConstraint) + QSimplexConstraint() : constant(0), ratio(Equal), artificial(nullptr) {} enum Ratio { @@ -109,7 +111,7 @@ struct QSimplexConstraint #endif }; -class QSimplex +class QSimplex final { Q_DISABLE_COPY_MOVE(QSimplex) public: