diff options
author | Jason Barron <jason.barron@nokia.com> | 2010-07-14 14:12:04 (GMT) |
---|---|---|
committer | Jason Barron <jason.barron@nokia.com> | 2010-07-15 07:40:29 (GMT) |
commit | 6d29bcc28c4ee9b7583a62d23a931b9389004966 (patch) | |
tree | 8814b0bd8262d4f6557a58e62bf2d9cf86ba9de4 | |
parent | 7f339416471839ca9137b9ea1aa79f74fb565f4b (diff) | |
download | Qt-6d29bcc28c4ee9b7583a62d23a931b9389004966.zip Qt-6d29bcc28c4ee9b7583a62d23a931b9389004966.tar.gz Qt-6d29bcc28c4ee9b7583a62d23a931b9389004966.tar.bz2 |
Avoid a crash in the OpenVG paint engine when clipping to an empty path
The convertToPainterPath() function assumes that the QVectorPath
contains at least one path element when creating the QPainterPath. This
is not necessarily the case here though because if QVG_SCISSOR_CLIP is
defined and setClipPath() is called with an empty QPainterPath, this is
then converted to an empty QVectorPath in QPaintEngineEx::clip() which
then calls QVGPaintEngine::clip(). This function then goes on to
convert the QVectorPath back into a QPainterPath using the
aforementioned function which crashes when attempting to access the
first element of the path.
In case you are wondering why this seemingly redundant conversion
happens at all, it happens because when QVG_SCISSOR_CLIP is defined, we
attempt to convert the path to a series of rects for scissor clipping
and this conversion function operates on QPainterPath instead of
QVectorPath which is what this clip() function was designed to deal
with.
The fix is to skip over the path conversion for empty paths and go
directly to an empty QRegion.
Reviewed-by: Alessandro Portale
-rw-r--r-- | src/openvg/qpaintengine_vg.cpp | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/src/openvg/qpaintengine_vg.cpp b/src/openvg/qpaintengine_vg.cpp index 7a050f6..7de09ce 100644 --- a/src/openvg/qpaintengine_vg.cpp +++ b/src/openvg/qpaintengine_vg.cpp @@ -1632,7 +1632,10 @@ void QVGPaintEngine::clip(const QVectorPath &path, Qt::ClipOperation op) // Try converting the path into a QRegion that tightly follows // the outline of the path we want to clip with. - QRegion region(path.convertToPainterPath().toFillPolygon(QTransform()).toPolygon()); + QRegion region; + if (!path.isEmpty()) + region = QRegion(path.convertToPainterPath().toFillPolygon(QTransform()).toPolygon()); + switch (op) { case Qt::NoClip: { |