summaryrefslogtreecommitdiffstats
path: root/src/gui/text/qstatictext.cpp
diff options
context:
space:
mode:
authorEskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@nokia.com>2011-06-28 15:07:13 (GMT)
committerEskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@nokia.com>2011-06-29 08:06:26 (GMT)
commitf8560717dd56514269cfb081c7f4b94e231e10d7 (patch)
tree8e398ce43f8be1d5805ccd81697846c9a31eb553 /src/gui/text/qstatictext.cpp
parent348894a550510e54e7709d18676b4b10c9e5e9e3 (diff)
downloadQt-f8560717dd56514269cfb081c7f4b94e231e10d7.zip
Qt-f8560717dd56514269cfb081c7f4b94e231e10d7.tar.gz
Qt-f8560717dd56514269cfb081c7f4b94e231e10d7.tar.bz2
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 Reviewed-by: Jiang Jiang
Diffstat (limited to 'src/gui/text/qstatictext.cpp')
-rw-r--r--src/gui/text/qstatictext.cpp10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/gui/text/qstatictext.cpp b/src/gui/text/qstatictext.cpp
index 414de51..73a871b 100644
--- a/src/gui/text/qstatictext.cpp
+++ b/src/gui/text/qstatictext.cpp
@@ -430,14 +430,17 @@ namespace {
public:
DrawTextItemRecorder(bool untransformedCoordinates, bool useBackendOptimizations)
: 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)
@@ -453,7 +456,7 @@ namespace {
currentItem.positionOffset = m_glyphs.size(); // Offset into position pool
currentItem.useBackendOptimizations = m_useBackendOptimizations;
if (m_dirtyPen)
- currentItem.color = state->pen().color();
+ currentItem.color = m_currentColor;
QTransform matrix = m_untransformedCoordinates ? QTransform() : state->transform();
matrix.translate(position.x(), position.y());
@@ -524,6 +527,7 @@ namespace {
bool m_dirtyPen;
bool m_useBackendOptimizations;
bool m_untransformedCoordinates;
+ QColor m_currentColor;
};
class DrawTextItemDevice: public QPaintDevice