diff options
Diffstat (limited to 'src/gui/painting/qpainterpath.cpp')
-rw-r--r-- | src/gui/painting/qpainterpath.cpp | 65 |
1 files changed, 14 insertions, 51 deletions
diff --git a/src/gui/painting/qpainterpath.cpp b/src/gui/painting/qpainterpath.cpp index bfe86b251d..8d23d167b0 100644 --- a/src/gui/painting/qpainterpath.cpp +++ b/src/gui/painting/qpainterpath.cpp @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtGui module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #include "qpainterpath.h" #include "qpainterpath_p.h" @@ -553,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() @@ -1171,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 @@ -1179,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) { @@ -1524,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); } /*! @@ -2477,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; @@ -2507,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; } |