From dae23694cb89b853785a5772cc7e0477f65ac5bf Mon Sep 17 00:00:00 2001 From: Jiang Jiang Date: Mon, 16 Aug 2010 15:14:43 +0200 Subject: Fix tabArray support for boundingRect measurement QFontMetrics::boundingRect() and size() accept a tabArray as argument to measure the size of string, but tabArray argument has no effect because qt_format_text() just ignore that. This patch make it handle tabArray so that measurement for tab aligned text can be handled correctly. Task-number: QTBUG-4904 Reviewed-by: Eskil --- src/gui/painting/qpainter.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/gui/painting/qpainter.cpp b/src/gui/painting/qpainter.cpp index 314f349..c0f195a 100644 --- a/src/gui/painting/qpainter.cpp +++ b/src/gui/painting/qpainter.cpp @@ -7997,7 +7997,7 @@ void qt_format_text(const QFont &fnt, const QRectF &_r, } void qt_format_text(const QFont &fnt, const QRectF &_r, int tf, const QTextOption *option, const QString& str, QRectF *brect, - int tabstops, int *, int tabarraylen, + int tabstops, int *ta, int tabarraylen, QPainter *painter) { @@ -8120,6 +8120,13 @@ start_lengthVariant: if (engine.option.tabStop() < 0 && tabstops > 0) engine.option.setTabStop(tabstops); + if (engine.option.tabs().isEmpty() && ta) { + QList tabs; + for (int i = 0; i < tabarraylen; i++) + tabs.append(qreal(ta[i])); + engine.option.setTabArray(tabs); + } + engine.option.setTextDirection(layout_direction); if (tf & Qt::AlignJustify) engine.option.setAlignment(Qt::AlignJustify); -- cgit v0.12 From b7fd2930986a9be5dd6115bfc4a5c5c517344371 Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Mon, 23 Aug 2010 16:49:06 +0200 Subject: QFutureWatcher: display a warning when connecting after calling setFuture() Reviewed-by: brad --- src/corelib/concurrent/qfuturewatcher.cpp | 9 +++++++++ tests/auto/qfuturewatcher/tst_qfuturewatcher.cpp | 24 +++++++++++++++++++++++- 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/src/corelib/concurrent/qfuturewatcher.cpp b/src/corelib/concurrent/qfuturewatcher.cpp index d4573c6..21b0789 100644 --- a/src/corelib/concurrent/qfuturewatcher.cpp +++ b/src/corelib/concurrent/qfuturewatcher.cpp @@ -359,6 +359,15 @@ void QFutureWatcherBase::connectNotify(const char * signal) Q_D(QFutureWatcherBase); if (qstrcmp(signal, SIGNAL(resultReadyAt(int))) == 0) d->resultAtConnected.ref(); +#ifndef QT_NO_DEBUG + if (qstrcmp(signal, SIGNAL(finished())) == 0) { + if (futureInterface().isRunning()) { + //connections should be established before calling stFuture to avoid race. + // (The future could finish before the connection is made.) + qWarning("QFutureWatcher::connect: connecting after calling setFuture() is likely to produce race"); + } + } +#endif } void QFutureWatcherBase::disconnectNotify(const char * signal) diff --git a/tests/auto/qfuturewatcher/tst_qfuturewatcher.cpp b/tests/auto/qfuturewatcher/tst_qfuturewatcher.cpp index c53c67a..8b52761 100644 --- a/tests/auto/qfuturewatcher/tst_qfuturewatcher.cpp +++ b/tests/auto/qfuturewatcher/tst_qfuturewatcher.cpp @@ -81,6 +81,7 @@ private slots: void incrementalMapResults(); void incrementalFilterResults(); void qfutureSynchornizer(); + void warnRace(); }; QTEST_MAIN(tst_QFutureWatcher) @@ -466,12 +467,12 @@ void tst_QFutureWatcher::toMuchProgress() ProgressObject o; QFutureWatcher f; - f.setFuture((new ProgressEmitterTask())->start()); QObject::connect(&f, SIGNAL(finished()), &QTestEventLoop::instance(), SLOT(exitLoop())); #ifdef PRINT QObject::connect(&f, SIGNAL(progressValueChanged(int)), &o, SLOT(printProgress(int))); #endif QObject::connect(&f, SIGNAL(progressValueChanged(int)), &o, SLOT(registerProgress(int))); + f.setFuture((new ProgressEmitterTask())->start()); QTestEventLoop::instance().enterLoop(5); QVERIFY(!QTestEventLoop::instance().timeout()); @@ -886,6 +887,27 @@ void tst_QFutureWatcher::qfutureSynchornizer() QVERIFY(t.elapsed() < taskCount * 10); } +class DummyObject : public QObject { + Q_OBJECT +public slots: + void dummySlot() {} +}; + +void tst_QFutureWatcher::warnRace() +{ +#ifndef QT_NO_DEBUG + QTest::ignoreMessage(QtWarningMsg, "QFutureWatcher::connect: connecting after calling setFuture() is likely to produce race"); +#endif + QFutureWatcher watcher; + DummyObject object; + + QFuture future = QtConcurrent::run(sleeper); + watcher.setFuture(future); + connect(&watcher, SIGNAL(finished()), &object, SLOT(dummySlot())); + future.waitForFinished(); +} + + #include "tst_qfuturewatcher.moc" #else -- cgit v0.12