summaryrefslogtreecommitdiffstats
path: root/src/gui/painting/qpathclipper_p.h
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@qt.io>2022-07-08 08:19:59 +0200
committerTor Arne Vestbø <tor.arne.vestbo@qt.io>2022-07-08 20:14:52 +0000
commit04ab0905e3cff6371b21731aa7f26d2f7f32ce7b (patch)
treede2a4e5b1dd182417cb4a403dfa38a6eb4840b0d /src/gui/painting/qpathclipper_p.h
parent6b6b88774bc9176a9e5eb3b82778a8317bf99d45 (diff)
Gui: mark types Q_PRIMITIVE_TYPE when they're held in QDataBuffer
QDataBuffer assumes that its template argument is a POD, iow: it's ok to not run ctors and dtors and assign a value into uninitialized memory. In Qt, we call that Q_PRIMITIVE_TYPE. Asserting that the QDataBuffer value_type is not QTypeInfo::isComplex, however, has shown that a large number of types had not been marked as such, sometimes for good reason, e.g. because their default constructor doesn't value-initialize all members, but sets some of them to -1. Since QDataBuffer doesn't memset the memory to zero, it doesn't matter, as the code obviously has to have worked before, with uninitialized memory, and all-zeros is just a special, if common, form of uninitialized memory. I also tried to assert is_pod in QDataBuffer (working around the fact that that particular trait is deprecated), but found that almost none of the types in question were, in fact, trivial. We should fix this, because it means the compiler is generating code that's less efficient than it could be, but that's for another patch. All types marked as Q_PRIMITIVE_TYPE in this patch are private API, so this doesn't affect users. For PathSimplifier::Event, had to shorten the unnamed namespace to not include the member functions, because Q_DECLARE_TYPEINFO cannot appear in a namespace other than the Qt one. Pick-to: 6.4 6.3 Change-Id: I4431a2f269ec1ac4804a87ea71f983eaa34ef867 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io> Reviewed-by: Lars Knoll <lars.knoll@gmail.com>
Diffstat (limited to 'src/gui/painting/qpathclipper_p.h')
-rw-r--r--src/gui/painting/qpathclipper_p.h6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/gui/painting/qpathclipper_p.h b/src/gui/painting/qpathclipper_p.h
index b6cb65630f..f13b96e0ef 100644
--- a/src/gui/painting/qpathclipper_p.h
+++ b/src/gui/painting/qpathclipper_p.h
@@ -79,6 +79,7 @@ public:
qreal x;
qreal y;
};
+Q_DECLARE_TYPEINFO(QPathVertex, Q_PRIMITIVE_TYPE);
class QPathEdge
{
@@ -122,6 +123,7 @@ public:
private:
int m_next[2][2] = { { -1, -1 }, { -1, -1 } };
};
+Q_DECLARE_TYPEINFO(QPathEdge, Q_PRIMITIVE_TYPE);
class QPathSegments
{
@@ -135,6 +137,7 @@ public:
return t < o.t;
}
};
+ friend class QTypeInfo<Intersection>;
struct Segment {
Segment(int pathId, int vertexA, int vertexB)
@@ -156,6 +159,7 @@ public:
QRectF bounds;
};
+ friend class QTypeInfo<Segment>;
QPathSegments(int reserve);
@@ -187,6 +191,8 @@ private:
int m_pathId;
};
+Q_DECLARE_TYPEINFO(QPathSegments::Intersection, Q_PRIMITIVE_TYPE);
+Q_DECLARE_TYPEINFO(QPathSegments::Segment, Q_PRIMITIVE_TYPE);
class Q_AUTOTEST_EXPORT QWingedEdge
{