diff options
author | Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@theqtcompany.com> | 2014-10-16 16:57:08 +0200 |
---|---|---|
committer | Jani Heikkinen <jani.heikkinen@theqtcompany.com> | 2014-11-13 19:58:28 +0100 |
commit | dd08a22a4e8d7120341a1227e227de3f0628dd2f (patch) | |
tree | 6130ebf44600d5ec579752f617d9189875e7bb0b /src/quick/items/qquicktextinput.cpp | |
parent | dd6e14a7df6e40ff8b9ffe22fe6124630a15bda0 (diff) |
Invalidate font caches when switching between threadsv5.4.0-rc1
The font caches can only be used from a single thread at a time.
QFontEngineFT for instance, uses a global static thread storage
which is accessed on releasing and creating engines, and this
causes a crash if the font engine is created on one thread and
released on another.
We use the updatePolish() function to make sure the caches are
empty before entering updatePaintNode(), and then we invalidate
the cache again after updatePaintNode() is done.
[ChangeLog][Text] Fixed uncommon crash in text nodes.
Change-Id: I01dbc2ed58aeebd03d77a157c700330334bdb385
Task-number: QTBUG-38800
Reviewed-by: Konstantin Ritt <ritt.ks@gmail.com>
Diffstat (limited to 'src/quick/items/qquicktextinput.cpp')
-rw-r--r-- | src/quick/items/qquicktextinput.cpp | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/src/quick/items/qquicktextinput.cpp b/src/quick/items/qquicktextinput.cpp index 1f03fb21e2..a9c60273d2 100644 --- a/src/quick/items/qquicktextinput.cpp +++ b/src/quick/items/qquicktextinput.cpp @@ -56,6 +56,8 @@ #include "qquickaccessibleattached_p.h" #endif +#include <QtGui/private/qtextengine_p.h> + QT_BEGIN_NAMESPACE DEFINE_BOOL_CONFIG_OPTION(qmlDisableDistanceField, QML_DISABLE_DISTANCEFIELD) @@ -362,6 +364,7 @@ void QQuickTextInput::setColor(const QColor &c) d->color = c; d->textLayoutDirty = true; d->updateType = QQuickTextInputPrivate::UpdatePaintNode; + polish(); update(); emit colorChanged(); } @@ -389,6 +392,7 @@ void QQuickTextInput::setSelectionColor(const QColor &color) if (d->hasSelectedText()) { d->textLayoutDirty = true; d->updateType = QQuickTextInputPrivate::UpdatePaintNode; + polish(); update(); } emit selectionColorChanged(); @@ -414,6 +418,7 @@ void QQuickTextInput::setSelectedTextColor(const QColor &color) if (d->hasSelectedText()) { d->textLayoutDirty = true; d->updateType = QQuickTextInputPrivate::UpdatePaintNode; + polish(); update(); } emit selectedTextColorChanged(); @@ -723,6 +728,7 @@ void QQuickTextInput::setCursorVisible(bool on) if (!d->cursorItem) { d->setCursorBlinkPeriod(on ? qApp->styleHints()->cursorFlashTime() : 0); d->updateType = QQuickTextInputPrivate::UpdatePaintNode; + polish(); update(); } emit cursorVisibleChanged(d->cursorVisible); @@ -1830,9 +1836,23 @@ void QQuickTextInput::triggerPreprocess() Q_D(QQuickTextInput); if (d->updateType == QQuickTextInputPrivate::UpdateNone) d->updateType = QQuickTextInputPrivate::UpdateOnlyPreprocess; + polish(); update(); } +void QQuickTextInput::updatePolish() +{ + invalidateFontCaches(); +} + +void QQuickTextInput::invalidateFontCaches() +{ + Q_D(QQuickTextInput); + + if (d->m_textLayout.engine() != 0) + d->m_textLayout.engine()->resetFontEngineCache(); +} + QSGNode *QQuickTextInput::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *data) { Q_UNUSED(data); @@ -1891,6 +1911,8 @@ QSGNode *QQuickTextInput::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData d->textLayoutDirty = false; } + invalidateFontCaches(); + return node; } @@ -2651,6 +2673,7 @@ void QQuickTextInput::updateCursorRectangle(bool scroll) d->updateVerticalScroll(); } d->updateType = QQuickTextInputPrivate::UpdatePaintNode; + polish(); update(); emit cursorRectangleChanged(); if (d->cursorItem) { @@ -2668,6 +2691,7 @@ void QQuickTextInput::selectionChanged() Q_D(QQuickTextInput); d->textLayoutDirty = true; //TODO: Only update rect in selection d->updateType = QQuickTextInputPrivate::UpdatePaintNode; + polish(); update(); emit selectedTextChanged(); @@ -2879,6 +2903,7 @@ void QQuickTextInputPrivate::updateLayout() contentSize = QSizeF(width, height); updateType = UpdatePaintNode; + q->polish(); q->update(); if (!requireImplicitWidth && !q->widthValid()) @@ -4167,6 +4192,7 @@ void QQuickTextInputPrivate::setCursorBlinkPeriod(int msec) m_blinkTimer = 0; if (m_blinkStatus == 1) { updateType = UpdatePaintNode; + q->polish(); q->update(); } } @@ -4179,6 +4205,7 @@ void QQuickTextInput::timerEvent(QTimerEvent *event) if (event->timerId() == d->m_blinkTimer) { d->m_blinkStatus = !d->m_blinkStatus; d->updateType = QQuickTextInputPrivate::UpdatePaintNode; + polish(); update(); } else if (event->timerId() == d->m_passwordEchoTimer.timerId()) { d->m_passwordEchoTimer.stop(); |