From: Yann Bodson Date: Tue, 10 Jul 2012 05:35:57 +0000 (+1000) Subject: Remove unneeded mac specific code in QQuickText X-Git-Url: http://git.silmor.de/gitweb/?a=commitdiff_plain;h=7ddd5308946f32f4f0514c493a0a0f01c2bdc840;p=konrad%2Fqtdeclarative.git Remove unneeded mac specific code in QQuickText We don't need to relayout in painting thread. Task-number: QTBUG-26361 Change-Id: Idfad1b90e2772e72411df821d02ea596a094f508 Reviewed-by: Andrew den Exter --- diff --git a/src/quick/items/qquicktext.cpp b/src/quick/items/qquicktext.cpp index 3d29ade..d2db178 100644 --- a/src/quick/items/qquicktext.cpp +++ b/src/quick/items/qquicktext.cpp @@ -74,11 +74,7 @@ QT_BEGIN_NAMESPACE const QChar QQuickTextPrivate::elideChar = QChar(0x2026); QQuickTextPrivate::QQuickTextPrivate() - : elideLayout(0), textLine(0) -#if defined(Q_OS_MAC) - , layoutThread(0), paintingThread(0) -#endif - , lineWidth(0) + : elideLayout(0), textLine(0), lineWidth(0) , color(0xFF000000), linkColor(0xFF0000FF), styleColor(0xFF000000) , lineCount(1), multilengthEos(-1) , elideMode(QQuickText::ElideNone), hAlign(QQuickText::AlignLeft), vAlign(QQuickText::AlignTop) @@ -488,9 +484,6 @@ void QQuickTextPrivate::updateSize() QSizeF size(0, 0); QSizeF previousSize = layedOutTextRect.size(); -#if defined(Q_OS_MAC) - layoutThread = QThread::currentThread(); -#endif //setup instance of QTextLayout for all cases other than richtext if (!richText) { @@ -655,42 +648,24 @@ void QQuickTextPrivate::setupCustomLineGeometry(QTextLine &line, qreal &height, { Q_Q(QQuickText); -#if defined(Q_OS_MAC) - if (QThread::currentThread() != paintingThread) { - if (!line.lineNumber()) - linesRects.clear(); -#endif - - if (!textLine) - textLine = new QQuickTextLine; - textLine->setLine(&line); - textLine->setY(height); - textLine->setHeight(0); - textLine->setLineOffset(lineOffset); + if (!textLine) + textLine = new QQuickTextLine; + textLine->setLine(&line); + textLine->setY(height); + textLine->setHeight(0); + textLine->setLineOffset(lineOffset); - // use the text item's width by default if it has one and wrap is on - if (q->widthValid() && q->wrapMode() != QQuickText::NoWrap) - textLine->setWidth(q->width()); - else - textLine->setWidth(INT_MAX); - if (lineHeight() != 1.0) - textLine->setHeight((lineHeightMode() == QQuickText::FixedHeight) ? lineHeight() : line.height() * lineHeight()); - - emit q->lineLaidOut(textLine); - - height += textLine->height(); + // use the text item's width by default if it has one and wrap is on + if (q->widthValid() && q->wrapMode() != QQuickText::NoWrap) + textLine->setWidth(q->width()); + else + textLine->setWidth(INT_MAX); + if (lineHeight() != 1.0) + textLine->setHeight((lineHeightMode() == QQuickText::FixedHeight) ? lineHeight() : line.height() * lineHeight()); -#if defined(Q_OS_MAC) - linesRects << QRectF(textLine->x(), textLine->y(), textLine->width(), textLine->height()); + emit q->lineLaidOut(textLine); - } else { - if (line.lineNumber() < linesRects.count()) { - QRectF r = linesRects.at(line.lineNumber()); - line.setLineWidth(r.width()); - line.setPosition(r.topLeft()); - } - } -#endif + height += textLine->height(); } void QQuickTextPrivate::elideFormats( @@ -2243,13 +2218,6 @@ QSGNode *QQuickText::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *data const qreal dy = QQuickTextUtil::alignedY(d->layedOutTextRect.height(), height(), d->vAlign); - // We need to make sure the layout is done in the current thread -#if defined(Q_OS_MAC) - d->paintingThread = QThread::currentThread(); - if (d->layoutThread != d->paintingThread) - d->updateLayout(); -#endif - QQuickTextNode *node = 0; if (!oldNode) { node = new QQuickTextNode(QQuickItemPrivate::get(this)->sceneGraphContext(), this); diff --git a/src/quick/items/qquicktext_p_p.h b/src/quick/items/qquicktext_p_p.h index b6f68c4..f959dc1 100644 --- a/src/quick/items/qquicktext_p_p.h +++ b/src/quick/items/qquicktext_p_p.h @@ -115,12 +115,6 @@ public: QTextLayout *elideLayout; QQuickTextLine *textLine; -#if defined(Q_OS_MAC) - QList linesRects; - QThread *layoutThread; - QThread *paintingThread; -#endif - qreal lineWidth; QRgb color; diff --git a/tests/auto/quick/qquicktext/tst_qquicktext.cpp b/tests/auto/quick/qquicktext/tst_qquicktext.cpp index 7a7f5cc..c16da4c 100644 --- a/tests/auto/quick/qquicktext/tst_qquicktext.cpp +++ b/tests/auto/quick/qquicktext/tst_qquicktext.cpp @@ -2450,10 +2450,6 @@ void tst_qquicktext::lineLaidOut() QVERIFY(!textPrivate->extra.isAllocated()); -#if defined(Q_OS_MAC) - QVERIFY(myText->lineCount() == textPrivate->linesRects.count()); -#endif - for (int i = 0; i < textPrivate->layout.lineCount(); ++i) { QRectF r = textPrivate->layout.lineAt(i).rect(); QVERIFY(r.width() == i * 15); @@ -2484,10 +2480,6 @@ void tst_qquicktext::lineLaidOutRelayout() QVERIFY(!textPrivate->extra.isAllocated()); -#if defined(Q_OS_MAC) - QVERIFY(myText->lineCount() == textPrivate->linesRects.count()); -#endif - qreal maxH = 0; for (int i = 0; i < textPrivate->layout.lineCount(); ++i) { QRectF r = textPrivate->layout.lineAt(i).rect();