diff options
Diffstat (limited to 'src/gui/painting/qpainterpath.cpp')
-rw-r--r-- | src/gui/painting/qpainterpath.cpp | 25 |
1 files changed, 12 insertions, 13 deletions
diff --git a/src/gui/painting/qpainterpath.cpp b/src/gui/painting/qpainterpath.cpp index 851df3e7ae..8d23d167b0 100644 --- a/src/gui/painting/qpainterpath.cpp +++ b/src/gui/painting/qpainterpath.cpp @@ -517,10 +517,8 @@ QPainterPath::QPainterPath(const QPainterPath &other) = default; */ QPainterPath::QPainterPath(const QPointF &startPoint) - : d_ptr(new QPainterPathPrivate) + : d_ptr(new QPainterPathPrivate(startPoint)) { - Element e = { startPoint.x(), startPoint.y(), MoveToElement }; - d_func()->elements << e; } void QPainterPath::detach() @@ -1135,6 +1133,9 @@ void QPainterPath::addEllipse(const QRectF &boundingRect) that the left end of the text's baseline lies at the specified \a point. + Some fonts may yield overlapping subpaths and will require the + \c Qt::WindingFill fill rule for correct rendering. + \table 100% \row \li \inlineimage qpainterpath-addtext.png @@ -1143,7 +1144,7 @@ void QPainterPath::addEllipse(const QRectF &boundingRect) \endtable \sa QPainter::drawText(), {QPainterPath#Composing a - QPainterPath}{Composing a QPainterPath} + QPainterPath}{Composing a QPainterPath}, setFillRule() */ void QPainterPath::addText(const QPointF &point, const QFont &f, const QString &text) { @@ -1488,7 +1489,7 @@ QRectF QPainterPath::controlPointRect() const bool QPainterPath::isEmpty() const { - return !d_ptr || (d_ptr->elements.size() == 1 && d_ptr->elements.first().type == MoveToElement); + return !d_ptr || (d_ptr->elements.size() == 1 && d_ptr->elements.constFirst().type == MoveToElement); } /*! @@ -2441,14 +2442,14 @@ QDataStream &operator>>(QDataStream &s, QPainterPath &p) int size; s >> size; - if (size == 0) + if (size == 0) { + p = {}; return s; + } p.ensureData(); // in case if p.d_func() == 0 - if (p.d_func()->elements.size() == 1) { - Q_ASSERT(p.d_func()->elements.at(0).type == QPainterPath::MoveToElement); - p.d_func()->elements.clear(); - } + p.detach(); + p.d_func()->elements.clear(); for (int i=0; i<size; ++i) { int type; double x, y; @@ -2471,9 +2472,7 @@ QDataStream &operator>>(QDataStream &s, QPainterPath &p) s >> fillRule; Q_ASSERT(fillRule == Qt::OddEvenFill || fillRule == Qt::WindingFill); p.d_func()->fillRule = Qt::FillRule(fillRule); - p.d_func()->dirtyBounds = true; - p.d_func()->dirtyControlBounds = true; - if (errorDetected) + if (errorDetected || p.d_func()->elements.isEmpty()) p = QPainterPath(); // Better than to return path with possibly corrupt datastructure, which would likely cause crash return s; } |