aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAndy Shaw <andy.shaw@qt.io>2019-02-13 14:08:49 +0100
committerAndy Shaw <andy.shaw@qt.io>2019-02-14 06:26:36 +0000
commit0148243a77a42de1ba6170a1da3977b3026c1927 (patch)
tree663b864b4bec3a7a454cf0dce9ca0b888e470f9d /src
parent68d0377736a541fa29d1aaba6b7aa4a4cf8781ef (diff)
Canvas: Handle switching between object and string based colors
When switching between the two it should respect whatever the color is regardless of whether it is a color value or a string based color. This also accounts for "invalid" colors as this should set the stroke-style to be #000000 to be inline with the default stroke-style indicated in the specification. Change-Id: I00bee6c9a85787762271882838510b4187798ee0 Fixes: QTBUG-42155 Fixes: QTBUG-52959 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Diffstat (limited to 'src')
-rw-r--r--src/quick/items/context2d/qquickcontext2d.cpp9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/quick/items/context2d/qquickcontext2d.cpp b/src/quick/items/context2d/qquickcontext2d.cpp
index 66727e7845..57e697bdd1 100644
--- a/src/quick/items/context2d/qquickcontext2d.cpp
+++ b/src/quick/items/context2d/qquickcontext2d.cpp
@@ -1548,7 +1548,7 @@ QV4::ReturnedValue QQuickJSContext2D::method_set_strokeStyle(const QV4::Function
if (value->as<Object>()) {
QColor color = scope.engine->toVariant(value, qMetaTypeId<QColor>()).value<QColor>();
if (color.isValid()) {
- r->d()->context()->state.fillStyle = color;
+ r->d()->context()->state.strokeStyle = color;
r->d()->context()->buffer()->setStrokeStyle(color);
r->d()->context()->m_strokeStyle.set(scope.engine, value);
} else {
@@ -1559,7 +1559,12 @@ QV4::ReturnedValue QQuickJSContext2D::method_set_strokeStyle(const QV4::Function
r->d()->context()->m_strokeStyle.set(scope.engine, value);
r->d()->context()->state.strokePatternRepeatX = style->d()->patternRepeatX;
r->d()->context()->state.strokePatternRepeatY = style->d()->patternRepeatY;
-
+ } else if (!style && r->d()->context()->state.strokeStyle != QBrush(QColor())) {
+ // If there is no style object, then ensure that the strokeStyle is at least
+ // QColor in case it was previously set
+ r->d()->context()->state.strokeStyle = QBrush(QColor());
+ r->d()->context()->buffer()->setStrokeStyle(r->d()->context()->state.strokeStyle);
+ r->d()->context()->m_strokeStyle.set(scope.engine, value);
}
}
} else if (value->isString()) {