aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorEskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@nokia.com>2011-06-28 17:07:13 +0200
committerQt by Nokia <qt-info@nokia.com>2011-06-30 12:48:16 +0200
commit3296449d5cd9491b56914a23a78d2f78982a6856 (patch)
tree30607e71d8a91a4ca6481586f49a9e3a5c8501a1 /src
parentdb5aad6a99996b134cb406dc562017690f6a6812 (diff)
Fix text color in some cases of QML and QStaticText
This reverts 518c2a58ed6fdfd7449cb4476aa8ea0d32ad16e3 which caused a regression. When writing systems are mixed and an underline is set on the font, QPainter will set a pen with the current color and a new width on itself before drawing the decoration. This would cause the recorder in QStaticText to mark the pen as dirty, saving the current pen color in all subsequent text items. The effect was e.g. that in QML the cached color would override the current one, making it impossible to change the color on the text without forcing a relayout somehow. The right fix is to only mark the pen as dirty when its color actually changes. Task-number: QTBUG-20159 Change-Id: I0db1966787f543695bcba4a0c13328ae0a17625b Reviewed-by: Jiang Jiang Reviewed-on: http://codereview.qt.nokia.com/875 Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com> Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@nokia.com>
Diffstat (limited to 'src')
-rw-r--r--src/declarative/graphicsitems/qdeclarativetextlayout.cpp15
-rw-r--r--src/declarative/graphicsitems/qdeclarativetextlayout_p.h2
2 files changed, 10 insertions, 7 deletions
diff --git a/src/declarative/graphicsitems/qdeclarativetextlayout.cpp b/src/declarative/graphicsitems/qdeclarativetextlayout.cpp
index 73a8570b55..e7bcf1f460 100644
--- a/src/declarative/graphicsitems/qdeclarativetextlayout.cpp
+++ b/src/declarative/graphicsitems/qdeclarativetextlayout.cpp
@@ -69,14 +69,17 @@ class DrawTextItemRecorder: public QPaintEngine
public:
DrawTextItemRecorder(bool untransformedCoordinates, bool useBackendOptimizations)
: m_inertText(0), m_dirtyPen(false), m_useBackendOptimizations(useBackendOptimizations),
- m_untransformedCoordinates(untransformedCoordinates)
+ m_untransformedCoordinates(untransformedCoordinates), m_currentColor(Qt::black)
{
}
virtual void updateState(const QPaintEngineState &newState)
{
- if (newState.state() & QPaintEngine::DirtyPen)
+ if (newState.state() & QPaintEngine::DirtyPen
+ && newState.pen().color() != m_currentColor) {
m_dirtyPen = true;
+ m_currentColor = newState.pen().color();
+ }
}
virtual void drawTextItem(const QPointF &position, const QTextItem &textItem)
@@ -112,7 +115,7 @@ class DrawTextItemRecorder: public QPaintEngine
currentItem.positionOffset = positionOffset;
currentItem.useBackendOptimizations = m_useBackendOptimizations;
if (m_dirtyPen)
- currentItem.color = state->pen().color();
+ currentItem.color = m_currentColor;
m_inertText->items.append(currentItem);
}
@@ -169,6 +172,7 @@ class DrawTextItemRecorder: public QPaintEngine
bool m_dirtyPen;
bool m_useBackendOptimizations;
bool m_untransformedCoordinates;
+ QColor m_currentColor;
};
class DrawTextItemDevice: public QPaintDevice
@@ -296,7 +300,7 @@ void QDeclarativeTextLayout::clearLayout()
QTextLayout::clearLayout();
}
-void QDeclarativeTextLayout::prepare(QPainter *painter)
+void QDeclarativeTextLayout::prepare()
{
if (!d || !d->cached) {
@@ -305,7 +309,6 @@ void QDeclarativeTextLayout::prepare(QPainter *painter)
InertTextPainter *itp = inertTextPainter();
itp->device.begin(d);
- itp->painter.setPen(painter->pen());
QTextLayout::draw(&itp->painter, QPointF(0, 0));
glyph_t *glyphPool = d->glyphs.data();
@@ -344,7 +347,7 @@ void QDeclarativeTextLayout::draw(QPainter *painter, const QPointF &p)
return;
}
- prepare(painter);
+ prepare();
int itemCount = d->items.count();
diff --git a/src/declarative/graphicsitems/qdeclarativetextlayout_p.h b/src/declarative/graphicsitems/qdeclarativetextlayout_p.h
index 85d333e613..d83ce7e4ce 100644
--- a/src/declarative/graphicsitems/qdeclarativetextlayout_p.h
+++ b/src/declarative/graphicsitems/qdeclarativetextlayout_p.h
@@ -61,7 +61,7 @@ public:
void beginLayout();
void clearLayout();
- void prepare(QPainter *);
+ void prepare();
void draw(QPainter *, const QPointF & = QPointF());
private: