From fae182ebe716cf805805564af95fd2d4c73ae20e Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Thu, 12 Nov 2009 11:31:15 +0100 Subject: remove dependency on git line end conversions consistently use QIODevice::Text --- tests/auto/linguist/lconvert/tst_lconvert.cpp | 8 +++++--- tests/auto/linguist/lrelease/tst_lrelease.cpp | 8 ++++---- tests/auto/linguist/lupdate/testlupdate.cpp | 4 ++-- tests/auto/linguist/lupdate/tst_lupdate.cpp | 12 ++++++------ 4 files changed, 17 insertions(+), 15 deletions(-) diff --git a/tests/auto/linguist/lconvert/tst_lconvert.cpp b/tests/auto/linguist/lconvert/tst_lconvert.cpp index e38e22c..10098a4 100644 --- a/tests/auto/linguist/lconvert/tst_lconvert.cpp +++ b/tests/auto/linguist/lconvert/tst_lconvert.cpp @@ -105,7 +105,7 @@ void tst_lconvert::doCompare(QIODevice *actualDev, const QString &expectedFn) QList actual = actualDev->readAll().split('\n'); QFile file(expectedFn); - QVERIFY(file.open(QIODevice::ReadOnly)); + QVERIFY(file.open(QIODevice::ReadOnly | QIODevice::Text)); QList expected = file.readAll().split('\n'); int i = 0, ei = expected.size(), gi = actual.size(); @@ -179,7 +179,7 @@ void tst_lconvert::convertChain(const QString &_inFileName, const QString &_outF if (!argList.isEmpty()) args += argList[i]; args << "-if" << stations[i] << "-i" << "-" << "-of" << stations[i + 1]; - cvts.at(i)->start(binDir + "/lconvert", args); + cvts.at(i)->start(binDir + "/lconvert", args, QIODevice::ReadWrite | QIODevice::Text); } int st = 0; foreach (QProcess *cvt, cvts) @@ -243,7 +243,9 @@ void tst_lconvert::converts() QString outFileNameFq = dataDir + outFileName; QProcess cvt; - cvt.start(binDir + "/lconvert", QStringList() << "-i" << (dataDir + inFileName) << "-of" << format); + cvt.start(binDir + "/lconvert", + QStringList() << "-i" << (dataDir + inFileName) << "-of" << format, + QIODevice::ReadWrite | QIODevice::Text); doWait(&cvt, 0); if (QTest::currentTestFailed()) return; diff --git a/tests/auto/linguist/lrelease/tst_lrelease.cpp b/tests/auto/linguist/lrelease/tst_lrelease.cpp index 9a3bba6..9d30fe7 100644 --- a/tests/auto/linguist/lrelease/tst_lrelease.cpp +++ b/tests/auto/linguist/lrelease/tst_lrelease.cpp @@ -70,8 +70,8 @@ private: void tst_lrelease::doCompare(const QStringList &actual, const QString &expectedFn) { QFile file(expectedFn); - QVERIFY(file.open(QIODevice::ReadOnly)); - QStringList expected = QString(file.readAll()).trimmed().remove('\r').split('\n'); + QVERIFY(file.open(QIODevice::ReadOnly | QIODevice::Text)); + QStringList expected = QString(file.readAll()).trimmed().split('\n'); int i = 0, ei = expected.size(), gi = actual.size(); for (; ; i++) { @@ -200,10 +200,10 @@ void tst_lrelease::compressed() void tst_lrelease::dupes() { QProcess proc; - proc.start(binDir + "/lrelease testdata/dupes.ts"); + proc.start(binDir + "/lrelease testdata/dupes.ts", QIODevice::ReadWrite | QIODevice::Text); QVERIFY(proc.waitForFinished()); QVERIFY(proc.exitStatus() == QProcess::NormalExit); - doCompare(QString(proc.readAllStandardError()).trimmed().remove('\r').split('\n'), "testdata/dupes.errors"); + doCompare(QString(proc.readAllStandardError()).trimmed().split('\n'), "testdata/dupes.errors"); } QTEST_MAIN(tst_lrelease) diff --git a/tests/auto/linguist/lupdate/testlupdate.cpp b/tests/auto/linguist/lupdate/testlupdate.cpp index 8e57323..d43fbc4 100644 --- a/tests/auto/linguist/lupdate/testlupdate.cpp +++ b/tests/auto/linguist/lupdate/testlupdate.cpp @@ -98,9 +98,9 @@ bool TestLUpdate::runChild( bool showOutput, const QString &program, const QStri connect(childProc, SIGNAL(finished(int)), this, SLOT(childReady(int))); childProc->setProcessChannelMode(QProcess::MergedChannels); if (argList.isEmpty()) { - childProc->start( program ); + childProc->start( program, QIODevice::ReadWrite | QIODevice::Text ); } else { - childProc->start( program, argList ); + childProc->start( program, argList, QIODevice::ReadWrite | QIODevice::Text ); } bool ok; diff --git a/tests/auto/linguist/lupdate/tst_lupdate.cpp b/tests/auto/linguist/lupdate/tst_lupdate.cpp index 8443621..359c5a10 100644 --- a/tests/auto/linguist/lupdate/tst_lupdate.cpp +++ b/tests/auto/linguist/lupdate/tst_lupdate.cpp @@ -80,8 +80,8 @@ private: void tst_lupdate::doCompare(const QStringList &actual, const QString &expectedFn, bool err) { QFile file(expectedFn); - QVERIFY(file.open(QIODevice::ReadOnly)); - QStringList expected = QString(file.readAll()).trimmed().remove('\r').split('\n'); + QVERIFY(file.open(QIODevice::ReadOnly | QIODevice::Text)); + QStringList expected = QString(file.readAll()).trimmed().split('\n'); int i = 0, ei = expected.size(), gi = actual.size(); for (; ; i++) { @@ -130,8 +130,8 @@ void tst_lupdate::doCompare(const QStringList &actual, const QString &expectedFn void tst_lupdate::doCompare(const QString &actualFn, const QString &expectedFn, bool err) { QFile afile(actualFn); - QVERIFY(afile.open(QIODevice::ReadOnly)); - QStringList actual = QString(afile.readAll()).trimmed().remove('\r').split('\n'); + QVERIFY(afile.open(QIODevice::ReadOnly | QIODevice::Text)); + QStringList actual = QString(afile.readAll()).trimmed().split('\n'); doCompare(actual, expectedFn, err); } @@ -169,7 +169,7 @@ void tst_lupdate::good() QString lupdatecmd; QFile file(dir + "/lupdatecmd"); if (file.exists()) { - QVERIFY(file.open(QIODevice::ReadOnly)); + QVERIFY(file.open(QIODevice::ReadOnly | QIODevice::Text)); while (!file.atEnd()) { QByteArray cmdstring = file.readLine().simplified(); if (cmdstring.startsWith('#')) @@ -215,7 +215,7 @@ void tst_lupdate::output_ts() QString lupdatecmd; QFile file(dir + "/lupdatecmd"); if (file.exists()) { - QVERIFY(file.open(QIODevice::ReadOnly)); + QVERIFY(file.open(QIODevice::ReadOnly | QIODevice::Text)); while (!file.atEnd()) { QByteArray cmdstring = file.readLine().simplified(); if (cmdstring.startsWith('#')) -- cgit v0.12 From cec18d91bfd113d5402e5fc45160a5225362dd4c Mon Sep 17 00:00:00 2001 From: Shane Kearns Date: Thu, 12 Nov 2009 17:45:55 +0100 Subject: Fix MWC warning Reviewed-by: Trust Me --- src/gui/painting/qpaintbuffer_p.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/painting/qpaintbuffer_p.h b/src/gui/painting/qpaintbuffer_p.h index adf0564..e100512 100644 --- a/src/gui/painting/qpaintbuffer_p.h +++ b/src/gui/painting/qpaintbuffer_p.h @@ -66,7 +66,7 @@ class QPaintBufferPlayback; class Q_GUI_EXPORT QPaintBuffer : public QPaintDevice { - Q_DECLARE_PRIVATE(QPaintBuffer); + Q_DECLARE_PRIVATE(QPaintBuffer) public: QPaintBuffer(); QPaintBuffer(const QPaintBuffer &other); -- cgit v0.12 From c460009821fd646355bb2cd3d1909992483a4678 Mon Sep 17 00:00:00 2001 From: Shane Kearns Date: Thu, 12 Nov 2009 19:21:25 +0100 Subject: Fix corelib def files for the new atomics implementation 4.6.0 has the wrong atomics implementation for symbian, as the team branch was not merged before the freeze. This updates the def files to match the implementation on the team branch so that it can be cherry-picked. Task-number: QTBUG-5752 Reviewed-by: Iain --- src/s60installs/bwins/QtCoreu.def | 3 +++ src/s60installs/eabi/QtCoreu.def | 15 +++++++++++---- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/src/s60installs/bwins/QtCoreu.def b/src/s60installs/bwins/QtCoreu.def index 146d47e..1218b75 100644 --- a/src/s60installs/bwins/QtCoreu.def +++ b/src/s60installs/bwins/QtCoreu.def @@ -4384,4 +4384,7 @@ EXPORTS ?staticMetaObject@QAbstractTableModel@@2UQMetaObject@@B @ 4383 NONAME ; struct QMetaObject const QAbstractTableModel::staticMetaObject ?staticMetaObject@QFile@@2UQMetaObject@@B @ 4384 NONAME ; struct QMetaObject const QFile::staticMetaObject ?staticMetaObject@QHistoryState@@2UQMetaObject@@B @ 4385 NONAME ; struct QMetaObject const QHistoryState::staticMetaObject + ?QBasicAtomicPointer_isFetchAndAddNative@@YA_NXZ @ 4386 NONAME ; bool QBasicAtomicPointer_isFetchAndAddNative(void) + ?QBasicAtomicPointer_isFetchAndStoreNative@@YA_NXZ @ 4387 NONAME ; bool QBasicAtomicPointer_isFetchAndStoreNative(void) + ?QBasicAtomicPointer_isTestAndSetNative@@YA_NXZ @ 4388 NONAME ; bool QBasicAtomicPointer_isTestAndSetNative(void) diff --git a/src/s60installs/eabi/QtCoreu.def b/src/s60installs/eabi/QtCoreu.def index faf8b1e..99be68e 100644 --- a/src/s60installs/eabi/QtCoreu.def +++ b/src/s60installs/eabi/QtCoreu.def @@ -13,7 +13,7 @@ EXPORTS _Z11qt_int_sqrtj @ 12 NONAME _Z12noforcepointR11QTextStream @ 13 NONAME _Z12qSharedBuildv @ 14 NONAME - _Z12q_atomic_swpPVcc @ 15 NONAME + _Z12q_atomic_swpPVcc @ 15 NONAME ABSENT _Z12qt_s60GetRFsv @ 16 NONAME _Z13lowercasebaseR11QTextStream @ 17 NONAME _Z13qErrnoWarningPKcz @ 18 NONAME @@ -24,7 +24,7 @@ EXPORTS _Z15lowercasedigitsR11QTextStream @ 23 NONAME _Z15qAddPostRoutinePFvvE @ 24 NONAME _Z15qInitResourceIOv @ 25 NONAME - _Z15qt_atomic_yieldPi @ 26 NONAME + _Z15qt_atomic_yieldPi @ 26 NONAME ABSENT _Z15qt_error_stringi @ 27 NONAME _Z15uppercasedigitsR11QTextStream @ 28 NONAME _Z16qt_QString2HBufCRK7QString @ 29 NONAME @@ -706,7 +706,7 @@ EXPORTS _ZN15QAnimationGroupD0Ev @ 705 NONAME _ZN15QAnimationGroupD1Ev @ 706 NONAME _ZN15QAnimationGroupD2Ev @ 707 NONAME - _ZN15QBasicAtomicInt20fetchAndStoreOrderedEi @ 708 NONAME + _ZN15QBasicAtomicInt20fetchAndStoreOrderedEi @ 708 NONAME ABSENT _ZN15QDateTimeParser11parseFormatERK7QString @ 709 NONAME _ZN15QLinkedListData11shared_nullE @ 710 NONAME DATA 20 _ZN15QObjectUserDataD0Ev @ 711 NONAME @@ -3566,7 +3566,7 @@ EXPORTS inflateSync @ 3565 NONAME inflateSyncPoint @ 3566 NONAME qMetaTypeGuiHelper @ 3567 NONAME DATA 4 - q_atomic_lock @ 3568 NONAME DATA 1 + q_atomic_lock @ 3568 NONAME DATA 1 ABSENT qt_addObject @ 3569 NONAME qt_global_mutexpool @ 3570 NONAME DATA 4 qt_locale_initialized @ 3571 NONAME DATA 1 @@ -3612,4 +3612,11 @@ EXPORTS _ZNK13QStateMachine10isAnimatedEv @ 3611 NONAME _ZNK18QAbstractAnimation15currentLoopTimeEv @ 3612 NONAME _ZNK7QRegExp12captureCountEv @ 3613 NONAME + _Z38QBasicAtomicPointer_isTestAndSetNativev @ 3614 NONAME + _Z39QBasicAtomicPointer_isFetchAndAddNativev @ 3615 NONAME + _Z41QBasicAtomicPointer_isFetchAndStoreNativev @ 3616 NONAME + _ZN15QBasicAtomicInt18isTestAndSetNativeEv @ 3617 NONAME + _ZN15QBasicAtomicInt19isFetchAndAddNativeEv @ 3618 NONAME + _ZN15QBasicAtomicInt21isFetchAndStoreNativeEv @ 3619 NONAME + _ZN15QBasicAtomicInt25isReferenceCountingNativeEv @ 3620 NONAME -- cgit v0.12 From e7689dbab0e9a491d0ac6ead5b9412bf6ff86be0 Mon Sep 17 00:00:00 2001 From: "Eduardo M. Fleury" Date: Wed, 11 Nov 2009 19:22:42 -0300 Subject: QGAL (Test): Fix order of parameters in QCOMPARE The order is relevant when the test fails and QTest prints the failure message refering to the values as the expected and actual ones. Signed-off-by: Eduardo M. Fleury Reviewed-by: Caio Marcelo de Oliveira Filho --- tests/auto/qgraphicsanchorlayout1/tst_qgraphicsanchorlayout1.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/auto/qgraphicsanchorlayout1/tst_qgraphicsanchorlayout1.cpp b/tests/auto/qgraphicsanchorlayout1/tst_qgraphicsanchorlayout1.cpp index 0fbd069..bca59c3 100644 --- a/tests/auto/qgraphicsanchorlayout1/tst_qgraphicsanchorlayout1.cpp +++ b/tests/auto/qgraphicsanchorlayout1/tst_qgraphicsanchorlayout1.cpp @@ -1722,7 +1722,7 @@ void tst_QGraphicsAnchorLayout1::testBasicLayout() QRectF expected = truncate(item.rect); QRectF actual = truncate(widgets[item.index]->geometry()); - QCOMPARE(expected, actual); + QCOMPARE(actual, expected); } // Test mirrored mode @@ -1739,7 +1739,7 @@ void tst_QGraphicsAnchorLayout1::testBasicLayout() QRectF expected = truncate(mirroredRect); QRectF actual = truncate(widgets[item.index]->geometry()); - QCOMPARE(expected, actual); + QCOMPARE(actual, expected); delete widgets[item.index]; } -- cgit v0.12 From 0f5a0ec164b3a5bc1f2a48ae56688a984b990bbd Mon Sep 17 00:00:00 2001 From: "Eduardo M. Fleury" Date: Tue, 10 Nov 2009 13:00:44 -0300 Subject: QGAL (Test): Add test to ensure persistency of user-defined spacing Currently the user-defined spacing is saved inside "AnchorData->prefSize". However this value may be modified if spacing is negative or if the anchor's policy is "QSizePolicy::Ignored". Signed-off-by: Eduardo M. Fleury Reviewed-by: Caio Marcelo de Oliveira Filho --- .../tst_qgraphicsanchorlayout.cpp | 26 ++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/tests/auto/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp b/tests/auto/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp index c7ed309..2ad024f 100644 --- a/tests/auto/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp +++ b/tests/auto/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp @@ -85,6 +85,7 @@ private slots: void simplificationVsOrder(); void parallelSimplificationOfCenter(); void simplificationVsRedundance(); + void spacingPersistency(); }; class RectWidget : public QGraphicsWidget @@ -1866,5 +1867,30 @@ void tst_QGraphicsAnchorLayout::simplificationVsRedundance() QCOMPARE(usedSimplex(l, Qt::Vertical), false); } +/* + Avoid regression where the saved prefSize would be lost. This was + solved by saving the original spacing in the QGraphicsAnchorPrivate class +*/ +void tst_QGraphicsAnchorLayout::spacingPersistency() +{ + QGraphicsWidget w; + QGraphicsWidget *a = createItem(); + QGraphicsAnchorLayout *l = new QGraphicsAnchorLayout(&w); + + l->addAnchors(l, a, Qt::Horizontal); + QGraphicsAnchor *anchor = l->anchor(l, Qt::AnchorLeft, a, Qt::AnchorLeft); + + anchor->setSpacing(-30); + QCOMPARE(anchor->spacing(), -30.0); + + anchor->setSpacing(30); + QCOMPARE(anchor->spacing(), 30.0); + + anchor->setSizePolicy(QSizePolicy::Ignored); + w.effectiveSizeHint(Qt::PreferredSize); + + QCOMPARE(anchor->spacing(), 30.0); +} + QTEST_MAIN(tst_QGraphicsAnchorLayout) #include "tst_qgraphicsanchorlayout.moc" -- cgit v0.12 From bf0e30ce2987a9e93369fe01ab0f01eeb1d3afdb Mon Sep 17 00:00:00 2001 From: "Eduardo M. Fleury" Date: Tue, 10 Nov 2009 15:51:53 -0300 Subject: QGAL: Update header documentation in QGALPrivate As part of the refactoring of the setSpacing logic, we are encoraging the analogy between the references to QGraphicsLayoutItem and to QGraphicsAnchor, from the AnchorData point of view. It happens that leaf anchors (ie, those that were not created by the simplification) either represent an item or an user-created anchor. This means that they should fetch their size information either from a QGraphicsLayoutItem (member AnchorData->item) or from a QGraphicsAnchor (member AnchorData->graphicsAnchor). Thus, I'm organizing the header to make it more consistent to the new concept. Signed-off-by: Eduardo M. Fleury Reviewed-by: Caio Marcelo de Oliveira Filho --- src/gui/graphicsview/qgraphicsanchorlayout_p.h | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/src/gui/graphicsview/qgraphicsanchorlayout_p.h b/src/gui/graphicsview/qgraphicsanchorlayout_p.h index 5f50c85..26df109 100644 --- a/src/gui/graphicsview/qgraphicsanchorlayout_p.h +++ b/src/gui/graphicsview/qgraphicsanchorlayout_p.h @@ -121,10 +121,10 @@ struct AnchorData : public QSimplexVariable { }; AnchorData() - : QSimplexVariable(), item(0), from(0), to(0), + : QSimplexVariable(), from(0), to(0), minSize(0), prefSize(0), maxSize(0), sizeAtMinimum(0), sizeAtPreferred(0), - sizeAtMaximum(0), + sizeAtMaximum(0), item(0), graphicsAnchor(0), skipInPreferred(0), type(Normal), hasSize(true), isLayoutAnchor(false), isCenterAnchor(false), orientation(0), @@ -152,27 +152,32 @@ struct AnchorData : public QSimplexVariable { hasSize = false; } - // Internal anchors have associated items - QGraphicsLayoutItem *item; - // Anchor is semantically directed AnchorVertex *from; AnchorVertex *to; - // Size restrictions of this edge. For anchors internal to items, these - // values are derived from the respective item size hints. For anchors - // that were added by users, these values are equal to the specified anchor - // size. + // Nominal sizes + // These are the intrinsic size restrictions for a given item. They are + // used as input for the calculation of the actual sizes. + // These values are filled by the refreshSizeHints method, based on the + // anchor size policy, the size hints of the item it (possibly) represents + // and the layout spacing information. qreal minSize; qreal prefSize; qreal maxSize; + // Calculated sizes // These attributes define which sizes should that anchor be in when the // layout is at its minimum, preferred or maximum sizes. Values are // calculated by the Simplex solver based on the current layout setup. qreal sizeAtMinimum; qreal sizeAtPreferred; qreal sizeAtMaximum; + + // References to the classes that represent this anchor in the public world + // An anchor may represent a LayoutItem, it may also be acessible externally + // through a GraphicsAnchor "handler". + QGraphicsLayoutItem *item; QGraphicsAnchor *graphicsAnchor; uint skipInPreferred : 1; -- cgit v0.12 From 6cc1703af1f403168b7251616a7685aa83de8caa Mon Sep 17 00:00:00 2001 From: "Eduardo M. Fleury" Date: Tue, 10 Nov 2009 16:55:43 -0300 Subject: QGAL: Move size information from AnchorData to QGraphicsAnchorPrivate To solve the spacing persistency bug, this commit saves the preferredSize (spacing) information inside QGraphicsAnchorPrivate. The problem started when we could not rely on "AnchorData->prefSize" to keep the spacing information for user-defined anchors. This happens because that member can be overriden if the spacing is negative (anchor is inverted) or its sizePolicy is of type "Ignored" (it is overriden by minSize). Then, to decide where to store it, we aimed to make something similar to what happens with item-internal anchors. Those can rely on their items to get fresh information regarding their size, so we decided that user-anchors (that don't have items, but do have QGraphicsAnchors) could read such information from there. This refactory also reduced the deep indirection that existed in the "QGraphicsAnchor->setSpacing" call. Previously it would call internal layout methods to do some black magic, that's now gone. As the spacing information is now stored in the anchor itself, it can do pretty much all the work and, after that, just invalidate the layout. Also, moved information like "AnchorData->hasSize" to QGAnchor as its pretty much related to the preferredSize information itself. Signed-off-by: Eduardo M. Fleury Reviewed-by: Caio Marcelo de Oliveira Filho --- src/gui/graphicsview/qgraphicsanchorlayout.h | 1 + src/gui/graphicsview/qgraphicsanchorlayout_p.cpp | 148 +++++++++-------------- src/gui/graphicsview/qgraphicsanchorlayout_p.h | 25 ++-- 3 files changed, 66 insertions(+), 108 deletions(-) diff --git a/src/gui/graphicsview/qgraphicsanchorlayout.h b/src/gui/graphicsview/qgraphicsanchorlayout.h index 01c3a86..1a0c458 100644 --- a/src/gui/graphicsview/qgraphicsanchorlayout.h +++ b/src/gui/graphicsview/qgraphicsanchorlayout.h @@ -76,6 +76,7 @@ private: Q_DECLARE_PRIVATE(QGraphicsAnchor) friend class QGraphicsAnchorLayoutPrivate; + friend class AnchorData; }; class Q_GUI_EXPORT QGraphicsAnchorLayout : public QGraphicsLayout diff --git a/src/gui/graphicsview/qgraphicsanchorlayout_p.cpp b/src/gui/graphicsview/qgraphicsanchorlayout_p.cpp index 182594e..872fecb 100644 --- a/src/gui/graphicsview/qgraphicsanchorlayout_p.cpp +++ b/src/gui/graphicsview/qgraphicsanchorlayout_p.cpp @@ -55,7 +55,8 @@ QT_BEGIN_NAMESPACE QGraphicsAnchorPrivate::QGraphicsAnchorPrivate(int version) : QObjectPrivate(version), layoutPrivate(0), data(0), - sizePolicy(QSizePolicy::Fixed) + sizePolicy(QSizePolicy::Fixed), preferredSize(0), + hasSize(true), reversed(false) { } @@ -76,31 +77,60 @@ void QGraphicsAnchorPrivate::setSizePolicy(QSizePolicy::Policy policy) void QGraphicsAnchorPrivate::setSpacing(qreal value) { - if (data) { - layoutPrivate->setAnchorSize(data, &value); - } else { + if (!data) { qWarning("QGraphicsAnchor::setSpacing: The anchor does not exist."); + return; } + + const qreal rawValue = reversed ? -preferredSize : preferredSize; + if (hasSize && (rawValue == value)) + return; + + // The anchor has an user-defined size + hasSize = true; + + // The simplex solver cannot handle negative sizes. To workaround that, + // if value is less than zero, we reverse the anchor and set the absolute + // value; + if (value >= 0) { + preferredSize = value; + if (reversed) + qSwap(data->from, data->to); + reversed = false; + } else { + preferredSize = -value; + if (!reversed) + qSwap(data->from, data->to); + reversed = true; + } + + layoutPrivate->q_func()->invalidate(); } void QGraphicsAnchorPrivate::unsetSpacing() { - if (data) { - layoutPrivate->setAnchorSize(data, 0); - } else { + if (!data) { qWarning("QGraphicsAnchor::setSpacing: The anchor does not exist."); + return; } + + // Return to standard direction + hasSize = false; + if (reversed) + qSwap(data->from, data->to); + reversed = false; + + layoutPrivate->q_func()->invalidate(); } qreal QGraphicsAnchorPrivate::spacing() const { - qreal size = 0; - if (data) { - layoutPrivate->anchorSize(data, 0, &size, 0); - } else { + if (!data) { qWarning("QGraphicsAnchor::setSpacing: The anchor does not exist."); + return 0; } - return size; + + return reversed ? -preferredSize : preferredSize; } @@ -146,8 +176,8 @@ bool AnchorData::refreshSizeHints(const QLayoutStyleInfo *styleInfo) qreal prefSizeHint; qreal maxSizeHint; - // It is an internal anchor if (item) { + // It is an internal anchor, fetch size information from the item if (isLayoutAnchor) { minSize = 0; prefSize = 0; @@ -175,14 +205,16 @@ bool AnchorData::refreshSizeHints(const QLayoutStyleInfo *styleInfo) } } } else { + // It is a user-created anchor, fetch size information from the associated QGraphicsAnchor Q_ASSERT(graphicsAnchor); - policy = graphicsAnchor->sizePolicy(); + QGraphicsAnchorPrivate *anchorPrivate = graphicsAnchor->d_func(); + policy = anchorPrivate->sizePolicy; minSizeHint = 0; - if (hasSize) { + if (anchorPrivate->hasSize) { // One can only configure the preferred size of a normal anchor. Their minimum and // maximum "size hints" are always 0 and QWIDGETSIZE_MAX, correspondingly. However, // their effective size hints might be narrowed down due to their size policies. - prefSizeHint = prefSize; + prefSizeHint = anchorPrivate->preferredSize; } else { const Qt::Orientation orient = Qt::Orientation(QGraphicsAnchorLayoutPrivate::edgeOrientation(from->m_edge) + 1); qreal s = styleInfo->defaultSpacing(orient); @@ -1565,7 +1597,13 @@ QGraphicsAnchor *QGraphicsAnchorLayoutPrivate::addAnchor(QGraphicsLayoutItem *fi correctEdgeDirection(firstItem, firstEdge, secondItem, secondEdge); AnchorData *data = new AnchorData; - if (!spacing) { + QGraphicsAnchor *graphicsAnchor = acquireGraphicsAnchor(data); + + addAnchor_helper(firstItem, firstEdge, secondItem, secondEdge, data); + + if (spacing) { + graphicsAnchor->setSpacing(*spacing); + } else { // If firstItem or secondItem is the layout itself, the spacing will default to 0. // Otherwise, the following matrix is used (questionmark means that the spacing // is queried from the style): @@ -1578,22 +1616,13 @@ QGraphicsAnchor *QGraphicsAnchorLayoutPrivate::addAnchor(QGraphicsLayoutItem *fi || secondItem == q || pickEdge(firstEdge, Horizontal) == Qt::AnchorHorizontalCenter || oppositeEdge(firstEdge) != secondEdge) { - data->setPreferredSize(0); + graphicsAnchor->setSpacing(0); } else { - data->unsetSize(); + graphicsAnchor->unsetSpacing(); } - addAnchor_helper(firstItem, firstEdge, secondItem, secondEdge, data); - - } else if (*spacing >= 0) { - data->setPreferredSize(*spacing); - addAnchor_helper(firstItem, firstEdge, secondItem, secondEdge, data); - - } else { - data->setPreferredSize(-*spacing); - addAnchor_helper(secondItem, secondEdge, firstItem, firstEdge, data); } - return acquireGraphicsAnchor(data); + return graphicsAnchor; } void QGraphicsAnchorLayoutPrivate::addAnchor_helper(QGraphicsLayoutItem *firstItem, @@ -1753,67 +1782,6 @@ void QGraphicsAnchorLayoutPrivate::removeAnchor_helper(AnchorVertex *v1, AnchorV removeInternalVertex(v2->m_item, v2->m_edge); } -/*! - \internal - Only called from outside. (calls invalidate()) -*/ -void QGraphicsAnchorLayoutPrivate::setAnchorSize(AnchorData *data, const qreal *anchorSize) -{ - Q_Q(QGraphicsAnchorLayout); - // ### we can avoid restoration if we really want to, but we would have to - // search recursively through all composite anchors - Q_ASSERT(data); - restoreSimplifiedGraph(edgeOrientation(data->from->m_edge)); - - QGraphicsLayoutItem *firstItem = data->from->m_item; - QGraphicsLayoutItem *secondItem = data->to->m_item; - Qt::AnchorPoint firstEdge = data->from->m_edge; - Qt::AnchorPoint secondEdge = data->to->m_edge; - - // Use heuristics to find out what the user meant with this anchor. - correctEdgeDirection(firstItem, firstEdge, secondItem, secondEdge); - if (data->from->m_item != firstItem) - qSwap(data->from, data->to); - - if (anchorSize) { - // ### The current implementation makes "setAnchorSize" behavior - // dependent on the argument order for cases where we have - // no heuristic. Ie. two widgets, same anchor point. - - // We cannot have negative sizes inside the graph. This would cause - // the simplex solver to fail because all simplex variables are - // positive by definition. - // "negative spacing" is handled by inverting the standard item order. - if (*anchorSize >= 0) { - data->setPreferredSize(*anchorSize); - } else { - data->setPreferredSize(-*anchorSize); - qSwap(data->from, data->to); - } - } else { - data->unsetSize(); - } - q->invalidate(); -} - -void QGraphicsAnchorLayoutPrivate::anchorSize(const AnchorData *data, - qreal *minSize, - qreal *prefSize, - qreal *maxSize) const -{ - Q_ASSERT(minSize || prefSize || maxSize); - Q_ASSERT(data); - QGraphicsAnchorLayoutPrivate *that = const_cast(this); - that->restoreSimplifiedGraph(Orientation(data->orientation)); - - if (minSize) - *minSize = data->minSize; - if (prefSize) - *prefSize = data->prefSize; - if (maxSize) - *maxSize = data->maxSize; -} - AnchorVertex *QGraphicsAnchorLayoutPrivate::addInternalVertex(QGraphicsLayoutItem *item, Qt::AnchorPoint edge) { diff --git a/src/gui/graphicsview/qgraphicsanchorlayout_p.h b/src/gui/graphicsview/qgraphicsanchorlayout_p.h index 26df109..cb8c4dd 100644 --- a/src/gui/graphicsview/qgraphicsanchorlayout_p.h +++ b/src/gui/graphicsview/qgraphicsanchorlayout_p.h @@ -126,7 +126,7 @@ struct AnchorData : public QSimplexVariable { sizeAtMinimum(0), sizeAtPreferred(0), sizeAtMaximum(0), item(0), graphicsAnchor(0), skipInPreferred(0), - type(Normal), hasSize(true), isLayoutAnchor(false), + type(Normal), isLayoutAnchor(false), isCenterAnchor(false), orientation(0), dependency(Independent) {} @@ -141,17 +141,6 @@ struct AnchorData : public QSimplexVariable { QString name; #endif - inline void setPreferredSize(qreal size) - { - prefSize = size; - hasSize = true; - } - - inline void unsetSize() - { - hasSize = false; - } - // Anchor is semantically directed AnchorVertex *from; AnchorVertex *to; @@ -182,7 +171,6 @@ struct AnchorData : public QSimplexVariable { uint skipInPreferred : 1; uint type : 2; // either Normal, Sequential or Parallel - uint hasSize : 1; // if false, get size from style. uint isLayoutAnchor : 1; // if this anchor is an internal layout anchor uint isCenterAnchor : 1; uint orientation : 1; @@ -355,7 +343,13 @@ public: QGraphicsAnchorLayoutPrivate *layoutPrivate; AnchorData *data; + + // Size information for user controlled anchor QSizePolicy::Policy sizePolicy; + qreal preferredSize; + + uint hasSize : 1; // if false, get size from style. + uint reversed : 1; // if true, the anchor was inverted to keep its value positive }; @@ -450,11 +444,6 @@ public: void removeAnchor(AnchorVertex *firstVertex, AnchorVertex *secondVertex); void removeAnchor_helper(AnchorVertex *v1, AnchorVertex *v2); - void setAnchorSize(AnchorData *data, const qreal *anchorSize); - void anchorSize(const AnchorData *data, - qreal *minSize = 0, - qreal *prefSize = 0, - qreal *maxSize = 0) const; void removeAnchors(QGraphicsLayoutItem *item); -- cgit v0.12 From 604b6d9d00e36de7ed516e4fa5c277946216f1e9 Mon Sep 17 00:00:00 2001 From: "Eduardo M. Fleury" Date: Thu, 12 Nov 2009 13:48:54 -0300 Subject: QGAL: Update code documentation Signed-off-by: Eduardo M. Fleury Reviewed-by: Caio Marcelo de Oliveira Filho --- src/gui/graphicsview/qgraphicsanchorlayout_p.cpp | 39 ++++++++++++++++-------- 1 file changed, 26 insertions(+), 13 deletions(-) diff --git a/src/gui/graphicsview/qgraphicsanchorlayout_p.cpp b/src/gui/graphicsview/qgraphicsanchorlayout_p.cpp index 872fecb..a15e473 100644 --- a/src/gui/graphicsview/qgraphicsanchorlayout_p.cpp +++ b/src/gui/graphicsview/qgraphicsanchorlayout_p.cpp @@ -1537,15 +1537,21 @@ void QGraphicsAnchorLayoutPrivate::removeCenterConstraints(QGraphicsLayoutItem * /*! * \internal + * Implements the high level "addAnchor" feature. Called by the public API + * addAnchor method. * - * Helper function that is called from the anchor functions in the public API. - * If \a spacing is 0, it will pick up the spacing defined by the style. + * The optional \a spacing argument defines the size of the anchor. If not provided, + * the anchor size is either 0 or not-set, depending on type of anchor created (see + * matrix below). + * + * All anchors that remain with size not-set will assume the standard spacing, + * set either by the layout style or through the "setSpacing" layout API. */ QGraphicsAnchor *QGraphicsAnchorLayoutPrivate::addAnchor(QGraphicsLayoutItem *firstItem, - Qt::AnchorPoint firstEdge, - QGraphicsLayoutItem *secondItem, - Qt::AnchorPoint secondEdge, - qreal *spacing) + Qt::AnchorPoint firstEdge, + QGraphicsLayoutItem *secondItem, + Qt::AnchorPoint secondEdge, + qreal *spacing) { Q_Q(QGraphicsAnchorLayout); if ((firstItem == 0) || (secondItem == 0)) { @@ -1625,11 +1631,20 @@ QGraphicsAnchor *QGraphicsAnchorLayoutPrivate::addAnchor(QGraphicsLayoutItem *fi return graphicsAnchor; } +/* + \internal + + This method adds an AnchorData to the internal graph. It is responsible for doing + the boilerplate part of such task. + + If another AnchorData exists between the mentioned vertices, it is deleted and + the new one is inserted. +*/ void QGraphicsAnchorLayoutPrivate::addAnchor_helper(QGraphicsLayoutItem *firstItem, - Qt::AnchorPoint firstEdge, - QGraphicsLayoutItem *secondItem, - Qt::AnchorPoint secondEdge, - AnchorData *data) + Qt::AnchorPoint firstEdge, + QGraphicsLayoutItem *secondItem, + Qt::AnchorPoint secondEdge, + AnchorData *data) { Q_Q(QGraphicsAnchorLayout); @@ -1639,13 +1654,11 @@ void QGraphicsAnchorLayoutPrivate::addAnchor_helper(QGraphicsLayoutItem *firstIt // anchor manipulation always happen in the full graph restoreSimplifiedGraph(orientation); - // Is the Vertex (firstItem, firstEdge) already represented in our - // internal structure? + // Create or increase the reference count for the related vertices. AnchorVertex *v1 = addInternalVertex(firstItem, firstEdge); AnchorVertex *v2 = addInternalVertex(secondItem, secondEdge); // Remove previous anchor - // ### Could we update the existing edgeData rather than creating a new one? if (graph[orientation].edgeData(v1, v2)) { removeAnchor_helper(v1, v2); } -- cgit v0.12 From 41cc464ec332033127b88433ffa0a2a990fec83d Mon Sep 17 00:00:00 2001 From: Caio Marcelo de Oliveira Filho Date: Wed, 11 Nov 2009 22:09:11 -0300 Subject: QGAL: fix update size hints logic in parallel anchors When filling sizeAt* values for parallel anchors, we have to identify the case when the second anchor in the parallel doesn't have the same direction as the parallel itself. However, relying on the parallel group vertices to identify this case is not safe, because after a parallel group a new vertex simplification can happen. So, the comparing the 'from' with the first edge is the correct way to verify whether the second is backwards. Code was fixed to follow that. Note that, without negative spacing the case "out-of-order" for parallels is only the trivial case (size == 0). Signed-off-by: Caio Marcelo de Oliveira Filho Reviewed-by: Eduardo M. Fleury --- src/gui/graphicsview/qgraphicsanchorlayout_p.cpp | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/src/gui/graphicsview/qgraphicsanchorlayout_p.cpp b/src/gui/graphicsview/qgraphicsanchorlayout_p.cpp index a15e473..8520ebd 100644 --- a/src/gui/graphicsview/qgraphicsanchorlayout_p.cpp +++ b/src/gui/graphicsview/qgraphicsanchorlayout_p.cpp @@ -256,8 +256,13 @@ void ParallelAnchorData::updateChildrenSizes() firstEdge->sizeAtPreferred = sizeAtPreferred; firstEdge->sizeAtMaximum = sizeAtMaximum; - const bool secondFwd = (secondEdge->from == from); - if (secondFwd) { + // We have the convention that the first children will define the direction of the + // pararell group. So we can check whether the second edge is "forward" in relation + // to the group if it have the same direction as the first edge. Note that we don't + // use 'this->from' because it might be changed by vertex simplification. + const bool secondForward = (firstEdge->from == secondEdge->from); + + if (secondForward) { secondEdge->sizeAtMinimum = sizeAtMinimum; secondEdge->sizeAtPreferred = sizeAtPreferred; secondEdge->sizeAtMaximum = sizeAtMaximum; @@ -287,10 +292,12 @@ bool ParallelAnchorData::refreshSizeHints_helper(const QLayoutStyleInfo *styleIn // Account for parallel anchors where the second edge is backwards. // We rely on the fact that a forward anchor of sizes min, pref, max is equivalent // to a backwards anchor of size (-max, -pref, -min) - const bool secondFwd = (secondEdge->from == from); - const qreal secondMin = secondFwd ? secondEdge->minSize : -secondEdge->maxSize; - const qreal secondPref = secondFwd ? secondEdge->prefSize : -secondEdge->prefSize; - const qreal secondMax = secondFwd ? secondEdge->maxSize : -secondEdge->minSize; + + // Also see comments in updateChildrenSizes(). + const bool secondForward = (firstEdge->from == secondEdge->from); + const qreal secondMin = secondForward ? secondEdge->minSize : -secondEdge->maxSize; + const qreal secondPref = secondForward ? secondEdge->prefSize : -secondEdge->prefSize; + const qreal secondMax = secondForward ? secondEdge->maxSize : -secondEdge->minSize; minSize = qMax(firstEdge->minSize, secondMin); maxSize = qMin(firstEdge->maxSize, secondMax); -- cgit v0.12 From 7a11b8ca00f49e22cfd3706b59606775d6792e29 Mon Sep 17 00:00:00 2001 From: Caio Marcelo de Oliveira Filho Date: Wed, 11 Nov 2009 16:37:53 -0300 Subject: QGAL: remove the caching of simplified graph After discussion with Jan-Arve, we decided to remove for good the caching of simplified graph. This avoided recalculating the simplification (but not the simplex) in some situations. Since vertex simplification, this was temporarily disabled already. To know whether if we could the cached version or not, we needed to track individual anchors to see whether they reached size 0 or they were 0 and changed the size. This is because the vertex simplification depend on that fact. Now the simplified version of the graph exists only during the execution of calculateGraphs() function. This and next commits clear up the code to take advantage of that fact. Signed-off-by: Caio Marcelo de Oliveira Filho Reviewed-by: Eduardo M. Fleury --- src/gui/graphicsview/qgraphicsanchorlayout.cpp | 3 - src/gui/graphicsview/qgraphicsanchorlayout_p.cpp | 89 ++++++------------------ src/gui/graphicsview/qgraphicsanchorlayout_p.h | 2 - 3 files changed, 22 insertions(+), 72 deletions(-) diff --git a/src/gui/graphicsview/qgraphicsanchorlayout.cpp b/src/gui/graphicsview/qgraphicsanchorlayout.cpp index 872ec3c..7e5929e 100644 --- a/src/gui/graphicsview/qgraphicsanchorlayout.cpp +++ b/src/gui/graphicsview/qgraphicsanchorlayout.cpp @@ -477,9 +477,6 @@ void QGraphicsAnchorLayout::removeAt(int index) return; // Removing an item affects both horizontal and vertical graphs - d->restoreSimplifiedGraph(QGraphicsAnchorLayoutPrivate::Horizontal); - d->restoreSimplifiedGraph(QGraphicsAnchorLayoutPrivate::Vertical); - d->removeCenterConstraints(item, QGraphicsAnchorLayoutPrivate::Horizontal); d->removeCenterConstraints(item, QGraphicsAnchorLayoutPrivate::Vertical); d->removeAnchors(item); diff --git a/src/gui/graphicsview/qgraphicsanchorlayout_p.cpp b/src/gui/graphicsview/qgraphicsanchorlayout_p.cpp index 8520ebd..5b1e36c 100644 --- a/src/gui/graphicsview/qgraphicsanchorlayout_p.cpp +++ b/src/gui/graphicsview/qgraphicsanchorlayout_p.cpp @@ -62,8 +62,6 @@ QGraphicsAnchorPrivate::QGraphicsAnchorPrivate(int version) QGraphicsAnchorPrivate::~QGraphicsAnchorPrivate() { - // ### - layoutPrivate->restoreSimplifiedGraph(QGraphicsAnchorLayoutPrivate::Orientation(data->orientation)); layoutPrivate->removeAnchor(data->from, data->to); } @@ -529,7 +527,6 @@ QGraphicsAnchorLayoutPrivate::QGraphicsAnchorLayoutPrivate() interpolationProgress[i] = -1; spacings[i] = -1; - graphSimplified[i] = false; graphHasConflicts[i] = false; layoutFirstVertex[i] = 0; @@ -735,16 +732,18 @@ static AnchorData *createSequence(Graph *graph, */ bool QGraphicsAnchorLayoutPrivate::simplifyGraph(Orientation orientation) { - static bool noSimplification = !qgetenv("QT_ANCHORLAYOUT_NO_SIMPLIFICATION").isEmpty(); - if (noSimplification || items.isEmpty()) + if (items.isEmpty()) return true; - if (graphSimplified[orientation]) - return true; - -#if 0 +#if defined(QT_DEBUG) && 0 qDebug("Simplifying Graph for %s", orientation == Horizontal ? "Horizontal" : "Vertical"); + + static int count = 0; + if (orientation == Horizontal) { + count++; + dumpGraph(QString::fromAscii("%1-full").arg(count)); + } #endif // Vertex simplification @@ -762,13 +761,16 @@ bool QGraphicsAnchorLayoutPrivate::simplifyGraph(Orientation orientation) // Note that if we are not feasible, we fallback and make sure that the graph is fully restored if (!feasible) { - graphSimplified[orientation] = true; restoreSimplifiedGraph(orientation); restoreVertices(orientation); return false; } - graphSimplified[orientation] = true; +#if defined(QT_DEBUG) && 0 + dumpGraph(QString::fromAscii("%1-simplified-%2").arg(count).arg( + QString::fromAscii(orientation == Horizontal ? "Horizontal" : "Vertical"))); +#endif + return true; } @@ -1173,10 +1175,6 @@ void QGraphicsAnchorLayoutPrivate::restoreSimplifiedConstraints(ParallelAnchorDa void QGraphicsAnchorLayoutPrivate::restoreSimplifiedGraph(Orientation orientation) { - if (!graphSimplified[orientation]) - return; - graphSimplified[orientation] = false; - #if 0 qDebug("Restoring Simplified Graph for %s", orientation == Horizontal ? "Horizontal" : "Vertical"); @@ -1331,8 +1329,6 @@ void QGraphicsAnchorLayoutPrivate::deleteLayoutEdges() void QGraphicsAnchorLayoutPrivate::createItemEdges(QGraphicsLayoutItem *item) { - Q_ASSERT(!graphSimplified[Horizontal] && !graphSimplified[Vertical]); - items.append(item); // Create horizontal and vertical internal anchors for the item and @@ -1375,8 +1371,6 @@ void QGraphicsAnchorLayoutPrivate::createCenterAnchors( return; } - Q_ASSERT(!graphSimplified[orientation]); - // Check if vertex already exists if (internalVertex(item, centerEdge)) return; @@ -1443,8 +1437,6 @@ void QGraphicsAnchorLayoutPrivate::removeCenterAnchors( return; } - Q_ASSERT(!graphSimplified[orientation]); - // Orientation code Qt::AnchorPoint firstEdge; Qt::AnchorPoint lastEdge; @@ -1512,8 +1504,6 @@ void QGraphicsAnchorLayoutPrivate::removeCenterAnchors( void QGraphicsAnchorLayoutPrivate::removeCenterConstraints(QGraphicsLayoutItem *item, Orientation orientation) { - Q_ASSERT(!graphSimplified[orientation]); - // Remove the item center constraints associated to this item // ### This is a temporary solution. We should probably use a better // data structure to hold items and/or their associated constraints @@ -1579,10 +1569,6 @@ QGraphicsAnchor *QGraphicsAnchorLayoutPrivate::addAnchor(QGraphicsLayoutItem *fi return 0; } - // Guarantee that the graph is no simplified when adding this anchor, - // anchor manipulation always happen in the full graph - restoreSimplifiedGraph(edgeOrientation(firstEdge)); - // In QGraphicsAnchorLayout, items are represented in its internal // graph as four anchors that connect: // - Left -> HCenter @@ -1592,12 +1578,10 @@ QGraphicsAnchor *QGraphicsAnchorLayoutPrivate::addAnchor(QGraphicsLayoutItem *fi // Ensure that the internal anchors have been created for both items. if (firstItem != q && !items.contains(firstItem)) { - restoreSimplifiedGraph(edgeOrientation(firstEdge) == Horizontal ? Vertical : Horizontal); createItemEdges(firstItem); addChildLayoutItem(firstItem); } if (secondItem != q && !items.contains(secondItem)) { - restoreSimplifiedGraph(edgeOrientation(firstEdge) == Horizontal ? Vertical : Horizontal); createItemEdges(secondItem); addChildLayoutItem(secondItem); } @@ -1657,10 +1641,6 @@ void QGraphicsAnchorLayoutPrivate::addAnchor_helper(QGraphicsLayoutItem *firstIt const Orientation orientation = edgeOrientation(firstEdge); - // Guarantee that the graph is no simplified when adding this anchor, - // anchor manipulation always happen in the full graph - restoreSimplifiedGraph(orientation); - // Create or increase the reference count for the related vertices. AnchorVertex *v1 = addInternalVertex(firstItem, firstEdge); AnchorVertex *v2 = addInternalVertex(secondItem, secondEdge); @@ -1696,15 +1676,13 @@ QGraphicsAnchor *QGraphicsAnchorLayoutPrivate::getAnchor(QGraphicsLayoutItem *fi QGraphicsLayoutItem *secondItem, Qt::AnchorPoint secondEdge) { - Orientation orient = edgeOrientation(firstEdge); - restoreSimplifiedGraph(orient); - + const Orientation orientation = edgeOrientation(firstEdge); AnchorVertex *v1 = internalVertex(firstItem, firstEdge); AnchorVertex *v2 = internalVertex(secondItem, secondEdge); QGraphicsAnchor *graphicsAnchor = 0; - AnchorData *data = graph[orient].edgeData(v1, v2); + AnchorData *data = graph[orientation].edgeData(v1, v2); if (data) graphicsAnchor = acquireGraphicsAnchor(data); return graphicsAnchor; @@ -1789,12 +1767,9 @@ void QGraphicsAnchorLayoutPrivate::removeAnchor(AnchorVertex *firstVertex, void QGraphicsAnchorLayoutPrivate::removeAnchor_helper(AnchorVertex *v1, AnchorVertex *v2) { Q_ASSERT(v1 && v2); - // Guarantee that the graph is no simplified when removing this anchor, - // anchor manipulation always happen in the full graph - Orientation o = edgeOrientation(v1->m_edge); - restoreSimplifiedGraph(o); // Remove edge from graph + const Orientation o = edgeOrientation(v1->m_edge); graph[o].removeEdge(v1, v2); // Decrease vertices reference count (may trigger a deletion) @@ -1867,8 +1842,6 @@ void QGraphicsAnchorLayoutPrivate::removeVertex(QGraphicsLayoutItem *item, Qt::A void QGraphicsAnchorLayoutPrivate::removeAnchors(QGraphicsLayoutItem *item) { - Q_ASSERT(!graphSimplified[Horizontal] && !graphSimplified[Vertical]); - // remove the center anchor first!! removeCenterAnchors(item, Qt::AnchorHorizontalCenter, false); removeVertex(item, Qt::AnchorLeft); @@ -1971,20 +1944,8 @@ void QGraphicsAnchorLayoutPrivate::calculateGraphs() { if (!calculateGraphCacheDirty) return; - -#if defined(QT_DEBUG) && 0 - static int count = 0; - count++; - dumpGraph(QString::fromAscii("%1-before").arg(count)); -#endif - calculateGraphs(Horizontal); calculateGraphs(Vertical); - -#if defined(QT_DEBUG) && 0 - dumpGraph(QString::fromAscii("%1-after").arg(count)); -#endif - calculateGraphCacheDirty = false; } @@ -2032,18 +1993,9 @@ void QGraphicsAnchorLayoutPrivate::calculateGraphs( lastCalculationUsedSimplex[orientation] = false; #endif - // ### This is necessary because now we do vertex simplification, we still don't know - // differentiate between invalidate()s that doesn't need resimplification and those which - // need. For example, when size hint of an item changes, this may cause an anchor to reach 0 or to - // leave 0 and get a size. In both cases we need resimplify. - // - // ### one possible solution would be tracking all the 0-sized anchors, if this set change, we need - // resimplify. - restoreSimplifiedGraph(orientation); + static bool simplificationEnabled = qgetenv("QT_ANCHORLAYOUT_NO_SIMPLIFICATION").isEmpty(); - // Reset the nominal sizes of each anchor based on the current item sizes. This function - // works with both simplified and non-simplified graphs, so it'll work when the - // simplification is going to be reused. + // Reset the nominal sizes of each anchor based on the current item sizes. if (!refreshAllSizeHints(orientation)) { qWarning("QGraphicsAnchorLayout: anchor setup is not feasible."); graphHasConflicts[orientation] = true; @@ -2051,7 +2003,7 @@ void QGraphicsAnchorLayoutPrivate::calculateGraphs( } // Simplify the graph - if (!simplifyGraph(orientation)) { + if (simplificationEnabled && !simplifyGraph(orientation)) { qWarning("QGraphicsAnchorLayout: anchor setup is not feasible."); graphHasConflicts[orientation] = true; return; @@ -2115,6 +2067,9 @@ void QGraphicsAnchorLayoutPrivate::calculateGraphs( qDeleteAll(constraints[orientation]); constraints[orientation].clear(); graphPaths[orientation].clear(); // ### + + if (simplificationEnabled) + restoreSimplifiedGraph(orientation); } /*! diff --git a/src/gui/graphicsview/qgraphicsanchorlayout_p.h b/src/gui/graphicsview/qgraphicsanchorlayout_p.h index cb8c4dd..7e2e00e 100644 --- a/src/gui/graphicsview/qgraphicsanchorlayout_p.h +++ b/src/gui/graphicsview/qgraphicsanchorlayout_p.h @@ -570,8 +570,6 @@ public: Interval interpolationInterval[2]; qreal interpolationProgress[2]; - // ### - bool graphSimplified[2]; bool graphHasConflicts[2]; QSet m_floatItems[2]; -- cgit v0.12 From e52ce79b8eee44742d71bf945e806aa2db06818b Mon Sep 17 00:00:00 2001 From: Caio Marcelo de Oliveira Filho Date: Thu, 12 Nov 2009 10:30:15 -0300 Subject: QGAL: clean up interpolation code Now the interpolation doesn't need to know how to traverse complex anchors, since when it runs, the graph is not simplified anymore. This commit removes unnecessary code for dealing with that. Signed-off-by: Caio Marcelo de Oliveira Filho Reviewed-by: Eduardo M. Fleury --- src/gui/graphicsview/qgraphicsanchorlayout_p.cpp | 109 ++++------------------- src/gui/graphicsview/qgraphicsanchorlayout_p.h | 2 - 2 files changed, 16 insertions(+), 95 deletions(-) diff --git a/src/gui/graphicsview/qgraphicsanchorlayout_p.cpp b/src/gui/graphicsview/qgraphicsanchorlayout_p.cpp index 5b1e36c..7646d4c 100644 --- a/src/gui/graphicsview/qgraphicsanchorlayout_p.cpp +++ b/src/gui/graphicsview/qgraphicsanchorlayout_p.cpp @@ -2564,21 +2564,6 @@ void QGraphicsAnchorLayoutPrivate::setItemsGeometries(const QRectF &geom) } /*! - \internal - - Fill the distance in the vertex and in the sub-vertices if its a combined vertex. -*/ -static void setVertexDistance(AnchorVertex *v, qreal distance) -{ - v->distance = distance; - if (v->m_type == AnchorVertex::Pair) { - AnchorVertexPair *pair = static_cast(v); - setVertexDistance(pair->m_first, distance); - setVertexDistance(pair->m_second, distance); - } -} - -/*! \internal Calculate the position of each vertex based on the paths to each of @@ -2593,7 +2578,7 @@ void QGraphicsAnchorLayoutPrivate::calculateVertexPositions( // Get root vertex AnchorVertex *root = layoutFirstVertex[orientation]; - setVertexDistance(root, 0); + root->distance = 0; visited.insert(root); // Add initial edges to the queue @@ -2604,16 +2589,12 @@ void QGraphicsAnchorLayoutPrivate::calculateVertexPositions( // Do initial calculation required by "interpolateEdge()" setupEdgesInterpolation(orientation); - // Traverse the graph and calculate vertex positions, we need to - // visit all pairs since each of them could have a sequential - // anchor inside, which hides more vertices. + // Traverse the graph and calculate vertex positions while (!queue.isEmpty()) { QPair pair = queue.dequeue(); AnchorData *edge = graph[orientation].edgeData(pair.first, pair.second); - // Both vertices were interpolated, and the anchor itself can't have other - // anchors inside (it's not a complex anchor). - if (edge->type == AnchorData::Normal && visited.contains(pair.second)) + if (visited.contains(pair.second)) continue; visited.insert(pair.second); @@ -2653,24 +2634,20 @@ void QGraphicsAnchorLayoutPrivate::setupEdgesInterpolation( } /*! - \internal - - Calculate the current Edge size based on the current Layout size and the - size the edge is supposed to have when the layout is at its: + \internal - - minimum size, - - preferred size, - - maximum size. + Calculate the current Edge size based on the current Layout size and the + size the edge is supposed to have when the layout is at its: - These three key values are calculated in advance using linear - programming (more expensive) or the simplification algorithm, then - subsequential resizes of the parent layout require a simple - interpolation. + - minimum size, + - preferred size, + - maximum size. - If the edge is sequential or parallel, it's possible to have more - vertices to be initalized, so it calls specialized functions that - will recurse back to interpolateEdge(). - */ + These three key values are calculated in advance using linear + programming (more expensive) or the simplification algorithm, then + subsequential resizes of the parent layout require a simple + interpolation. +*/ void QGraphicsAnchorLayoutPrivate::interpolateEdge(AnchorVertex *base, AnchorData *edge) { const Orientation orientation = Orientation(edge->orientation); @@ -2684,64 +2661,10 @@ void QGraphicsAnchorLayoutPrivate::interpolateEdge(AnchorVertex *base, AnchorDat // Calculate the distance for the vertex opposite to the base if (edge->from == base) { - setVertexDistance(edge->to, base->distance + edgeDistance); + edge->to->distance = base->distance + edgeDistance; } else { - setVertexDistance(edge->from, base->distance - edgeDistance); - } - - // Process child anchors - if (edge->type == AnchorData::Sequential) - interpolateSequentialEdges(static_cast(edge)); - else if (edge->type == AnchorData::Parallel) - interpolateParallelEdges(static_cast(edge)); -} - -void QGraphicsAnchorLayoutPrivate::interpolateParallelEdges(ParallelAnchorData *data) -{ - // In parallels the boundary vertices are already calculate, we - // just need to look for sequential groups inside, because only - // them may have new vertices associated. - - // First edge - if (data->firstEdge->type == AnchorData::Sequential) - interpolateSequentialEdges(static_cast(data->firstEdge)); - else if (data->firstEdge->type == AnchorData::Parallel) - interpolateParallelEdges(static_cast(data->firstEdge)); - - // Second edge - if (data->secondEdge->type == AnchorData::Sequential) - interpolateSequentialEdges(static_cast(data->secondEdge)); - else if (data->secondEdge->type == AnchorData::Parallel) - interpolateParallelEdges(static_cast(data->secondEdge)); -} - -void QGraphicsAnchorLayoutPrivate::interpolateSequentialEdges(SequentialAnchorData *data) -{ - // This method is supposed to handle any sequential anchor, even out-of-order - // ones. However, in the current QGAL implementation we should get only the - // well behaved ones. - Q_ASSERT(data->m_edges.first()->from == data->from); - Q_ASSERT(data->m_edges.last()->to == data->to); - - // At this point, the two outter vertices already have their distance - // calculated. - // We use the first as the base to calculate the internal ones - - AnchorVertex *prev = data->from; - - for (int i = 0; i < data->m_edges.count() - 1; ++i) { - AnchorData *edge = data->m_edges.at(i); - interpolateEdge(prev, edge); - - // Use the recently calculated vertex as the base for the next one - const bool edgeIsForward = (edge->from == prev); - prev = edgeIsForward ? edge->to : edge->from; + edge->from->distance = base->distance - edgeDistance; } - - // Treat the last specially, since we already calculated it's end - // vertex, so it's only interesting if it's a complex one - if (data->m_edges.last()->type != AnchorData::Normal) - interpolateEdge(prev, data->m_edges.last()); } bool QGraphicsAnchorLayoutPrivate::solveMinMax(const QList &constraints, diff --git a/src/gui/graphicsview/qgraphicsanchorlayout_p.h b/src/gui/graphicsview/qgraphicsanchorlayout_p.h index 7e2e00e..fd82dd9 100644 --- a/src/gui/graphicsview/qgraphicsanchorlayout_p.h +++ b/src/gui/graphicsview/qgraphicsanchorlayout_p.h @@ -522,8 +522,6 @@ public: void calculateVertexPositions(Orientation orientation); void setupEdgesInterpolation(Orientation orientation); void interpolateEdge(AnchorVertex *base, AnchorData *edge); - void interpolateSequentialEdges(SequentialAnchorData *edge); - void interpolateParallelEdges(ParallelAnchorData *edge); // Linear Programming solver methods bool solveMinMax(const QList &constraints, -- cgit v0.12 From 3dcc9d6bc6385e2c4f4d7d7366c84b6dcc74508c Mon Sep 17 00:00:00 2001 From: Caio Marcelo de Oliveira Filho Date: Thu, 12 Nov 2009 12:21:51 -0300 Subject: QGAL: clean up size hint refresh code The code for refreshing size hints of items / user-created anchors now happens with a graph in full (not simplified). So we don't need to now how to refresh size hints for complex anchors. The code for refreshing complex anchors was used also to initialize the complex anchors (the '_helper' functions). Those were changed to calculateSizeHints() and refreshSizeHints() doesn't need to be virtual anymore. Signed-off-by: Caio Marcelo de Oliveira Filho Reviewed-by: Eduardo M. Fleury --- src/gui/graphicsview/qgraphicsanchorlayout_p.cpp | 78 +++++++----------------- src/gui/graphicsview/qgraphicsanchorlayout_p.h | 12 ++-- 2 files changed, 25 insertions(+), 65 deletions(-) diff --git a/src/gui/graphicsview/qgraphicsanchorlayout_p.cpp b/src/gui/graphicsview/qgraphicsanchorlayout_p.cpp index 7646d4c..2e80857 100644 --- a/src/gui/graphicsview/qgraphicsanchorlayout_p.cpp +++ b/src/gui/graphicsview/qgraphicsanchorlayout_p.cpp @@ -167,7 +167,7 @@ static void internalSizeHints(QSizePolicy::Policy policy, *prefSize = prefSizeHint; } -bool AnchorData::refreshSizeHints(const QLayoutStyleInfo *styleInfo) +void AnchorData::refreshSizeHints(const QLayoutStyleInfo *styleInfo) { QSizePolicy::Policy policy; qreal minSizeHint; @@ -182,7 +182,7 @@ bool AnchorData::refreshSizeHints(const QLayoutStyleInfo *styleInfo) maxSize = QWIDGETSIZE_MAX; if (isCenterAnchor) maxSize /= 2; - return true; + return; } else { if (orientation == QGraphicsAnchorLayoutPrivate::Horizontal) { policy = item->sizePolicy().horizontalPolicy(); @@ -244,8 +244,6 @@ bool AnchorData::refreshSizeHints(const QLayoutStyleInfo *styleInfo) sizeAtMinimum = prefSize; sizeAtPreferred = prefSize; sizeAtMaximum = prefSize; - - return true; } void ParallelAnchorData::updateChildrenSizes() @@ -274,18 +272,11 @@ void ParallelAnchorData::updateChildrenSizes() secondEdge->updateChildrenSizes(); } -bool ParallelAnchorData::refreshSizeHints(const QLayoutStyleInfo *styleInfo) +bool ParallelAnchorData::calculateSizeHints() { - return refreshSizeHints_helper(styleInfo); -} - -bool ParallelAnchorData::refreshSizeHints_helper(const QLayoutStyleInfo *styleInfo, - bool refreshChildren) -{ - if (refreshChildren && (!firstEdge->refreshSizeHints(styleInfo) - || !secondEdge->refreshSizeHints(styleInfo))) { - return false; - } + // Note that parallel groups can lead to unfeasibility, so during calculation, we can + // find out one unfeasibility. Because of that this method return boolean. This can't + // happen in sequential, so there the method is void. // Account for parallel anchors where the second edge is backwards. // We rely on the fact that a forward anchor of sizes min, pref, max is equivalent @@ -423,13 +414,7 @@ void SequentialAnchorData::updateChildrenSizes() } } -bool SequentialAnchorData::refreshSizeHints(const QLayoutStyleInfo *styleInfo) -{ - return refreshSizeHints_helper(styleInfo); -} - -bool SequentialAnchorData::refreshSizeHints_helper(const QLayoutStyleInfo *styleInfo, - bool refreshChildren) +void SequentialAnchorData::calculateSizeHints() { minSize = 0; prefSize = 0; @@ -437,11 +422,6 @@ bool SequentialAnchorData::refreshSizeHints_helper(const QLayoutStyleInfo *style for (int i = 0; i < m_edges.count(); ++i) { AnchorData *edge = m_edges.at(i); - - // If it's the case refresh children information first - if (refreshChildren && !edge->refreshSizeHints(styleInfo)) - return false; - minSize += edge->minSize; prefSize += edge->prefSize; maxSize += edge->maxSize; @@ -451,8 +431,6 @@ bool SequentialAnchorData::refreshSizeHints_helper(const QLayoutStyleInfo *style sizeAtMinimum = prefSize; sizeAtPreferred = prefSize; sizeAtMaximum = prefSize; - - return true; } #ifdef QT_DEBUG @@ -627,7 +605,7 @@ AnchorData *QGraphicsAnchorLayoutPrivate::addAnchorMaybeParallel(AnchorData *new // At this point we can identify that the parallel anchor is not feasible, e.g. one // anchor minimum size is bigger than the other anchor maximum size. - *feasible = parallel->refreshSizeHints_helper(0, false); + *feasible = parallel->calculateSizeHints(); newAnchor = parallel; } @@ -688,7 +666,7 @@ static AnchorData *createSequence(Graph *graph, sequence->from = before; sequence->to = after; - sequence->refreshSizeHints_helper(0, false); + sequence->calculateSizeHints(); return sequence; } @@ -1335,11 +1313,11 @@ void QGraphicsAnchorLayoutPrivate::createItemEdges(QGraphicsLayoutItem *item) // refresh its size hint / policy values. AnchorData *data = new AnchorData; addAnchor_helper(item, Qt::AnchorLeft, item, Qt::AnchorRight, data); - data->refreshSizeHints(0); // 0 = effectiveSpacing, will not be used + data->refreshSizeHints(); data = new AnchorData; addAnchor_helper(item, Qt::AnchorTop, item, Qt::AnchorBottom, data); - data->refreshSizeHints(0); // 0 = effectiveSpacing, will not be used + data->refreshSizeHints(); } /*! @@ -1399,14 +1377,14 @@ void QGraphicsAnchorLayoutPrivate::createCenterAnchors( addAnchor_helper(item, firstEdge, item, centerEdge, data); data->isCenterAnchor = true; data->dependency = AnchorData::Master; - data->refreshSizeHints(0); + data->refreshSizeHints(); data = new AnchorData; c->variables.insert(data, -1.0); addAnchor_helper(item, centerEdge, item, lastEdge, data); data->isCenterAnchor = true; data->dependency = AnchorData::Slave; - data->refreshSizeHints(0); + data->refreshSizeHints(); itemCenterConstraints[orientation].append(c); @@ -1473,7 +1451,7 @@ void QGraphicsAnchorLayoutPrivate::removeCenterAnchors( // Create the new anchor that should substitute the left-center-right anchors. AnchorData *data = new AnchorData; addAnchor_helper(item, firstEdge, item, lastEdge, data); - data->refreshSizeHints(0); + data->refreshSizeHints(); // Remove old anchors removeAnchor_helper(first, center); @@ -1995,12 +1973,8 @@ void QGraphicsAnchorLayoutPrivate::calculateGraphs( static bool simplificationEnabled = qgetenv("QT_ANCHORLAYOUT_NO_SIMPLIFICATION").isEmpty(); - // Reset the nominal sizes of each anchor based on the current item sizes. - if (!refreshAllSizeHints(orientation)) { - qWarning("QGraphicsAnchorLayout: anchor setup is not feasible."); - graphHasConflicts[orientation] = true; - return; - } + // Reset the nominal sizes of each anchor based on the current item sizes + refreshAllSizeHints(orientation); // Simplify the graph if (simplificationEnabled && !simplifyGraph(orientation)) { @@ -2169,29 +2143,19 @@ bool QGraphicsAnchorLayoutPrivate::calculateNonTrunk(const QList &g = graph[orientation]; QList > vertices = g.connections(); QLayoutStyleInfo styleInf = styleInfo(); for (int i = 0; i < vertices.count(); ++i) { - AnchorData *data = g.edgeData(vertices.at(i).first, vertices.at(i).second);; - Q_ASSERT(data->from && data->to); - - // During the traversal we check the feasibility of the complex anchors. - if (!data->refreshSizeHints(&styleInf)) - return false; + AnchorData *data = g.edgeData(vertices.at(i).first, vertices.at(i).second); + data->refreshSizeHints(&styleInf); } - - return true; } /*! diff --git a/src/gui/graphicsview/qgraphicsanchorlayout_p.h b/src/gui/graphicsview/qgraphicsanchorlayout_p.h index fd82dd9..2b365fb 100644 --- a/src/gui/graphicsview/qgraphicsanchorlayout_p.h +++ b/src/gui/graphicsview/qgraphicsanchorlayout_p.h @@ -131,7 +131,7 @@ struct AnchorData : public QSimplexVariable { dependency(Independent) {} virtual void updateChildrenSizes() {} - virtual bool refreshSizeHints(const QLayoutStyleInfo *styleInfo); + void refreshSizeHints(const QLayoutStyleInfo *styleInfo = 0); virtual ~AnchorData() {} @@ -197,9 +197,7 @@ struct SequentialAnchorData : public AnchorData } virtual void updateChildrenSizes(); - virtual bool refreshSizeHints(const QLayoutStyleInfo *styleInfo); - - bool refreshSizeHints_helper(const QLayoutStyleInfo *styleInfo, bool refreshChildren = true); + void calculateSizeHints(); QVector m_children; // list of vertices in the sequence QVector m_edges; // keep the list of edges too. @@ -226,9 +224,7 @@ struct ParallelAnchorData : public AnchorData } virtual void updateChildrenSizes(); - virtual bool refreshSizeHints(const QLayoutStyleInfo *styleInfo); - - bool refreshSizeHints_helper(const QLayoutStyleInfo *styleInfo, bool refreshChildren = true); + bool calculateSizeHints(); AnchorData* firstEdge; AnchorData* secondEdge; @@ -483,7 +479,7 @@ public: const QList &variables); // Support functions for calculateGraph() - bool refreshAllSizeHints(Orientation orientation); + void refreshAllSizeHints(Orientation orientation); void findPaths(Orientation orientation); void constraintsFromPaths(Orientation orientation); void updateAnchorSizes(Orientation orientation); -- cgit v0.12 From 2b243d590fcd6ce0c94fbf8adb1a4bd19b1c4685 Mon Sep 17 00:00:00 2001 From: Janne Koskinen Date: Fri, 13 Nov 2009 10:32:02 +0200 Subject: Highlighted text colour correction for s60style Changed s60style HighlightedText to pickup the correct colour from S60 themes. Task-number: QTBUG-5709 Reviewed-by: Sami Merila --- src/gui/styles/qs60style.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/styles/qs60style.cpp b/src/gui/styles/qs60style.cpp index 9179237..a204ebc 100644 --- a/src/gui/styles/qs60style.cpp +++ b/src/gui/styles/qs60style.cpp @@ -668,7 +668,7 @@ void QS60StylePrivate::setThemePalette(QPalette *palette) const s60Color(QS60StyleEnums::CL_QsnTextColors, 55, 0)); palette->setColor(QPalette::BrightText, palette->color(QPalette::WindowText).lighter()); palette->setColor(QPalette::HighlightedText, - s60Color(QS60StyleEnums::CL_QsnTextColors, 10, 0)); + s60Color(QS60StyleEnums::CL_QsnTextColors, 24, 0)); palette->setColor(QPalette::Link, s60Color(QS60StyleEnums::CL_QsnHighlightColors, 3, 0)); palette->setColor(QPalette::LinkVisited, palette->color(QPalette::Link).darker()); -- cgit v0.12 From edede3b20aa6ffdb16c790f7e537f5b8e9c96e68 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Fri, 13 Nov 2009 10:47:43 +0100 Subject: Add an entry to the changelog about the XUnit support in QtTest --- dist/changes-4.6.0 | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/dist/changes-4.6.0 b/dist/changes-4.6.0 index a257c91..7c97aa5 100644 --- a/dist/changes-4.6.0 +++ b/dist/changes-4.6.0 @@ -56,7 +56,10 @@ MR#1234 - Merge Request: http://qt.gitorious.org * New abstract video output classes. - New state machine framework added to QtCore. - + + - QtTest now supports outputting XUnit XML documents, for integrating + with existing continuous integration systems. This is enabled by + running the test program with the -xunitxml option. Third party components ---------------------- -- cgit v0.12 From aeac586476a6e47c7a8a6aa2121bfe39a29d8458 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Fri, 8 May 2009 20:42:44 +0200 Subject: Reorganize the qatomic_armv6.h file to receive the RVCT inline assembly. Move the *Relaxed, *Acquire and *Release functions (which are simply forwarding calls to the *Ordered version) to the bottom of the file. Reviewed-By: Shane Kearns --- src/corelib/arch/qatomic_armv6.h | 171 ++++++++++++++++++++------------------- 1 file changed, 90 insertions(+), 81 deletions(-) diff --git a/src/corelib/arch/qatomic_armv6.h b/src/corelib/arch/qatomic_armv6.h index 6862638..6eb9a7b 100644 --- a/src/corelib/arch/qatomic_armv6.h +++ b/src/corelib/arch/qatomic_armv6.h @@ -101,6 +101,8 @@ template Q_INLINE_TEMPLATE bool QBasicAtomicPointer::isFetchAndAddWaitFree() { return false; } +#ifdef !Q_CC_RVCT + inline bool QBasicAtomicInt::ref() { register int newValue; @@ -155,21 +157,6 @@ inline bool QBasicAtomicInt::testAndSetOrdered(int expectedValue, int newValue) return result == 0; } -inline bool QBasicAtomicInt::testAndSetRelaxed(int expectedValue, int newValue) -{ - return testAndSetOrdered(expectedValue, newValue); -} - -inline bool QBasicAtomicInt::testAndSetAcquire(int expectedValue, int newValue) -{ - return testAndSetOrdered(expectedValue, newValue); -} - -inline bool QBasicAtomicInt::testAndSetRelease(int expectedValue, int newValue) -{ - return testAndSetOrdered(expectedValue, newValue); -} - inline int QBasicAtomicInt::fetchAndStoreOrdered(int newValue) { register int originalValue; @@ -188,21 +175,6 @@ inline int QBasicAtomicInt::fetchAndStoreOrdered(int newValue) return originalValue; } -inline int QBasicAtomicInt::fetchAndStoreRelaxed(int newValue) -{ - return fetchAndStoreOrdered(newValue); -} - -inline int QBasicAtomicInt::fetchAndStoreAcquire(int newValue) -{ - return fetchAndStoreOrdered(newValue); -} - -inline int QBasicAtomicInt::fetchAndStoreRelease(int newValue) -{ - return fetchAndStoreOrdered(newValue); -} - inline int QBasicAtomicInt::fetchAndAddOrdered(int valueToAdd) { register int originalValue; @@ -224,21 +196,6 @@ inline int QBasicAtomicInt::fetchAndAddOrdered(int valueToAdd) return originalValue; } -inline int QBasicAtomicInt::fetchAndAddRelaxed(int valueToAdd) -{ - return fetchAndAddOrdered(valueToAdd); -} - -inline int QBasicAtomicInt::fetchAndAddAcquire(int valueToAdd) -{ - return fetchAndAddOrdered(valueToAdd); -} - -inline int QBasicAtomicInt::fetchAndAddRelease(int valueToAdd) -{ - return fetchAndAddOrdered(valueToAdd); -} - template Q_INLINE_TEMPLATE bool QBasicAtomicPointer::testAndSetOrdered(T *expectedValue, T *newValue) { @@ -259,24 +216,6 @@ Q_INLINE_TEMPLATE bool QBasicAtomicPointer::testAndSetOrdered(T *expectedValu } template -Q_INLINE_TEMPLATE bool QBasicAtomicPointer::testAndSetRelaxed(T *expectedValue, T *newValue) -{ - return testAndSetOrdered(expectedValue, newValue); -} - -template -Q_INLINE_TEMPLATE bool QBasicAtomicPointer::testAndSetAcquire(T *expectedValue, T *newValue) -{ - return testAndSetOrdered(expectedValue, newValue); -} - -template -Q_INLINE_TEMPLATE bool QBasicAtomicPointer::testAndSetRelease(T *expectedValue, T *newValue) -{ - return testAndSetOrdered(expectedValue, newValue); -} - -template Q_INLINE_TEMPLATE T *QBasicAtomicPointer::fetchAndStoreOrdered(T *newValue) { register T *originalValue; @@ -296,24 +235,6 @@ Q_INLINE_TEMPLATE T *QBasicAtomicPointer::fetchAndStoreOrdered(T *newValue) } template -Q_INLINE_TEMPLATE T *QBasicAtomicPointer::fetchAndStoreRelaxed(T *newValue) -{ - return fetchAndStoreOrdered(newValue); -} - -template -Q_INLINE_TEMPLATE T *QBasicAtomicPointer::fetchAndStoreAcquire(T *newValue) -{ - return fetchAndStoreOrdered(newValue); -} - -template -Q_INLINE_TEMPLATE T *QBasicAtomicPointer::fetchAndStoreRelease(T *newValue) -{ - return fetchAndStoreOrdered(newValue); -} - -template Q_INLINE_TEMPLATE T *QBasicAtomicPointer::fetchAndAddOrdered(qptrdiff valueToAdd) { register T *originalValue; @@ -335,6 +256,94 @@ Q_INLINE_TEMPLATE T *QBasicAtomicPointer::fetchAndAddOrdered(qptrdiff valueTo return originalValue; } +#else +// This is Q_CC_RVCT + +#endif + +// common code + +inline bool QBasicAtomicInt::testAndSetRelaxed(int expectedValue, int newValue) +{ + return testAndSetOrdered(expectedValue, newValue); +} + +inline bool QBasicAtomicInt::testAndSetAcquire(int expectedValue, int newValue) +{ + return testAndSetOrdered(expectedValue, newValue); +} + +inline bool QBasicAtomicInt::testAndSetRelease(int expectedValue, int newValue) +{ + return testAndSetOrdered(expectedValue, newValue); +} + +inline int QBasicAtomicInt::fetchAndStoreRelaxed(int newValue) +{ + return fetchAndStoreOrdered(newValue); +} + +inline int QBasicAtomicInt::fetchAndStoreAcquire(int newValue) +{ + return fetchAndStoreOrdered(newValue); +} + +inline int QBasicAtomicInt::fetchAndStoreRelease(int newValue) +{ + return fetchAndStoreOrdered(newValue); +} + +inline int QBasicAtomicInt::fetchAndAddRelaxed(int valueToAdd) +{ + return fetchAndAddOrdered(valueToAdd); +} + +inline int QBasicAtomicInt::fetchAndAddAcquire(int valueToAdd) +{ + return fetchAndAddOrdered(valueToAdd); +} + +inline int QBasicAtomicInt::fetchAndAddRelease(int valueToAdd) +{ + return fetchAndAddOrdered(valueToAdd); +} + +template +Q_INLINE_TEMPLATE bool QBasicAtomicPointer::testAndSetRelaxed(T *expectedValue, T *newValue) +{ + return testAndSetOrdered(expectedValue, newValue); +} + +template +Q_INLINE_TEMPLATE bool QBasicAtomicPointer::testAndSetAcquire(T *expectedValue, T *newValue) +{ + return testAndSetOrdered(expectedValue, newValue); +} + +template +Q_INLINE_TEMPLATE bool QBasicAtomicPointer::testAndSetRelease(T *expectedValue, T *newValue) +{ + return testAndSetOrdered(expectedValue, newValue); +} + +template +Q_INLINE_TEMPLATE T *QBasicAtomicPointer::fetchAndStoreRelaxed(T *newValue) +{ + return fetchAndStoreOrdered(newValue); +} + +template +Q_INLINE_TEMPLATE T *QBasicAtomicPointer::fetchAndStoreAcquire(T *newValue) +{ + return fetchAndStoreOrdered(newValue); +} + +template +Q_INLINE_TEMPLATE T *QBasicAtomicPointer::fetchAndStoreRelease(T *newValue) +{ + return fetchAndStoreOrdered(newValue); +} + template Q_INLINE_TEMPLATE T *QBasicAtomicPointer::fetchAndAddRelaxed(qptrdiff valueToAdd) { -- cgit v0.12 From 43c607383697ab506f9eb0d491ec6348f939e53d Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Fri, 8 May 2009 20:45:24 +0200 Subject: Add the ARMv6 inline assembly code for compiling with RVCT. This is basically a copy & paste of the GCC inline assembly above, switched to the RVCT inline assembly model (which is actually easier to write and understand). I verified that this code compiles and assembles as expected. The output generated by RVCT is pretty much on the mark. However, I have not executed this code yet to see if it performs as expected. To be noted: - when expanding the inline template code, RVCT may be tempted to switch your entire function to ARM mode. Should we add __attribute__((noinline)) to prevent that? - There's no equivalent to GCC inline assembler's clobber, especially of "memory". Also, there's no "volatile" qualifier to the assembly. Does the compiler know it can't reorder the code? Does it know it shouldn't trust the value of the memory after this? My test indicates the code is fine... Reviewed-By: Shane Kearns --- src/corelib/arch/qatomic_armv6.h | 132 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 132 insertions(+) diff --git a/src/corelib/arch/qatomic_armv6.h b/src/corelib/arch/qatomic_armv6.h index 6eb9a7b..28655df 100644 --- a/src/corelib/arch/qatomic_armv6.h +++ b/src/corelib/arch/qatomic_armv6.h @@ -259,6 +259,138 @@ Q_INLINE_TEMPLATE T *QBasicAtomicPointer::fetchAndAddOrdered(qptrdiff valueTo #else // This is Q_CC_RVCT +// RVCT inline assembly documentation: +// http://www.keil.com/support/man/docs/armcc/armcc_chdcffdb.htm +// RVCT embedded assembly documentation: +// http://www.keil.com/support/man/docs/armcc/armcc_chddbeib.htm + +// save our pragma state and switch to ARM mode +#pragma push +#pragma arm + +inline bool QBasicAtomicInt::ref() +{ + register int newValue; + register int result; + retry: + __asm { + ldrex newValue, [&_q_value] + add newValue, newValue, #1 + strex result, newValue, [&_q_value] + teq result, #0 + bne retry + } + return newValue != 0; +} + +inline bool QBasicAtomicInt::deref() +{ + register int newValue; + register int result; + retry: + __asm { + ldrex newValue, [&_q_value] + sub newValue, newValue, #1 + strex result, newValue, [&_q_value] + teq result, #0 + bne retry + } + return newValue != 0; +} + +inline bool QBasicAtomicInt::testAndSetOrdered(int expectedValue, int newValue) +{ + register int result; + retry: + __asm { + ldrex result, [&_q_value] + eors result, result, expectedValue + strexeq result, newValue, [&_q_value] + teqeq result, #1 + beq retry + } + return result == 0; +} + +inline int QBasicAtomicInt::fetchAndStoreOrdered(int newValue) +{ + register int originalValue; + register int result; + retry: + __asm { + ldrex originalValue, [&_q_value] + strex result, newValue, [&_q_value] + teq result, #0 + bne retry + } + return originalValue; +} + +inline int QBasicAtomicInt::fetchAndAddOrdered(int valueToAdd) +{ + register int originalValue; + register int newValue; + register int result; + retry: + __asm { + ldrex originalValue, [&_q_value] + add newValue, originalValue, valueToAdd + strex result, newValue, [&_q_value] + teq result, #0 + bne retry + } + return originalValue; +} + +template +Q_INLINE_TEMPLATE bool QBasicAtomicPointer::testAndSetOrdered(T *expectedValue, T *newValue) +{ + register T *result; + retry: + __asm { + ldrex result, [&_q_value] + eors result, result, expectedValue + strexeq result, newValue, [&_q_value] + teqeq result, #1 + beq retry + } + return result == 0; +} + +template +Q_INLINE_TEMPLATE T *QBasicAtomicPointer::fetchAndStoreOrdered(T *newValue) +{ + register T *originalValue; + register int result; + retry: + __asm { + ldrex originalValue, [&_q_value] + strex result, newValue, [&_q_value] + teq result, #0 + bne retry + } + return originalValue; +} + +template +Q_INLINE_TEMPLATE T *QBasicAtomicPointer::fetchAndAddOrdered(qptrdiff valueToAdd) +{ + register T *originalValue; + register T *newValue; + register int result; + retry: + __asm { + ldrex originalValue, [&_q_value] + add newValue, originalValue, valueToAdd * sizeof(T) + strex result, newValue, [&_q_value] + teq result, #0 + bne retry + } + return originalValue; +} + +// go back to the previous pragma state (probably Thumb mode) +#pragma pop #endif // common code -- cgit v0.12 From a53bbbf81ce2dbce143ebc08fd91418e51a44588 Mon Sep 17 00:00:00 2001 From: Shane Kearns Date: Wed, 4 Nov 2009 22:26:00 +0100 Subject: Binary compatibility of Symbian ARMv5 and ARMv6 builds Use ARMv6 atomics where available Use OS atomics otherwise Integrate ARMV6 atomics to Symbian builds Use compiler defined macros to detect if ARMv6 instructions are available This defines the QT_HAVE_ARMV6 macro, replacing the way it was defined by the Symbian build system previously in qpainting.pri. qatomic_symbian now uses qatomic_arm or qatomic_armv6 automatically Port armv6 atomics to implement generic atomics interface The inline atomics are not inlined when we build for thumb using RVCT. So there is no performance improvement of using the "inline" versions vs a shared version called through a function call. The generic atomics interface is good for binary compatibility, as the same symbols are exported in all versions now. Changed the fallback generic atomics implementation from the unix one to a symbian specific one using RFastLock (identical code to the windows generic atomics, except for RFastLock replaces Win32 CRITICAL_SECTION) Note: GCCE atomics still need porting Tell git to ignore .lst listing files (produced by sbs/abld listing) ARMv6 support for GCCE compiler and fallback implementation using OS When building corelib with GCCE and -march=armv6, QT_HAVE_ARMV6 will be defined. This patch adds copies of the asm functions in GCC syntax. When building for the Symbian emulator, or ARMv5, then Symbian OS atomic functions are used as a fallback - these are more efficient than the unix atomics, and don't require data import (which the ARMv5 atomics use, but the OS loader doesn't support fully) Symbian OS functions are always used for QBasicAtomicInt::ref / deref, because these are faster than the generic function in all cases. They are machine coded for ARMv6, and are used internally by RFastLock. Reviewed-By: axis Reviewed-By: Brad --- .gitignore | 1 + src/corelib/arch/armv6/qatomic_generic_armv6.cpp | 260 +++++++++++++++++++++++ src/corelib/arch/qatomic_armv6.h | 3 +- src/corelib/arch/qatomic_symbian.h | 240 ++++++++++++++++++++- src/corelib/arch/symbian/arch.pri | 2 +- src/corelib/arch/symbian/qatomic_symbian.cpp | 104 +++++++-- src/corelib/global/qglobal.h | 7 +- src/gui/painting/painting.pri | 1 - src/s60installs/eabi/QtCoreu.def | 8 +- 9 files changed, 587 insertions(+), 39 deletions(-) create mode 100644 src/corelib/arch/armv6/qatomic_generic_armv6.cpp diff --git a/.gitignore b/.gitignore index feb1ea4..33c9b7c 100644 --- a/.gitignore +++ b/.gitignore @@ -191,6 +191,7 @@ plugin_commonU.def *.qtplugin *.sis *.sisx +*.lst # Generated by abldfast.bat from devtools. .abldsteps.* diff --git a/src/corelib/arch/armv6/qatomic_generic_armv6.cpp b/src/corelib/arch/armv6/qatomic_generic_armv6.cpp new file mode 100644 index 0000000..3078662 --- /dev/null +++ b/src/corelib/arch/armv6/qatomic_generic_armv6.cpp @@ -0,0 +1,260 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtCore module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +** This file implements the generic atomics interface using ARMv6 assembly +** instructions. It is more efficent than the inline versions when Qt is +** built for the THUMB instruction set, as the required instructions are +** only available in ARM state. +****************************************************************************/ + +#include + +#ifdef QT_HAVE_ARMV6 + +QT_BEGIN_NAMESPACE + +QT_USE_NAMESPACE + +#ifdef Q_CC_RVCT +#pragma push +#pragma arm +Q_CORE_EXPORT asm +bool QBasicAtomicInt_testAndSetOrdered(volatile int *_q_value, int expectedValue, int newValue) +{ + CODE32 + //R0 = _q_value + //R1 = expectedValue + //R2 = newValue +retry_testAndSetOrdered + LDREX r3,[r0] //r3 = *_q_value + EORS r3,r3,r1 //if (r3 == expectedValue) { + STREXEQ r3,r2,[r0] //*_q_value = newvalue, r3 = error + TEQEQ r3,#1 //if error + BEQ retry_testAndSetOrdered //then goto retry } + RSBS r0,r3,#1 //return (r3 == 0) + MOVCC r0,#0 + BX r14 +} + +Q_CORE_EXPORT asm +int QBasicAtomicInt_fetchAndStoreOrdered(volatile int *_q_value, int newValue) +{ + CODE32 +//R0 = _q_value +//R1 = newValue +retry_fetchAndStoreOrdered + LDREX r3,[r0] //r3 = *_q_value + STREX r2,r1,[r0] //*_q_value = newValue, r2 = error + TEQ r2,#0 //if error + BNE retry_fetchAndStoreOrdered //then goto retry + MOV r0,r3 //return r3 + BX r14 +} + +Q_CORE_EXPORT asm +int QBasicAtomicInt_fetchAndAddOrdered(volatile int *_q_value, int valueToAdd) +{ + CODE32 + //R0 = _q_value + //R1 = valueToAdd + STMDB sp!,{r12,lr} +retry_fetchAndAddOrdered + LDREX r2,[r0] //r2 = *_q_value + ADD r3,r2,r1 //r3 = r2 + r1 + STREX r12,r3,[r0] //*_q_value = r3, r12 = error + TEQ r12,#0 //if error + BNE retry_fetchAndAddOrdered //then retry + MOV r0,r2 //return r2 + LDMIA sp!,{r12,pc} +} + +Q_CORE_EXPORT asm +bool QBasicAtomicPointer_testAndSetOrdered(void * volatile *_q_value, + void *expectedValue, + void *newValue) +{ + CODE32 + //R0 = _q_value + //R1 = expectedValue + //R2 = newValue +retryPointer_testAndSetOrdered + LDREX r3,[r0] //r3 = *_q_value + EORS r3,r3,r1 //if (r3 == expectedValue) { + STREXEQ r3,r2,[r0] //*_q_value = newvalue, r3 = error + TEQEQ r3,#1 //if error + BEQ retryPointer_testAndSetOrdered //then goto retry } + RSBS r0,r3,#1 //return (r3 == 0) + MOVCC r0,#0 + BX r14 +} + +Q_CORE_EXPORT asm +void *QBasicAtomicPointer_fetchAndStoreOrdered(void * volatile *_q_value, void *newValue) +{ + CODE32 + //R0 = _q_value + //R1 = newValue +retryPointer_fetchAndStoreOrdered + LDREX r3,[r0] //r3 = *_q_value + STREX r2,r1,[r0] //*_q_value = newValue, r2 = error + TEQ r2,#0 //if error + BNE retryPointer_fetchAndStoreOrdered //then goto retry + MOV r0,r3 //return r3 + BX r14 +} + +Q_CORE_EXPORT asm +void *QBasicAtomicPointer_fetchAndAddOrdered(void * volatile *_q_value, qptrdiff valueToAdd) +{ + CODE32 + //R0 = _q_value + //R1 = valueToAdd + STMDB sp!,{r12,lr} +retryPointer_fetchAndAddOrdered + LDREX r2,[r0] //r2 = *_q_value + ADD r3,r2,r1 //r3 = r2 + r1 + STREX r12,r3,[r0] //*_q_value = r3, r12 = error + TEQ r12,#0 //if error + BNE retryPointer_fetchAndAddOrdered //then retry + MOV r0,r2 //return r2 + LDMIA sp!,{r12,pc} +} + +#pragma pop +#elif defined (Q_CC_GCCE) +Q_CORE_EXPORT __declspec( naked ) +bool QBasicAtomicInt_testAndSetOrdered(volatile int *_q_value, int expectedValue, int newValue) +{ + //R0 = _q_value + //R1 = expectedValue + //R2 = newValue + asm("retry_testAndSetOrdered:"); + asm(" LDREX r3,[r0]"); //r3 = *_q_value + asm(" EORS r3,r3,r1"); //if (r3 == expectedValue) { + asm(" STREXEQ r3,r2,[r0]"); //*_q_value = newvalue, r3 = error + asm(" TEQEQ r3,#1"); //if error + asm(" BEQ retry_testAndSetOrdered"); //then goto retry } + asm(" RSBS r0,r3,#1"); //return (r3 == 0) + asm(" MOVCC r0,#0"); + asm(" BX r14"); +} + +Q_CORE_EXPORT __declspec( naked ) +int QBasicAtomicInt_fetchAndStoreOrdered(volatile int *_q_value, int newValue) +{ +//R0 = _q_value +//R1 = newValue + asm("retry_fetchAndStoreOrdered:"); + asm(" LDREX r3,[r0]"); //r3 = *_q_value + asm(" STREX r2,r1,[r0]"); //*_q_value = newValue, r2 = error + asm(" TEQ r2,#0"); //if error + asm(" BNE retry_fetchAndStoreOrdered"); //then goto retry + asm(" MOV r0,r3"); //return r3 + asm(" BX r14"); +} + +Q_CORE_EXPORT __declspec( naked ) +int QBasicAtomicInt_fetchAndAddOrdered(volatile int *_q_value, int valueToAdd) +{ + //R0 = _q_value + //R1 = valueToAdd + asm(" STMDB sp!,{r12,lr}"); + asm("retry_fetchAndAddOrdered:"); + asm(" LDREX r2,[r0]"); //r2 = *_q_value + asm(" ADD r3,r2,r1 "); //r3 = r2 + r1 + asm(" STREX r12,r3,[r0]"); //*_q_value = r3, r12 = error + asm(" TEQ r12,#0"); //if error + asm(" BNE retry_fetchAndAddOrdered"); //then retry + asm(" MOV r0,r2"); //return r2 + asm(" LDMIA sp!,{r12,pc}"); +} + +Q_CORE_EXPORT __declspec( naked ) +bool QBasicAtomicPointer_testAndSetOrdered(void * volatile *_q_value, + void *expectedValue, + void *newValue) +{ + //R0 = _q_value + //R1 = expectedValue + //R2 = newValue + asm("retryPointer_testAndSetOrdered:"); + asm(" LDREX r3,[r0]"); //r3 = *_q_value + asm(" EORS r3,r3,r1"); //if (r3 == expectedValue) { + asm(" STREXEQ r3,r2,[r0]"); //*_q_value = newvalue, r3 = error + asm(" TEQEQ r3,#1"); //if error + asm(" BEQ retryPointer_testAndSetOrdered"); //then goto retry } + asm(" RSBS r0,r3,#1"); //return (r3 == 0) + asm(" MOVCC r0,#0"); + asm(" BX r14"); +} + +Q_CORE_EXPORT __declspec( naked ) +void *QBasicAtomicPointer_fetchAndStoreOrdered(void * volatile *_q_value, void *newValue) +{ + //R0 = _q_value + //R1 = newValue + asm("retryPointer_fetchAndStoreOrdered:"); + asm(" LDREX r3,[r0]"); //r3 = *_q_value + asm(" STREX r2,r1,[r0]"); //*_q_value = newValue, r2 = error + asm(" TEQ r2,#0"); //if error + asm(" BNE retryPointer_fetchAndStoreOrdered"); //then goto retry + asm(" MOV r0,r3"); //return r3 + asm(" BX r14"); +} + +Q_CORE_EXPORT __declspec( naked ) +void *QBasicAtomicPointer_fetchAndAddOrdered(void * volatile *_q_value, qptrdiff valueToAdd) +{ + //R0 = _q_value + //R1 = valueToAdd + asm(" STMDB sp!,{r12,lr}"); + asm("retryPointer_fetchAndAddOrdered:"); + asm(" LDREX r2,[r0]"); //r2 = *_q_value + asm(" ADD r3,r2,r1"); //r3 = r2 + r1 + asm(" STREX r12,r3,[r0]"); //*_q_value = r3, r12 = error + asm(" TEQ r12,#0"); //if error + asm(" BNE retryPointer_fetchAndAddOrdered"); //then retry + asm(" MOV r0,r2"); //return r2 + asm(" LDMIA sp!,{r12,pc}"); +} +#else +#error unknown arm compiler +#endif +QT_END_NAMESPACE +#endif diff --git a/src/corelib/arch/qatomic_armv6.h b/src/corelib/arch/qatomic_armv6.h index 28655df..1e9f0c4 100644 --- a/src/corelib/arch/qatomic_armv6.h +++ b/src/corelib/arch/qatomic_armv6.h @@ -45,7 +45,6 @@ QT_BEGIN_HEADER QT_BEGIN_NAMESPACE - #define Q_ATOMIC_INT_REFERENCE_COUNTING_IS_ALWAYS_NATIVE inline bool QBasicAtomicInt::isReferenceCountingNative() @@ -101,7 +100,7 @@ template Q_INLINE_TEMPLATE bool QBasicAtomicPointer::isFetchAndAddWaitFree() { return false; } -#ifdef !Q_CC_RVCT +#ifndef Q_CC_RVCT inline bool QBasicAtomicInt::ref() { diff --git a/src/corelib/arch/qatomic_symbian.h b/src/corelib/arch/qatomic_symbian.h index 3721aca..571f628 100644 --- a/src/corelib/arch/qatomic_symbian.h +++ b/src/corelib/arch/qatomic_symbian.h @@ -42,12 +42,8 @@ #ifndef QATOMIC_SYMBIAN_H #define QATOMIC_SYMBIAN_H -#if defined(Q_CC_RVCT) -# define QT_NO_ARM_EABI -# include -#elif defined(Q_CC_NOKIAX86) || defined(Q_CC_GCCE) -# include -#endif +#include +#include QT_BEGIN_HEADER @@ -55,7 +51,237 @@ QT_BEGIN_NAMESPACE QT_MODULE(Core) -// Empty, but needed to avoid warnings +#define Q_ATOMIC_INT_REFERENCE_COUNTING_IS_NOT_NATIVE + +inline bool QBasicAtomicInt::isReferenceCountingNative() +{ return false; } +inline bool QBasicAtomicInt::isReferenceCountingWaitFree() +{ return false; } + +#define Q_ATOMIC_INT_TEST_AND_SET_IS_NOT_NATIVE + +inline bool QBasicAtomicInt::isTestAndSetNative() +{ return false; } +inline bool QBasicAtomicInt::isTestAndSetWaitFree() +{ return false; } + +#define Q_ATOMIC_INT_FETCH_AND_STORE_IS_NOT_NATIVE + +inline bool QBasicAtomicInt::isFetchAndStoreNative() +{ return false; } +inline bool QBasicAtomicInt::isFetchAndStoreWaitFree() +{ return false; } + +#define Q_ATOMIC_INT_FETCH_AND_ADD_IS_NOT_NATIVE + +inline bool QBasicAtomicInt::isFetchAndAddNative() +{ return false; } +inline bool QBasicAtomicInt::isFetchAndAddWaitFree() +{ return false; } + +#define Q_ATOMIC_POINTER_TEST_AND_SET_IS_NOT_NATIVE + +template +Q_INLINE_TEMPLATE bool QBasicAtomicPointer::isTestAndSetNative() +{ return false; } +template +Q_INLINE_TEMPLATE bool QBasicAtomicPointer::isTestAndSetWaitFree() +{ return false; } + +#define Q_ATOMIC_POINTER_FETCH_AND_STORE_IS_NOT_NATIVE + +template +Q_INLINE_TEMPLATE bool QBasicAtomicPointer::isFetchAndStoreNative() +{ return false; } +template +Q_INLINE_TEMPLATE bool QBasicAtomicPointer::isFetchAndStoreWaitFree() +{ return false; } + +#define Q_ATOMIC_POINTER_FETCH_AND_ADD_IS_NOT_NATIVE + +template +Q_INLINE_TEMPLATE bool QBasicAtomicPointer::isFetchAndAddNative() +{ return false; } +template +Q_INLINE_TEMPLATE bool QBasicAtomicPointer::isFetchAndAddWaitFree() +{ return false; } + +Q_CORE_EXPORT bool QBasicAtomicInt_testAndSetOrdered(volatile int *, int, int); +Q_CORE_EXPORT int QBasicAtomicInt_fetchAndStoreOrdered(volatile int *, int); +Q_CORE_EXPORT int QBasicAtomicInt_fetchAndAddOrdered(volatile int *, int); + +Q_CORE_EXPORT bool QBasicAtomicPointer_testAndSetOrdered(void * volatile *, void *, void *); +Q_CORE_EXPORT void *QBasicAtomicPointer_fetchAndStoreOrdered(void * volatile *, void *); +Q_CORE_EXPORT void *QBasicAtomicPointer_fetchAndAddOrdered(void * volatile *, qptrdiff); + +// Reference counting + +//LockedInc and LockedDec are machine coded for ARMv6 (and future proof) +inline bool QBasicAtomicInt::ref() +{ + int original = User::LockedInc((TInt&)_q_value); + return original != -1; +} + +inline bool QBasicAtomicInt::deref() +{ + int original = User::LockedDec((TInt&)_q_value); + return original != 1; +} + +// Test and set for integers + +inline bool QBasicAtomicInt::testAndSetOrdered(int expectedValue, int newValue) +{ + return QBasicAtomicInt_testAndSetOrdered(&_q_value, expectedValue, newValue); +} + +inline bool QBasicAtomicInt::testAndSetRelaxed(int expectedValue, int newValue) +{ + return testAndSetOrdered(expectedValue, newValue); +} + +inline bool QBasicAtomicInt::testAndSetAcquire(int expectedValue, int newValue) +{ + return testAndSetOrdered(expectedValue, newValue); +} + +inline bool QBasicAtomicInt::testAndSetRelease(int expectedValue, int newValue) +{ + return testAndSetOrdered(expectedValue, newValue); +} + +// Fetch and store for integers + +inline int QBasicAtomicInt::fetchAndStoreOrdered(int newValue) +{ + return QBasicAtomicInt_fetchAndStoreOrdered(&_q_value, newValue); +} + +inline int QBasicAtomicInt::fetchAndStoreRelaxed(int newValue) +{ + return fetchAndStoreOrdered(newValue); +} + +inline int QBasicAtomicInt::fetchAndStoreAcquire(int newValue) +{ + return fetchAndStoreOrdered(newValue); +} + +inline int QBasicAtomicInt::fetchAndStoreRelease(int newValue) +{ + return fetchAndStoreOrdered(newValue); +} + +// Fetch and add for integers + +inline int QBasicAtomicInt::fetchAndAddOrdered(int valueToAdd) +{ + return QBasicAtomicInt_fetchAndAddOrdered(&_q_value, valueToAdd); +} + +inline int QBasicAtomicInt::fetchAndAddRelaxed(int valueToAdd) +{ + return fetchAndAddOrdered(valueToAdd); +} + +inline int QBasicAtomicInt::fetchAndAddAcquire(int valueToAdd) +{ + return fetchAndAddOrdered(valueToAdd); +} + +inline int QBasicAtomicInt::fetchAndAddRelease(int valueToAdd) +{ + return fetchAndAddOrdered(valueToAdd); +} + +// Test and set for pointers + +template +Q_INLINE_TEMPLATE bool QBasicAtomicPointer::testAndSetOrdered(T *expectedValue, T *newValue) +{ + union { T * volatile * typed; void * volatile * voidp; } pointer; + pointer.typed = &_q_value; + return QBasicAtomicPointer_testAndSetOrdered(pointer.voidp, expectedValue, newValue); +} + +template +Q_INLINE_TEMPLATE bool QBasicAtomicPointer::testAndSetRelaxed(T *expectedValue, T *newValue) +{ + return testAndSetOrdered(expectedValue, newValue); +} + +template +Q_INLINE_TEMPLATE bool QBasicAtomicPointer::testAndSetAcquire(T *expectedValue, T *newValue) +{ + return testAndSetOrdered(expectedValue, newValue); +} + +template +Q_INLINE_TEMPLATE bool QBasicAtomicPointer::testAndSetRelease(T *expectedValue, T *newValue) +{ + return testAndSetOrdered(expectedValue, newValue); +} + +// Fetch and store for pointers + +template +Q_INLINE_TEMPLATE T *QBasicAtomicPointer::fetchAndStoreOrdered(T *newValue) +{ + union { T * volatile * typed; void * volatile * voidp; } pointer; + union { T *typed; void *voidp; } returnValue; + pointer.typed = &_q_value; + returnValue.voidp = QBasicAtomicPointer_fetchAndStoreOrdered(pointer.voidp, newValue); + return returnValue.typed; +} + +template +Q_INLINE_TEMPLATE T *QBasicAtomicPointer::fetchAndStoreRelaxed(T *newValue) +{ + return fetchAndStoreOrdered(newValue); +} + +template +Q_INLINE_TEMPLATE T *QBasicAtomicPointer::fetchAndStoreAcquire(T *newValue) +{ + return fetchAndStoreOrdered(newValue); +} + +template +Q_INLINE_TEMPLATE T *QBasicAtomicPointer::fetchAndStoreRelease(T *newValue) +{ + return fetchAndStoreOrdered(newValue); +} + +// Fetch and add for pointers + +template +Q_INLINE_TEMPLATE T *QBasicAtomicPointer::fetchAndAddOrdered(qptrdiff valueToAdd) +{ + union { T * volatile *typed; void * volatile *voidp; } pointer; + union { T *typed; void *voidp; } returnValue; + pointer.typed = &_q_value; + returnValue.voidp = QBasicAtomicPointer_fetchAndAddOrdered(pointer.voidp, valueToAdd * sizeof(T)); + return returnValue.typed; +} + +template +Q_INLINE_TEMPLATE T *QBasicAtomicPointer::fetchAndAddRelaxed(qptrdiff valueToAdd) +{ + return fetchAndAddOrdered(valueToAdd); +} + +template +Q_INLINE_TEMPLATE T *QBasicAtomicPointer::fetchAndAddAcquire(qptrdiff valueToAdd) +{ + return fetchAndAddOrdered(valueToAdd); +} + +template +Q_INLINE_TEMPLATE T *QBasicAtomicPointer::fetchAndAddRelease(qptrdiff valueToAdd) +{ + return fetchAndAddOrdered(valueToAdd); +} QT_END_NAMESPACE diff --git a/src/corelib/arch/symbian/arch.pri b/src/corelib/arch/symbian/arch.pri index deb94b1..3ef1c9e 100644 --- a/src/corelib/arch/symbian/arch.pri +++ b/src/corelib/arch/symbian/arch.pri @@ -2,4 +2,4 @@ # Symbian architecture # SOURCES += $$QT_ARCH_CPP/qatomic_symbian.cpp \ - $$QT_ARCH_CPP/../generic/qatomic_generic_unix.cpp + $$QT_ARCH_CPP/../armv6/qatomic_generic_armv6.cpp diff --git a/src/corelib/arch/symbian/qatomic_symbian.cpp b/src/corelib/arch/symbian/qatomic_symbian.cpp index 8f02155..2ab5ae9 100644 --- a/src/corelib/arch/symbian/qatomic_symbian.cpp +++ b/src/corelib/arch/symbian/qatomic_symbian.cpp @@ -50,7 +50,7 @@ QT_BEGIN_NAMESPACE // This way we can report on heap cells and handles that are really not owned by anything which still exists. // This information can be used to detect whether memory leaks are happening, particularly if these numbers grow as the app is used more. // This code is placed here as it happens to make it the very last static to be destroyed in a Qt app. The -// reason assumed is that this file appears before any other file declaring static data in the generated +// reason assumed is that this file appears before any other file declaring static data in the generated // Symbian MMP file. This particular file was chosen as it is the earliest symbian specific file. struct QSymbianPrintExitInfo { @@ -77,37 +77,95 @@ struct QSymbianPrintExitInfo TInt initThreadHandleCount; } symbian_printExitInfo; -QT_END_NAMESPACE +//For ARMv6, the generic atomics are machine coded +#ifndef QT_HAVE_ARMV6 +class QCriticalSection +{ +public: + QCriticalSection() { fastlock.CreateLocal(); } + ~QCriticalSection() { fastlock.Close(); } + void lock() { fastlock.Wait(); } + void unlock() { fastlock.Signal(); } -#if defined(Q_CC_RVCT) +private: + RFastLock fastlock; +}; -#include "../arm/qatomic_arm.cpp" +QCriticalSection qAtomicCriticalSection; -QT_BEGIN_NAMESPACE +Q_CORE_EXPORT +bool QBasicAtomicInt_testAndSetOrdered(volatile int *_q_value, int expectedValue, int newValue) +{ + bool returnValue = false; + qAtomicCriticalSection.lock(); + if (*_q_value == expectedValue) { + *_q_value = newValue; + returnValue = true; + } + qAtomicCriticalSection.unlock(); + return returnValue; +} -Q_CORE_EXPORT __asm char q_atomic_swp(volatile char *ptr, char newval) +Q_CORE_EXPORT +int QBasicAtomicInt_fetchAndStoreOrdered(volatile int *_q_value, int newValue) { - add r2, pc, #0 - bx r2 - arm - swpb r2,r1,[r0] - mov r0, r2 - bx lr - thumb + int returnValue; + qAtomicCriticalSection.lock(); + returnValue = *_q_value; + *_q_value = newValue; + qAtomicCriticalSection.unlock(); + return returnValue; } -Q_CORE_EXPORT __asm int QBasicAtomicInt::fetchAndStoreOrdered(int newValue) +Q_CORE_EXPORT +int QBasicAtomicInt_fetchAndAddOrdered(volatile int *_q_value, int valueToAdd) { - add r2, pc, #0 - bx r2 - arm - swp r2,r1,[r0] - mov r0, r2 - bx lr - thumb + int returnValue; + qAtomicCriticalSection.lock(); + returnValue = *_q_value; + *_q_value += valueToAdd; + qAtomicCriticalSection.unlock(); + return returnValue; } -QT_END_NAMESPACE +Q_CORE_EXPORT +bool QBasicAtomicPointer_testAndSetOrdered(void * volatile *_q_value, + void *expectedValue, + void *newValue) +{ + bool returnValue = false; + qAtomicCriticalSection.lock(); + if (*_q_value == expectedValue) { + *_q_value = newValue; + returnValue = true; + } + qAtomicCriticalSection.unlock(); + return returnValue; +} -#endif // Q_CC_RVCT +Q_CORE_EXPORT +void *QBasicAtomicPointer_fetchAndStoreOrdered(void * volatile *_q_value, void *newValue) +{ + void *returnValue; + qAtomicCriticalSection.lock(); + returnValue = *_q_value; + *_q_value = newValue; + qAtomicCriticalSection.unlock(); + return returnValue; +} + +Q_CORE_EXPORT +void *QBasicAtomicPointer_fetchAndAddOrdered(void * volatile *_q_value, qptrdiff valueToAdd) +{ + void *returnValue; + qAtomicCriticalSection.lock(); + returnValue = *_q_value; + *_q_value = reinterpret_cast(returnValue) + valueToAdd; + qAtomicCriticalSection.unlock(); + return returnValue; +} + +#endif // QT_HAVE_ARMV6 + +QT_END_NAMESPACE diff --git a/src/corelib/global/qglobal.h b/src/corelib/global/qglobal.h index d113e02..9558256 100644 --- a/src/corelib/global/qglobal.h +++ b/src/corelib/global/qglobal.h @@ -437,13 +437,18 @@ namespace QT_NAMESPACE {} #elif defined(__GCCE__) # define Q_CC_GCCE # define QT_VISIBILITY_AVAILABLE +# if defined(__ARM_ARCH_6__) || defined(__ARM_ARCH_7__) || defined(__ARM_ARCH_7A__) +# define QT_HAVE_ARMV6 +# endif /* ARM Realview Compiler Suite RVCT compiler also defines __EDG__ and __GNUC__ (if --gnu flag is given), so check for it before that */ #elif defined(__ARMCC__) || defined(__CC_ARM) # define Q_CC_RVCT - +# if __TARGET_ARCH_ARM >= 6 +# define QT_HAVE_ARMV6 +# endif #elif defined(__GNUC__) # define Q_CC_GNU # define Q_C_CALLBACKS diff --git a/src/gui/painting/painting.pri b/src/gui/painting/painting.pri index c35c33a..628a109 100644 --- a/src/gui/painting/painting.pri +++ b/src/gui/painting/painting.pri @@ -370,7 +370,6 @@ symbian { SOURCES += painting/qwindowsurface_s60.cpp armccIfdefBlock = \ "$${LITERAL_HASH}if defined(ARMV6)" \ - "MACRO QT_HAVE_ARMV6" \ "SOURCEPATH painting" \ "SOURCE qblendfunctions_armv6_rvct.s" \ "SOURCE qdrawhelper_armv6_rvct.s" \ diff --git a/src/s60installs/eabi/QtCoreu.def b/src/s60installs/eabi/QtCoreu.def index faf8b1e..17693ea 100644 --- a/src/s60installs/eabi/QtCoreu.def +++ b/src/s60installs/eabi/QtCoreu.def @@ -13,7 +13,7 @@ EXPORTS _Z11qt_int_sqrtj @ 12 NONAME _Z12noforcepointR11QTextStream @ 13 NONAME _Z12qSharedBuildv @ 14 NONAME - _Z12q_atomic_swpPVcc @ 15 NONAME + _Z12q_atomic_swpPVcc @ 15 NONAME ABSENT _Z12qt_s60GetRFsv @ 16 NONAME _Z13lowercasebaseR11QTextStream @ 17 NONAME _Z13qErrnoWarningPKcz @ 18 NONAME @@ -24,7 +24,7 @@ EXPORTS _Z15lowercasedigitsR11QTextStream @ 23 NONAME _Z15qAddPostRoutinePFvvE @ 24 NONAME _Z15qInitResourceIOv @ 25 NONAME - _Z15qt_atomic_yieldPi @ 26 NONAME + _Z15qt_atomic_yieldPi @ 26 NONAME ABSENT _Z15qt_error_stringi @ 27 NONAME _Z15uppercasedigitsR11QTextStream @ 28 NONAME _Z16qt_QString2HBufCRK7QString @ 29 NONAME @@ -706,7 +706,7 @@ EXPORTS _ZN15QAnimationGroupD0Ev @ 705 NONAME _ZN15QAnimationGroupD1Ev @ 706 NONAME _ZN15QAnimationGroupD2Ev @ 707 NONAME - _ZN15QBasicAtomicInt20fetchAndStoreOrderedEi @ 708 NONAME + _ZN15QBasicAtomicInt20fetchAndStoreOrderedEi @ 708 NONAME ABSENT _ZN15QDateTimeParser11parseFormatERK7QString @ 709 NONAME _ZN15QLinkedListData11shared_nullE @ 710 NONAME DATA 20 _ZN15QObjectUserDataD0Ev @ 711 NONAME @@ -3566,7 +3566,7 @@ EXPORTS inflateSync @ 3565 NONAME inflateSyncPoint @ 3566 NONAME qMetaTypeGuiHelper @ 3567 NONAME DATA 4 - q_atomic_lock @ 3568 NONAME DATA 1 + q_atomic_lock @ 3568 NONAME DATA 1 ABSENT qt_addObject @ 3569 NONAME qt_global_mutexpool @ 3570 NONAME DATA 4 qt_locale_initialized @ 3571 NONAME DATA 1 -- cgit v0.12 From 99c42254480fb147b0aaa01458300bae4472e3d8 Mon Sep 17 00:00:00 2001 From: Shane Kearns Date: Fri, 6 Nov 2009 13:44:04 +0100 Subject: Fix functions that return whether atomics are natives following review comments Reviewed-By: Brad --- src/corelib/arch/qatomic_symbian.h | 31 ++++++-------- src/corelib/arch/symbian/qatomic_symbian.cpp | 63 ++++++++++++++++++++++++++++ 2 files changed, 76 insertions(+), 18 deletions(-) diff --git a/src/corelib/arch/qatomic_symbian.h b/src/corelib/arch/qatomic_symbian.h index 571f628..92f6ef9 100644 --- a/src/corelib/arch/qatomic_symbian.h +++ b/src/corelib/arch/qatomic_symbian.h @@ -51,57 +51,52 @@ QT_BEGIN_NAMESPACE QT_MODULE(Core) -#define Q_ATOMIC_INT_REFERENCE_COUNTING_IS_NOT_NATIVE +#define Q_ATOMIC_INT_REFERENCE_COUNTING_IS_SOMETIMES_NATIVE -inline bool QBasicAtomicInt::isReferenceCountingNative() -{ return false; } inline bool QBasicAtomicInt::isReferenceCountingWaitFree() { return false; } -#define Q_ATOMIC_INT_TEST_AND_SET_IS_NOT_NATIVE +#define Q_ATOMIC_INT_TEST_AND_SET_IS_SOMETIMES_NATIVE -inline bool QBasicAtomicInt::isTestAndSetNative() -{ return false; } inline bool QBasicAtomicInt::isTestAndSetWaitFree() { return false; } -#define Q_ATOMIC_INT_FETCH_AND_STORE_IS_NOT_NATIVE +#define Q_ATOMIC_INT_FETCH_AND_STORE_IS_SOMETIMES_NATIVE -inline bool QBasicAtomicInt::isFetchAndStoreNative() -{ return false; } inline bool QBasicAtomicInt::isFetchAndStoreWaitFree() { return false; } -#define Q_ATOMIC_INT_FETCH_AND_ADD_IS_NOT_NATIVE +#define Q_ATOMIC_INT_FETCH_AND_ADD_IS_SOMETIMES_NATIVE -inline bool QBasicAtomicInt::isFetchAndAddNative() -{ return false; } inline bool QBasicAtomicInt::isFetchAndAddWaitFree() { return false; } -#define Q_ATOMIC_POINTER_TEST_AND_SET_IS_NOT_NATIVE +#define Q_ATOMIC_POINTER_TEST_AND_SET_IS_SOMETIMES_NATIVE +Q_CORE_EXPORT bool QBasicAtomicPointer_isTestAndSetNative(); template Q_INLINE_TEMPLATE bool QBasicAtomicPointer::isTestAndSetNative() -{ return false; } +{ return QBasicAtomicPointer_isTestAndSetNative(); } template Q_INLINE_TEMPLATE bool QBasicAtomicPointer::isTestAndSetWaitFree() { return false; } -#define Q_ATOMIC_POINTER_FETCH_AND_STORE_IS_NOT_NATIVE +#define Q_ATOMIC_POINTER_FETCH_AND_STORE_IS_SOMETIMES_NATIVE +Q_CORE_EXPORT bool QBasicAtomicPointer_isFetchAndStoreNative(); template Q_INLINE_TEMPLATE bool QBasicAtomicPointer::isFetchAndStoreNative() -{ return false; } +{ return QBasicAtomicPointer_isFetchAndStoreNative(); } template Q_INLINE_TEMPLATE bool QBasicAtomicPointer::isFetchAndStoreWaitFree() { return false; } -#define Q_ATOMIC_POINTER_FETCH_AND_ADD_IS_NOT_NATIVE +#define Q_ATOMIC_POINTER_FETCH_AND_ADD_IS_SOMETIMES_NATIVE +Q_CORE_EXPORT bool QBasicAtomicPointer_isFetchAndAddNative(); template Q_INLINE_TEMPLATE bool QBasicAtomicPointer::isFetchAndAddNative() -{ return false; } +{ return QBasicAtomicPointer_isFetchAndAddNative(); } template Q_INLINE_TEMPLATE bool QBasicAtomicPointer::isFetchAndAddWaitFree() { return false; } diff --git a/src/corelib/arch/symbian/qatomic_symbian.cpp b/src/corelib/arch/symbian/qatomic_symbian.cpp index 2ab5ae9..91b49c7 100644 --- a/src/corelib/arch/symbian/qatomic_symbian.cpp +++ b/src/corelib/arch/symbian/qatomic_symbian.cpp @@ -77,6 +77,69 @@ struct QSymbianPrintExitInfo TInt initThreadHandleCount; } symbian_printExitInfo; +Q_CORE_EXPORT bool QBasicAtomicInt::isReferenceCountingNative() +{ +#ifdef QT_HAVE_ARMV6 + return true; +#else + return false; +#endif +} + +Q_CORE_EXPORT bool QBasicAtomicInt::isTestAndSetNative() +{ +#ifdef QT_HAVE_ARMV6 + return true; +#else + return false; +#endif +} + +Q_CORE_EXPORT bool QBasicAtomicInt::isFetchAndStoreNative() +{ +#ifdef QT_HAVE_ARMV6 + return true; +#else + return false; +#endif +} + +Q_CORE_EXPORT bool QBasicAtomicInt::isFetchAndAddNative() +{ +#ifdef QT_HAVE_ARMV6 + return true; +#else + return false; +#endif +} + +Q_CORE_EXPORT bool QBasicAtomicPointer_isTestAndSetNative() +{ +#ifdef QT_HAVE_ARMV6 + return true; +#else + return false; +#endif +} + +Q_CORE_EXPORT bool QBasicAtomicPointer_isFetchAndStoreNative() +{ +#ifdef QT_HAVE_ARMV6 + return true; +#else + return false; +#endif +} + +Q_CORE_EXPORT bool QBasicAtomicPointer_isFetchAndAddNative() +{ +#ifdef QT_HAVE_ARMV6 + return true; +#else + return false; +#endif +} + //For ARMv6, the generic atomics are machine coded #ifndef QT_HAVE_ARMV6 -- cgit v0.12 From 0a07ca79318ba1b735ce0b3a208e471e4a24e1f2 Mon Sep 17 00:00:00 2001 From: Shane Kearns Date: Thu, 12 Nov 2009 19:21:25 +0100 Subject: Fix corelib def files for the new atomics implementation 4.6.0 has the wrong atomics implementation for symbian, as the team branch was not merged before the freeze. This updates the def files to match the implementation on the team branch so that it can be cherry-picked. Task-number: QTBUG-5752 Reviewed-by: Iain --- src/s60installs/bwins/QtCoreu.def | 3 +++ src/s60installs/eabi/QtCoreu.def | 7 +++++++ 2 files changed, 10 insertions(+) diff --git a/src/s60installs/bwins/QtCoreu.def b/src/s60installs/bwins/QtCoreu.def index 146d47e..1218b75 100644 --- a/src/s60installs/bwins/QtCoreu.def +++ b/src/s60installs/bwins/QtCoreu.def @@ -4384,4 +4384,7 @@ EXPORTS ?staticMetaObject@QAbstractTableModel@@2UQMetaObject@@B @ 4383 NONAME ; struct QMetaObject const QAbstractTableModel::staticMetaObject ?staticMetaObject@QFile@@2UQMetaObject@@B @ 4384 NONAME ; struct QMetaObject const QFile::staticMetaObject ?staticMetaObject@QHistoryState@@2UQMetaObject@@B @ 4385 NONAME ; struct QMetaObject const QHistoryState::staticMetaObject + ?QBasicAtomicPointer_isFetchAndAddNative@@YA_NXZ @ 4386 NONAME ; bool QBasicAtomicPointer_isFetchAndAddNative(void) + ?QBasicAtomicPointer_isFetchAndStoreNative@@YA_NXZ @ 4387 NONAME ; bool QBasicAtomicPointer_isFetchAndStoreNative(void) + ?QBasicAtomicPointer_isTestAndSetNative@@YA_NXZ @ 4388 NONAME ; bool QBasicAtomicPointer_isTestAndSetNative(void) diff --git a/src/s60installs/eabi/QtCoreu.def b/src/s60installs/eabi/QtCoreu.def index 17693ea..99be68e 100644 --- a/src/s60installs/eabi/QtCoreu.def +++ b/src/s60installs/eabi/QtCoreu.def @@ -3612,4 +3612,11 @@ EXPORTS _ZNK13QStateMachine10isAnimatedEv @ 3611 NONAME _ZNK18QAbstractAnimation15currentLoopTimeEv @ 3612 NONAME _ZNK7QRegExp12captureCountEv @ 3613 NONAME + _Z38QBasicAtomicPointer_isTestAndSetNativev @ 3614 NONAME + _Z39QBasicAtomicPointer_isFetchAndAddNativev @ 3615 NONAME + _Z41QBasicAtomicPointer_isFetchAndStoreNativev @ 3616 NONAME + _ZN15QBasicAtomicInt18isTestAndSetNativeEv @ 3617 NONAME + _ZN15QBasicAtomicInt19isFetchAndAddNativeEv @ 3618 NONAME + _ZN15QBasicAtomicInt21isFetchAndStoreNativeEv @ 3619 NONAME + _ZN15QBasicAtomicInt25isReferenceCountingNativeEv @ 3620 NONAME -- cgit v0.12 From ee8e0fc9f32a84bd1e1673c9756044d62ecaebf5 Mon Sep 17 00:00:00 2001 From: Miikka Heikkinen Date: Fri, 13 Nov 2009 13:19:56 +0200 Subject: Fixed maximized dialogs losing maximized status on orientation switch If maximized dialog had minimum size that didn't fully fit to the screen, it lost its maximized status when orientation was switched, because of the logic that assumed that if a window is resized, it must no longer be maximized. Skipped this assumption for cases where resize occurs because enforcement of the minimum size of the window. Task-number: QTBUG-4671 Reviewed-by: Janne Anttila Reviewed-by: Sami Merila --- src/gui/kernel/qwidget_s60.cpp | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/gui/kernel/qwidget_s60.cpp b/src/gui/kernel/qwidget_s60.cpp index 504a538..1acdfda 100644 --- a/src/gui/kernel/qwidget_s60.cpp +++ b/src/gui/kernel/qwidget_s60.cpp @@ -213,6 +213,15 @@ void QWidgetPrivate::setGeometry_sys(int x, int y, int w, int h, bool isMove) if ((q->windowType() == Qt::Desktop)) return; + + QPoint oldPos(q->pos()); + QSize oldSize(q->size()); + QRect oldGeom(data.crect); + + // Lose maximized status if deliberate resize + if (w != oldSize.width() || h != oldSize.height()) + data.window_state &= ~Qt::WindowMaximized; + if (extra) { // any size restrictions? w = qMin(w,extra->maxw); h = qMin(h,extra->maxh); @@ -228,17 +237,10 @@ void QWidgetPrivate::setGeometry_sys(int x, int y, int w, int h, bool isMove) data.window_state = s; } - QPoint oldPos(q->pos()); - QSize oldSize(q->size()); - QRect oldGeom(data.crect); - bool isResize = w != oldSize.width() || h != oldSize.height(); if (!isMove && !isResize) return; - if (isResize) - data.window_state &= ~Qt::WindowMaximized; - if (q->isWindow()) { if (w == 0 || h == 0) { q->setAttribute(Qt::WA_OutsideWSRange, true); -- cgit v0.12 From aa784453478ebff299a27eec1683001d2e5084bc Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Fri, 13 Nov 2009 13:22:41 +0100 Subject: Fix QAbstractSlider test Commit 46a3e518b3070c changed the behaviour of a wheel event of a different orientation. It works now no matter where the event was. Reviewed-by: Denis Reviewed-by: Thierry --- tests/auto/qabstractslider/tst_qabstractslider.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/tests/auto/qabstractslider/tst_qabstractslider.cpp b/tests/auto/qabstractslider/tst_qabstractslider.cpp index d9574df..ee1ba19 100644 --- a/tests/auto/qabstractslider/tst_qabstractslider.cpp +++ b/tests/auto/qabstractslider/tst_qabstractslider.cpp @@ -742,11 +742,9 @@ void tst_QAbstractSlider::wheelEvent_data() << 1 // delta << int(Qt::Horizontal) // orientation of slider << int(Qt::Vertical) // orientation of wheel - << 0 // expected position after + << 1 // expected position after << QPoint(1,1); - // Scrolling in a slider of a different orientation than the wheel works - // if the mouse pointer is within the widget's rect QTest::newRow("Different orientation2")<< 0 // initial position << 0 // minimum << 100 // maximum -- cgit v0.12 From 0f236d91fbca19838a71df025446725fea2ca87a Mon Sep 17 00:00:00 2001 From: Jason McDonald Date: Fri, 13 Nov 2009 22:53:32 +1000 Subject: Fix broken merge of changes file. Reviewed-by: Trust Me --- dist/changes-4.6.0 | 4 ---- 1 file changed, 4 deletions(-) diff --git a/dist/changes-4.6.0 b/dist/changes-4.6.0 index 7c97aa5..eaacdae 100644 --- a/dist/changes-4.6.0 +++ b/dist/changes-4.6.0 @@ -15,10 +15,6 @@ Qt Bug Tracker: http://bugreports.qt.nokia.com Task Tracker: http://qt.nokia.com/developer/task-tracker Merge Request: http://qt.gitorious.org -QTBUG-1234 - Qt Bug Tracker: http://bugreports.qt.nokia.com -MR#1234 - Merge Request: http://qt.gitorious.org -123456 - Task Tracker: http://qt.nokia.com/developer/task-tracker - **************************************************************************** * General * **************************************************************************** -- cgit v0.12 From aff0df17051c4f251c86bc4d7929930e39514742 Mon Sep 17 00:00:00 2001 From: Kim Motoyoshi Kalland Date: Fri, 13 Nov 2009 13:22:41 +0100 Subject: Fixed stroking of discontinuous paths with the GL2 engine. Since the stroke is rendered as a triangle strip, zero area triangles must be inserted in order to have gaps in the stroke. This is achieved by duplicating vertices before and after each gap. It was already done for open subpaths. This commit fixes gaps between closed subpaths. Task-number: QTBUG-5736 Reviewed-by: Gunnar --- src/opengl/gl2paintengineex/qtriangulatingstroker.cpp | 3 +++ src/opengl/gl2paintengineex/qtriangulatingstroker_p.h | 4 ---- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/opengl/gl2paintengineex/qtriangulatingstroker.cpp b/src/opengl/gl2paintengineex/qtriangulatingstroker.cpp index 1163eba..206104f 100644 --- a/src/opengl/gl2paintengineex/qtriangulatingstroker.cpp +++ b/src/opengl/gl2paintengineex/qtriangulatingstroker.cpp @@ -61,6 +61,9 @@ void QTriangulatingStroker::endCapOrJoinClosed(const qreal *start, const qreal * } else { endCap(cur); } + int count = m_vertices.size(); + m_vertices.add(m_vertices.at(count-2)); + m_vertices.add(m_vertices.at(count-1)); } diff --git a/src/opengl/gl2paintengineex/qtriangulatingstroker_p.h b/src/opengl/gl2paintengineex/qtriangulatingstroker_p.h index defa3f1..a0117d5 100644 --- a/src/opengl/gl2paintengineex/qtriangulatingstroker_p.h +++ b/src/opengl/gl2paintengineex/qtriangulatingstroker_p.h @@ -188,10 +188,6 @@ inline void QTriangulatingStroker::endCap(const qreal *pts) break; default: break; // to shut gcc up... } - - int count = m_vertices.size(); - m_vertices.add(m_vertices.at(count-2)); - m_vertices.add(m_vertices.at(count-1)); } -- cgit v0.12 From d324a151a45fa30ff3cb139ce009a1ba20122c7e Mon Sep 17 00:00:00 2001 From: Thierry Bastian Date: Fri, 13 Nov 2009 14:00:12 +0100 Subject: Fixing and adding autotests for QTreeWidget Reviewed-By: ogoffart --- tests/auto/qtreewidget/tst_qtreewidget.cpp | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/tests/auto/qtreewidget/tst_qtreewidget.cpp b/tests/auto/qtreewidget/tst_qtreewidget.cpp index 6defd7b..621072c 100644 --- a/tests/auto/qtreewidget/tst_qtreewidget.cpp +++ b/tests/auto/qtreewidget/tst_qtreewidget.cpp @@ -167,6 +167,7 @@ private slots: void setCurrentItemExpandsParent(); void task239150_editorWidth(); void setTextUpdate(); + void taskQTBUG2844_visualItemRect(); public slots: void itemSelectionChanged(); @@ -601,9 +602,9 @@ void tst_QTreeWidget::setItemHidden() testWidget->scrollToItem(child); QVERIFY(testWidget->visualItemRect(parent).isValid() - && testWidget->viewport()->rect().contains(testWidget->visualItemRect(parent))); + && testWidget->viewport()->rect().intersects(testWidget->visualItemRect(parent))); QVERIFY(testWidget->visualItemRect(child).isValid() - && testWidget->viewport()->rect().contains(testWidget->visualItemRect(child))); + && testWidget->viewport()->rect().intersects(testWidget->visualItemRect(child))); QVERIFY(!testWidget->isItemHidden(parent)); QVERIFY(!testWidget->isItemHidden(child)); @@ -611,9 +612,9 @@ void tst_QTreeWidget::setItemHidden() testWidget->setItemHidden(parent, true); QVERIFY(!(testWidget->visualItemRect(parent).isValid() - && testWidget->viewport()->rect().contains(testWidget->visualItemRect(parent)))); + && testWidget->viewport()->rect().intersects(testWidget->visualItemRect(parent)))); QVERIFY(!(testWidget->visualItemRect(child).isValid() - && testWidget->viewport()->rect().contains(testWidget->visualItemRect(child)))); + && testWidget->viewport()->rect().intersects(testWidget->visualItemRect(child)))); QVERIFY(testWidget->isItemHidden(parent)); QVERIFY(!testWidget->isItemHidden(child)); @@ -3271,6 +3272,25 @@ void tst_QTreeWidget::setTextUpdate() QTRY_VERIFY(delegate.numPaints > 0); } +void tst_QTreeWidget::taskQTBUG2844_visualItemRect() +{ + CustomTreeWidget tree; + tree.resize(150, 100); + tree.setColumnCount(3); + QTreeWidgetItem item(&tree); + + QRect itemRect = tree.visualItemRect(&item); + + QRect rectCol0 = tree.visualRect(tree.indexFromItem(&item, 0)); + QRect rectCol1 = tree.visualRect(tree.indexFromItem(&item, 1)); + QRect rectCol2 = tree.visualRect(tree.indexFromItem(&item, 2)); + + QCOMPARE(tree.visualItemRect(&item), rectCol0 | rectCol2); + tree.setColumnHidden(2, true); + QCOMPARE(tree.visualItemRect(&item), rectCol0 | rectCol1); +} + + QTEST_MAIN(tst_QTreeWidget) -- cgit v0.12 From d0edd9b3d6ee5dba8e9a23d0fb9aaab74924d2ad Mon Sep 17 00:00:00 2001 From: Tom Cooksey Date: Wed, 11 Nov 2009 12:25:56 +0100 Subject: Add mkspec for Maemo 5 & 6 Reviewed-By: Robert Griebl Reviewed-By: Thiago Macieira --- mkspecs/linux-g++-maemo/qmake.conf | 28 ++++++++++++++++++++++ mkspecs/linux-g++-maemo/qplatformdefs.h | 42 +++++++++++++++++++++++++++++++++ 2 files changed, 70 insertions(+) create mode 100644 mkspecs/linux-g++-maemo/qmake.conf create mode 100644 mkspecs/linux-g++-maemo/qplatformdefs.h diff --git a/mkspecs/linux-g++-maemo/qmake.conf b/mkspecs/linux-g++-maemo/qmake.conf new file mode 100644 index 0000000..067d857 --- /dev/null +++ b/mkspecs/linux-g++-maemo/qmake.conf @@ -0,0 +1,28 @@ +# +# qmake configuration for Maemo 5 & 6 +# + +MAKEFILE_GENERATOR = UNIX +TEMPLATE = app +CONFIG += qt warn_on release incremental link_prl +QT += core gui +QMAKE_INCREMENTAL_STYLE = sublib + +include(../common/g++.conf) +include(../common/linux.conf) + +# Work round scratchbox not having standard paths in it's default search path +QMAKE_LFLAGS += -Wl,-rpath-link=/lib +QMAKE_LFLAGS += -Wl,-rpath-link=/usr/lib + +# Override the default lib/include directories for scratchbox: +QMAKE_INCDIR_X11 = /usr/include/X11 +QMAKE_INCDIR_OPENGL = /usr/include +QMAKE_LIBDIR_X11 = /usr/lib +QMAKE_LIBDIR_OPENGL = /usr/lib + +# Work round PowerVR SGX 1.3 driver bug with glScissor & FBOs: +DEFINES += QT_GL_NO_SCISSOR_TEST + + +load(qt_config) diff --git a/mkspecs/linux-g++-maemo/qplatformdefs.h b/mkspecs/linux-g++-maemo/qplatformdefs.h new file mode 100644 index 0000000..857eaf3 --- /dev/null +++ b/mkspecs/linux-g++-maemo/qplatformdefs.h @@ -0,0 +1,42 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the qmake spec of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "../linux-g++/qplatformdefs.h" -- cgit v0.12 From c95acfda6aae0dcf4285bb759a271598bb2dccea Mon Sep 17 00:00:00 2001 From: Tom Cooksey Date: Wed, 11 Nov 2009 12:32:04 +0100 Subject: Generate debug symbols in release mode on Maemo Reviewed-By: Stefano Pironato --- mkspecs/linux-g++-maemo/qmake.conf | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/mkspecs/linux-g++-maemo/qmake.conf b/mkspecs/linux-g++-maemo/qmake.conf index 067d857..2195329 100644 --- a/mkspecs/linux-g++-maemo/qmake.conf +++ b/mkspecs/linux-g++-maemo/qmake.conf @@ -21,6 +21,10 @@ QMAKE_INCDIR_OPENGL = /usr/include QMAKE_LIBDIR_X11 = /usr/lib QMAKE_LIBDIR_OPENGL = /usr/lib +# We still need to generate debug symbols in release mode to put into the *-dbg packages: +QMAKE_CFLAGS_RELEASE += -g +QMAKE_CXXFLAGS_RELEASE += -g + # Work round PowerVR SGX 1.3 driver bug with glScissor & FBOs: DEFINES += QT_GL_NO_SCISSOR_TEST -- cgit v0.12 From c9211c691b370332b9165a9d80f03220789c1d53 Mon Sep 17 00:00:00 2001 From: Tom Cooksey Date: Wed, 11 Nov 2009 13:43:55 +0100 Subject: Disable optimisations which break stack traces on Maemo The -O2 mode enables omit-frame-pointer & optimize-sibling-calls, which can break stack traces. So, even in release mode, disable these optimisations so that we can at least still get a backtrace when a Qt application dies. Reviewed-By: Stefano Pironato --- mkspecs/linux-g++-maemo/qmake.conf | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mkspecs/linux-g++-maemo/qmake.conf b/mkspecs/linux-g++-maemo/qmake.conf index 2195329..c39ba2c 100644 --- a/mkspecs/linux-g++-maemo/qmake.conf +++ b/mkspecs/linux-g++-maemo/qmake.conf @@ -22,8 +22,8 @@ QMAKE_LIBDIR_X11 = /usr/lib QMAKE_LIBDIR_OPENGL = /usr/lib # We still need to generate debug symbols in release mode to put into the *-dbg packages: -QMAKE_CFLAGS_RELEASE += -g -QMAKE_CXXFLAGS_RELEASE += -g +QMAKE_CFLAGS_RELEASE += -g -fno-omit-frame-pointer -fno-optimize-sibling-calls +QMAKE_CXXFLAGS_RELEASE += -g -fno-omit-frame-pointer -fno-optimize-sibling-calls # Work round PowerVR SGX 1.3 driver bug with glScissor & FBOs: DEFINES += QT_GL_NO_SCISSOR_TEST -- cgit v0.12 From 0c6255485dd2c59bfbb307583f2efe4dec8605cf Mon Sep 17 00:00:00 2001 From: ninerider Date: Fri, 13 Nov 2009 14:32:24 +0100 Subject: Cursor motion related tests disabled for windows ce. When calling cursor function, Windows CE responds with: This function is not supported on this system. Reviewed-by: Joerg --- tests/auto/qcombobox/tst_qcombobox.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/auto/qcombobox/tst_qcombobox.cpp b/tests/auto/qcombobox/tst_qcombobox.cpp index cc59b62..e903ab5 100644 --- a/tests/auto/qcombobox/tst_qcombobox.cpp +++ b/tests/auto/qcombobox/tst_qcombobox.cpp @@ -2479,6 +2479,10 @@ void tst_QComboBox::keyBoardNavigationWithMouse() QCOMPARE(combo.currentText(), QLatin1String("0")); +#ifdef Q_OS_WINCE + QSKIP("When calling cursor function, Windows CE responds with: This function is not supported on this system.", SkipAll); +#endif + QCursor::setPos(combo.view()->mapToGlobal(combo.view()->rect().center())); QTest::qWait(200); -- cgit v0.12 From 520ef13479e42b3eb1af96104fdad831905c53c2 Mon Sep 17 00:00:00 2001 From: ninerider Date: Fri, 13 Nov 2009 14:35:34 +0100 Subject: ChangeWindowTitle skipped for Windows CE Test fails on Windows CE due to QWorkspace state handling. As this class is obsolete, skipping this test resonable. The problem is added to the watch list for Windows CE in case it reappears. Reviewed-by: Joerg --- tests/auto/qworkspace/tst_qworkspace.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/auto/qworkspace/tst_qworkspace.cpp b/tests/auto/qworkspace/tst_qworkspace.cpp index c1fe3e0..35f8a4d 100644 --- a/tests/auto/qworkspace/tst_qworkspace.cpp +++ b/tests/auto/qworkspace/tst_qworkspace.cpp @@ -426,6 +426,9 @@ void tst_QWorkspace::showWindows() void tst_QWorkspace::changeWindowTitle() { +#ifdef Q_OS_WINCE + QSKIP( "Test fails on Windows CE due to QWorkspace state handling", SkipAll); +#endif const QString mwc( "MainWindow's Caption" ); const QString mwc2( "MainWindow's New Caption" ); const QString wc( "Widget's Caption" ); -- cgit v0.12 From aefd76b0052cd36ed7f890dd4b91f38873bec251 Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Fri, 13 Nov 2009 15:00:25 +0100 Subject: QItemSelectionModel: fixed selection not kept when layout change and everything is selected The arbitrary number in commit 8a7700ffb5e4959e78 was not big enough. People still complains Task-number: QTBUG-5671 Reviewed-by: Thierry --- src/gui/itemviews/qitemselectionmodel.cpp | 5 +- .../tst_qitemselectionmodel.cpp | 65 ++++++++++++++++++++-- 2 files changed, 62 insertions(+), 8 deletions(-) diff --git a/src/gui/itemviews/qitemselectionmodel.cpp b/src/gui/itemviews/qitemselectionmodel.cpp index c6e02a6..2e4a602 100644 --- a/src/gui/itemviews/qitemselectionmodel.cpp +++ b/src/gui/itemviews/qitemselectionmodel.cpp @@ -730,13 +730,14 @@ void QItemSelectionModelPrivate::_q_layoutAboutToBeChanged() savedPersistentIndexes.clear(); savedPersistentCurrentIndexes.clear(); - // special case for when all indexes are selected + // optimisation for when all indexes are selected + // (only if there is lots of items (1000) because this is not entirely correct) if (ranges.isEmpty() && currentSelection.count() == 1) { QItemSelectionRange range = currentSelection.first(); QModelIndex parent = range.parent(); tableRowCount = model->rowCount(parent); tableColCount = model->columnCount(parent); - if (tableRowCount * tableColCount > 100 + if (tableRowCount * tableColCount > 1000 && range.top() == 0 && range.left() == 0 && range.bottom() == tableRowCount - 1 diff --git a/tests/auto/qitemselectionmodel/tst_qitemselectionmodel.cpp b/tests/auto/qitemselectionmodel/tst_qitemselectionmodel.cpp index 77c259c..269afbd 100644 --- a/tests/auto/qitemselectionmodel/tst_qitemselectionmodel.cpp +++ b/tests/auto/qitemselectionmodel/tst_qitemselectionmodel.cpp @@ -92,6 +92,7 @@ private slots: void task252069_rowIntersectsSelection(); void task232634_childrenDeselectionSignal(); void task260134_layoutChangedWithAllSelected(); + void QTBUG5671_layoutChangedWithAllSelected(); private: QAbstractItemModel *model; @@ -2025,24 +2026,24 @@ void tst_QItemSelectionModel::task220420_selectedIndexes() class QtTestTableModel: public QAbstractTableModel { Q_OBJECT - + public: QtTestTableModel(int rows = 0, int columns = 0, QObject *parent = 0) : QAbstractTableModel(parent), row_count(rows), column_count(columns) {} - + int rowCount(const QModelIndex& = QModelIndex()) const { return row_count; } int columnCount(const QModelIndex& = QModelIndex()) const { return column_count; } bool isEditable(const QModelIndex &) const { return true; } - + QVariant data(const QModelIndex &idx, int role) const { if (role == Qt::DisplayRole || role == Qt::EditRole) return QString("[%1,%2]").arg(idx.row()).arg(idx.column()); return QVariant(); } - + int row_count; int column_count; friend class tst_QItemSelectionModel; @@ -2055,7 +2056,7 @@ void tst_QItemSelectionModel::task240734_layoutChanged() QItemSelectionModel selectionModel(&model); selectionModel.select(model.index(0,0), QItemSelectionModel::Select); QCOMPARE(selectionModel.selectedIndexes().count() , 1); - + emit model.layoutAboutToBeChanged(); model.row_count = 5; emit model.layoutChanged(); @@ -2107,7 +2108,7 @@ void tst_QItemSelectionModel::merge_data() << QItemSelection(model->index(2, 2) , model->index(3, 4)) << int(QItemSelectionModel::Deselect) << QItemSelection(model->index(2, 1) , model->index(3, 1)); - + QItemSelection r1(model->index(2, 1) , model->index(3, 1)); r1.select(model->index(2, 4) , model->index(3, 4)); QTest::newRow("Toggle") @@ -2274,5 +2275,57 @@ void tst_QItemSelectionModel::task260134_layoutChangedWithAllSelected() } +void tst_QItemSelectionModel::QTBUG5671_layoutChangedWithAllSelected() +{ + struct MyFilterModel : public QSortFilterProxyModel + { // Override sort filter proxy to remove even numbered rows. + bool filtering; + virtual bool filterAcceptsRow( int source_row, const QModelIndex& source_parent ) const + { + return !filtering || !( source_row & 1 ); + } + }; + + //same as task260134_layoutChangedWithAllSelected but with a sightly bigger model + + enum { cNumRows=30, cNumCols=20 }; + + QStandardItemModel model(cNumRows, cNumCols); + MyFilterModel proxy; + proxy.filtering = true; + proxy.setSourceModel(&model); + QItemSelectionModel selection(&proxy); + + // Populate the tree view. + for (unsigned int i = 0; i < cNumCols; i++) + model.setHeaderData( i, Qt::Horizontal, QString::fromLatin1("Column %1").arg(i)); + + for (unsigned int r = 0; r < cNumRows; r++) { + for (unsigned int c = 0; c < cNumCols; c++) { + model.setData(model.index(r, c, QModelIndex()), + QString::fromLatin1("r:%1/c:%2").arg(r, c)); + } + } + + + QCOMPARE(model.rowCount(), int(cNumRows)); + QCOMPARE(proxy.rowCount(), int(cNumRows/2)); + + selection.select( QItemSelection(proxy.index(0,0), proxy.index(proxy.rowCount() - 1, proxy.columnCount() - 1)), QItemSelectionModel::Select); + + QList indexList; + foreach(const QModelIndex &id, selection.selectedIndexes()) + indexList << id; + + proxy.filtering = false; + proxy.invalidate(); + QCOMPARE(proxy.rowCount(), int(cNumRows)); + + //let's check the selection hasn't changed + QCOMPARE(selection.selectedIndexes().count(), indexList.count()); + foreach(QPersistentModelIndex index, indexList) + QVERIFY(selection.isSelected(index)); +} + QTEST_MAIN(tst_QItemSelectionModel) #include "tst_qitemselectionmodel.moc" -- cgit v0.12 From 3a48a44f39a39126a9065f9b349b8906662f07b6 Mon Sep 17 00:00:00 2001 From: Thierry Bastian Date: Fri, 13 Nov 2009 16:16:05 +0100 Subject: Fixed dockwidget autotest on X11 --- tests/auto/qdockwidget/tst_qdockwidget.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tests/auto/qdockwidget/tst_qdockwidget.cpp b/tests/auto/qdockwidget/tst_qdockwidget.cpp index c9a7f1c..8f72e39 100644 --- a/tests/auto/qdockwidget/tst_qdockwidget.cpp +++ b/tests/auto/qdockwidget/tst_qdockwidget.cpp @@ -50,6 +50,7 @@ #include #include #include +#include "private/qdockwidget_p.h" bool hasFeature(QDockWidget *dockwidget, QDockWidget::DockWidgetFeature feature) { return (dockwidget->features() & feature) == feature; } @@ -865,7 +866,9 @@ void tst_QDockWidget::taskQTBUG_1665_closableChanged() dock.show(); QTest::qWaitForWindowShown(&dock); - if (dock.windowFlags() & Qt::FramelessWindowHint) + QDockWidgetLayout *l = qobject_cast(dock.layout()); + + if (l && !l->nativeWindowDeco()) QSKIP("this machine doesn't support native dock widget", SkipAll); QVERIFY(dock.windowFlags() & Qt::WindowCloseButtonHint); -- cgit v0.12 From c4dbc1c3feb04efae2734eb9f80735b47bc0d195 Mon Sep 17 00:00:00 2001 From: Shane Kearns Date: Fri, 13 Nov 2009 16:31:10 +0100 Subject: Remove fake right mouse button events from long tap The context menu is launched by a separate event, not by the right mouse button. Generating the fake right mouse button caused side effects. We now treat the touch screen as a one button mouse, long taps still open the context menu using QContextMenuEvent. Task-number: QTBUG-5180 Reviewed-by: axis --- src/gui/kernel/qapplication_s60.cpp | 20 +------------------- src/gui/kernel/qt_s60_p.h | 1 - 2 files changed, 1 insertion(+), 20 deletions(-) diff --git a/src/gui/kernel/qapplication_s60.cpp b/src/gui/kernel/qapplication_s60.cpp index 04e4b31..c7f0c00 100644 --- a/src/gui/kernel/qapplication_s60.cpp +++ b/src/gui/kernel/qapplication_s60.cpp @@ -323,7 +323,6 @@ QSymbianControl::QSymbianControl(QWidget *w) , qwidget(w) , m_longTapDetector(0) , m_ignoreFocusChanged(0) - , m_previousEventLongTap(0) , m_symbianPopupIsOpen(0) { } @@ -362,9 +361,6 @@ QSymbianControl::~QSymbianControl() setFocusSafely(false); S60->appUi()->RemoveFromStack(this); delete m_longTapDetector; - - if(m_previousEventLongTap) - QApplicationPrivate::mouse_buttons = QApplicationPrivate::mouse_buttons & ~Qt::RightButton; } void QSymbianControl::setWidget(QWidget *w) @@ -379,19 +375,11 @@ void QSymbianControl::HandleLongTapEventL( const TPoint& aPenEventLocation, cons alienWidget = qwidget->childAt(widgetPos); if (!alienWidget) alienWidget = qwidget; - QApplicationPrivate::mouse_buttons = QApplicationPrivate::mouse_buttons &(~Qt::LeftButton); - QApplicationPrivate::mouse_buttons = QApplicationPrivate::mouse_buttons | Qt::RightButton; - QMouseEvent mEvent(QEvent::MouseButtonPress, alienWidget->mapFrom(qwidget, widgetPos), globalPos, - Qt::RightButton, QApplicationPrivate::mouse_buttons, Qt::NoModifier); - - bool res = sendMouseEvent(alienWidget, &mEvent); #if !defined(QT_NO_CONTEXTMENU) - QContextMenuEvent contextMenuEvent(QContextMenuEvent::Mouse, widgetPos, globalPos, mEvent.modifiers()); + QContextMenuEvent contextMenuEvent(QContextMenuEvent::Mouse, widgetPos, globalPos, Qt::NoModifier); qt_sendSpontaneousEvent(alienWidget, &contextMenuEvent); #endif - - m_previousEventLongTap = true; } #ifdef QT_SYMBIAN_SUPPORTS_ADVANCED_POINTER @@ -515,12 +503,6 @@ void QSymbianControl::HandlePointerEvent(const TPointerEvent& pEvent) mapS60MouseEventTypeToQt(&type, &button, &pEvent); Qt::KeyboardModifiers modifiers = mapToQtModifiers(pEvent.iModifiers); - if (m_previousEventLongTap) - if (type == QEvent::MouseButtonRelease){ - button = Qt::RightButton; - QApplicationPrivate::mouse_buttons = QApplicationPrivate::mouse_buttons & ~Qt::RightButton; - m_previousEventLongTap = false; - } if (type == QMouseEvent::None) return; diff --git a/src/gui/kernel/qt_s60_p.h b/src/gui/kernel/qt_s60_p.h index ec8c9cb..08f8bb5 100644 --- a/src/gui/kernel/qt_s60_p.h +++ b/src/gui/kernel/qt_s60_p.h @@ -204,7 +204,6 @@ private: QWidget *qwidget; QLongTapTimer* m_longTapDetector; bool m_ignoreFocusChanged : 1; - bool m_previousEventLongTap : 1; bool m_symbianPopupIsOpen : 1; #ifdef Q_WS_S60 -- cgit v0.12 From 099d6efe275511f18b0bc0002ac8cedd193139cd Mon Sep 17 00:00:00 2001 From: Kim Motoyoshi Kalland Date: Fri, 13 Nov 2009 17:00:45 +0100 Subject: Fixed stroking of cosmetic dashed pens with the GL2 paint engine. Also fixed square caps which in some cases were extruded in the wrong direction. Task-number: QTBUG-5736 Reviewed-by: Trond --- src/opengl/gl2paintengineex/qtriangulatingstroker.cpp | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/opengl/gl2paintengineex/qtriangulatingstroker.cpp b/src/opengl/gl2paintengineex/qtriangulatingstroker.cpp index 206104f..1478b09 100644 --- a/src/opengl/gl2paintengineex/qtriangulatingstroker.cpp +++ b/src/opengl/gl2paintengineex/qtriangulatingstroker.cpp @@ -147,7 +147,6 @@ void QTriangulatingStroker::process(const QVectorPath &path, const QPen &pen) bool endsAtStart = startPts[0] == *(endPts-2) && startPts[1] == *(endPts-1); - Qt::PenCapStyle cap = m_cap_style; if (endsAtStart || path.hasImplicitClose()) m_cap_style = Qt::FlatCap; moveTo(pts); @@ -169,7 +168,7 @@ void QTriangulatingStroker::process(const QVectorPath &path, const QPen &pen) switch (*types) { case QPainterPath::MoveToElement: { if (pts != path.points()) - endCapOrJoinClosed(startPts, pts, path.hasImplicitClose(), endsAtStart); + endCapOrJoinClosed(startPts, pts-2, path.hasImplicitClose(), endsAtStart); startPts = pts; int end = (endPts - pts) / 2; @@ -247,8 +246,6 @@ void QTriangulatingStroker::cubicTo(const qreal *pts) m_nvy = vy; } - - static void qdashprocessor_moveTo(qreal x, qreal y, void *data) { ((QDashedStrokeProcessor *) data)->addElement(QPainterPath::MoveToElement, x, y); @@ -282,12 +279,12 @@ void QDashedStrokeProcessor::process(const QVectorPath &path, const QPen &pen) m_points.reset(); m_types.reset(); - qreal width = pen.width(); + qreal width = qpen_widthf(pen); if (width == 0) width = 1; m_dash_stroker.setDashPattern(pen.dashPattern()); - m_dash_stroker.setStrokeWidth(width); + m_dash_stroker.setStrokeWidth(pen.isCosmetic() ? width * m_inv_scale : width); m_dash_stroker.setMiterLimit(pen.miterLimit()); qreal curvyness = sqrt(width) * m_inv_scale / 8; -- cgit v0.12 From 57e2d478c47544c553d2a12237fa30b2c859536b Mon Sep 17 00:00:00 2001 From: Liang Qi Date: Fri, 13 Nov 2009 17:08:05 +0100 Subject: Fix tst_qfile, disable largefile for symbian. RevBy: TrustMe --- tests/auto/qfile/qfile.pro | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/auto/qfile/qfile.pro b/tests/auto/qfile/qfile.pro index f70f750..33fd2fd 100644 --- a/tests/auto/qfile/qfile.pro +++ b/tests/auto/qfile/qfile.pro @@ -5,5 +5,5 @@ wince*:{ SUBDIRS = test stdinprocess } -SUBDIRS += largefile +!symbian*:SUBDIRS += largefile -- cgit v0.12 From cbdfc6c2f761af6248355bf9bf71ac011d48b14b Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Fri, 13 Nov 2009 17:09:06 +0100 Subject: Fix Qt file header, as spotted by tst_headers. Reviewed-By: Trust Me --- tools/assistant/lib/qhelp_global.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/assistant/lib/qhelp_global.cpp b/tools/assistant/lib/qhelp_global.cpp index 980de27..749d2c9 100644 --- a/tools/assistant/lib/qhelp_global.cpp +++ b/tools/assistant/lib/qhelp_global.cpp @@ -4,7 +4,7 @@ ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** -** This file is part of the Qt Assistant. +** This file is part of the Qt Assistant of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** No Commercial Usage -- cgit v0.12 From 900b24a38e9b07250ce900e45fb73a369f6fe62b Mon Sep 17 00:00:00 2001 From: Liang Qi Date: Fri, 13 Nov 2009 17:17:51 +0100 Subject: Fix tst_collections compliation on symbian. RevBy: TrustMe --- tests/auto/collections/tst_collections.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/auto/collections/tst_collections.cpp b/tests/auto/collections/tst_collections.cpp index f97805e..84f466b 100644 --- a/tests/auto/collections/tst_collections.cpp +++ b/tests/auto/collections/tst_collections.cpp @@ -3586,7 +3586,7 @@ void tst_Collections::alignment() #else void tst_Collections::alignment() { - QSKIP("Compiler doesn't support necessary extension keywords", SkipAll) + QSKIP("Compiler doesn't support necessary extension keywords", SkipAll); } #endif -- cgit v0.12 From 379cea3cfdccf5a880241ca707ffc37170cb3736 Mon Sep 17 00:00:00 2001 From: Thierry Bastian Date: Fri, 13 Nov 2009 17:44:03 +0100 Subject: Fixed a regression in mainwindow that would not restore correctly The size of the dockwidgets would be ignored. Reviewed-by: ogoffart --- src/gui/widgets/qdockarealayout.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/gui/widgets/qdockarealayout.cpp b/src/gui/widgets/qdockarealayout.cpp index 953edab..07914b2 100644 --- a/src/gui/widgets/qdockarealayout.cpp +++ b/src/gui/widgets/qdockarealayout.cpp @@ -1931,9 +1931,6 @@ bool QDockAreaLayoutInfo::restoreState(QDataStream &stream, QList item_list.append(item); } else { QDockAreaLayoutItem item(new QDockWidgetItem(widget)); - if (!testing) { - item_list.append(item); - } if (flags & StateFlagFloating) { bool drawer = false; #ifdef Q_WS_MAC // drawer support @@ -1971,11 +1968,13 @@ bool QDockAreaLayoutInfo::restoreState(QDataStream &stream, QList if (!testing) { widget->setVisible(flags & StateFlagVisible); + item_list.append(item); } } else { int dummy; stream >> item.pos >> item.size >> dummy >> dummy; if (!testing) { + item_list.append(item); widget->setFloating(false); widget->setVisible(flags & StateFlagVisible); emit widget->dockLocationChanged(toDockWidgetArea(dockPos)); -- cgit v0.12 From 85c341cee6bf3f4fa611e6d691a9156feb5d835e Mon Sep 17 00:00:00 2001 From: Shane Kearns Date: Fri, 13 Nov 2009 18:05:29 +0100 Subject: Fix build error in QLibrary autotest Reviewed-by: Liang Qi --- tests/auto/qlibrary/lib2/lib2.pro | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/auto/qlibrary/lib2/lib2.pro b/tests/auto/qlibrary/lib2/lib2.pro index 436d7ba..fc00af8 100644 --- a/tests/auto/qlibrary/lib2/lib2.pro +++ b/tests/auto/qlibrary/lib2/lib2.pro @@ -37,9 +37,9 @@ symbian-abld: { symbian-sbsv2: { TARGET.CAPABILITY=ALL -TCB QMAKE_POST_LINK = \ - $(GNUCP) $${EPOCROOT}epoc32/release/$(PLATFORM_PATH)/$(CFG_PATH)/mylib.dll $${EPOCROOT}epoc32/release/$(PLATFORM_PATH)/$(CFG_PATH)/mylib.dl2 && \ - $(GNUCP) $${EPOCROOT}epoc32/release/$(PLATFORM_PATH)/$(CFG_PATH)/mylib.dll $${EPOCROOT}epoc32/release/$(PLATFORM_PATH)/$(CFG_PATH)/system.trolltech.test.mylib.dll && \ - if test $(PLATFORM) != WINSCW;then $(GNUCP) $${EPOCROOT}epoc32/release/$(PLATFORM_PATH)/$(CFG_PATH)/mylib.dll $${PWD}/../tst/mylib.dl2; fi + $(GNUCP) $(EPOCROOT)epoc32/release/$(PLATFORM_PATH)/$(CFG_PATH)/mylib.dll $(EPOCROOT)epoc32/release/$(PLATFORM_PATH)/$(CFG_PATH)/mylib.dl2 && \ + $(GNUCP) $(EPOCROOT)epoc32/release/$(PLATFORM_PATH)/$(CFG_PATH)/mylib.dll $(EPOCROOT)epoc32/release/$(PLATFORM_PATH)/$(CFG_PATH)/system.trolltech.test.mylib.dll && \ + if test $(PLATFORM) != WINSCW;then $(GNUCP) $(EPOCROOT)epoc32/release/$(PLATFORM_PATH)/$(CFG_PATH)/mylib.dll $${PWD}/../tst/mylib.dl2; fi } #no special install rule for the library used by test -- cgit v0.12 From d7abb14d1f4b8d5cca31ff9ec004eef7bf4cb9a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan-Arve=20S=C3=A6ther?= Date: Fri, 13 Nov 2009 18:14:09 +0100 Subject: Remove warning. (Forgot to commit this together with my previous commits) --- src/gui/graphicsview/qgraphicsanchorlayout.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/graphicsview/qgraphicsanchorlayout.h b/src/gui/graphicsview/qgraphicsanchorlayout.h index 1a0c458..063639e 100644 --- a/src/gui/graphicsview/qgraphicsanchorlayout.h +++ b/src/gui/graphicsview/qgraphicsanchorlayout.h @@ -76,7 +76,7 @@ private: Q_DECLARE_PRIVATE(QGraphicsAnchor) friend class QGraphicsAnchorLayoutPrivate; - friend class AnchorData; + friend struct AnchorData; }; class Q_GUI_EXPORT QGraphicsAnchorLayout : public QGraphicsLayout -- cgit v0.12 From bb818bf70cef00bbdcafaac1bf017575baeab8dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan-Arve=20S=C3=A6ther?= Date: Fri, 13 Nov 2009 18:17:32 +0100 Subject: Make it clear that the two semi-floating widget should overflow. --- examples/graphicsview/anchorlayout/main.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/graphicsview/anchorlayout/main.cpp b/examples/graphicsview/anchorlayout/main.cpp index 3e19f18..f898d1d 100644 --- a/examples/graphicsview/anchorlayout/main.cpp +++ b/examples/graphicsview/anchorlayout/main.cpp @@ -76,8 +76,8 @@ int main(int argc, char **argv) QGraphicsProxyWidget *c = createItem(minSize, prefSize, maxSize, "C"); QGraphicsProxyWidget *d = createItem(minSize, prefSize, maxSize, "D"); QGraphicsProxyWidget *e = createItem(minSize, prefSize, maxSize, "E"); - QGraphicsProxyWidget *f = createItem(QSizeF(30, 50), QSizeF(150, 50), maxSize, "F"); - QGraphicsProxyWidget *g = createItem(QSizeF(30, 50), QSizeF(30, 100), maxSize, "G"); + QGraphicsProxyWidget *f = createItem(QSizeF(30, 50), QSizeF(150, 50), maxSize, "F (overflow)"); + QGraphicsProxyWidget *g = createItem(QSizeF(30, 50), QSizeF(30, 100), maxSize, "G (overflow)"); QGraphicsAnchorLayout *l = new QGraphicsAnchorLayout; l->setSpacing(0); -- cgit v0.12 From 0e74cc3e1a05147a8ae9c1c4be7c9f836da1acf3 Mon Sep 17 00:00:00 2001 From: Rhys Weatherley Date: Mon, 16 Nov 2009 08:04:46 +1000 Subject: Make isSharing() reset to false when context no longer sharing The documentation for QGLContext::isSharing() indicates that the function returns true only when the context is sharing. However, previously the sharing flag would stay on if the context was created as sharing but is no longer sharing. Task-number: QTBUG-5578 Reviewed-by: Sarah Smith --- src/opengl/qgl.cpp | 2 +- src/opengl/qgl_p.h | 1 + tests/auto/qgl/tst_qgl.cpp | 5 +++++ 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/opengl/qgl.cpp b/src/opengl/qgl.cpp index 8063fc8..f8a2ea4 100644 --- a/src/opengl/qgl.cpp +++ b/src/opengl/qgl.cpp @@ -3030,7 +3030,7 @@ void QGLContext::setValid(bool valid) bool QGLContext::isSharing() const { Q_D(const QGLContext); - return d->sharing; + return d->group->isSharing(); } QGLFormat QGLContext::format() const diff --git a/src/opengl/qgl_p.h b/src/opengl/qgl_p.h index 9a17c67..45b2942 100644 --- a/src/opengl/qgl_p.h +++ b/src/opengl/qgl_p.h @@ -233,6 +233,7 @@ public: QGLExtensionFuncs &extensionFuncs() {return m_extensionFuncs;} const QGLContext *context() const {return m_context;} + bool isSharing() const { return m_shares.size() >= 2; } void addGuard(QGLSharedResourceGuard *guard); void removeGuard(QGLSharedResourceGuard *guard); diff --git a/tests/auto/qgl/tst_qgl.cpp b/tests/auto/qgl/tst_qgl.cpp index ccb08c3..5dc072d 100644 --- a/tests/auto/qgl/tst_qgl.cpp +++ b/tests/auto/qgl/tst_qgl.cpp @@ -1842,6 +1842,7 @@ void tst_QGL::shareRegister() QVERIFY(qt_shared_test()->value(glw1->context()) == res1); // Create another context that shares with the first. + QVERIFY(!glw1->isSharing()); QGLWidget *glw2 = new QGLWidget(0, glw1); if (!glw2->isSharing()) { delete glw2; @@ -1880,6 +1881,7 @@ void tst_QGL::shareRegister() // Create a third context, not sharing with the others. QGLWidget *glw3 = new QGLWidget(); + QVERIFY(!glw3->isSharing()); // Create a guard on the standalone context. QGLSharedResourceGuard guard3(glw3->context()); @@ -1928,6 +1930,9 @@ void tst_QGL::shareRegister() // Delete the first context. delete glw1; + // The second context should no longer register as sharing. + QVERIFY(!glw2->isSharing()); + // The first context's resource should transfer to the second context. QCOMPARE(tst_QGLResource::deletions, 0); QVERIFY(qt_shared_test()->value(glw2->context()) == res1); -- cgit v0.12 From b2d5f886b36b4f4d317024db7cfd6668e2895cd4 Mon Sep 17 00:00:00 2001 From: Rhys Weatherley Date: Mon, 16 Nov 2009 08:38:59 +1000 Subject: Make pbuffers example compile under OpenGL/ES 1.1 Reviewed-by: Sarah Smith --- examples/opengl/pbuffers/glwidget.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/examples/opengl/pbuffers/glwidget.cpp b/examples/opengl/pbuffers/glwidget.cpp index 56ba65b..d843a73 100644 --- a/examples/opengl/pbuffers/glwidget.cpp +++ b/examples/opengl/pbuffers/glwidget.cpp @@ -175,7 +175,11 @@ void GLWidget::perspectiveProjection() { glMatrixMode(GL_PROJECTION); glLoadIdentity(); +#ifdef QT_OPENGL_ES + glFrustumf(-aspect, +aspect, -1.0, +1.0, 4.0, 15.0); +#else glFrustum(-aspect, +aspect, -1.0, +1.0, 4.0, 15.0); +#endif glMatrixMode(GL_MODELVIEW); } @@ -183,7 +187,11 @@ void GLWidget::orthographicProjection() { glMatrixMode(GL_PROJECTION); glLoadIdentity(); +#ifdef QT_OPENGL_ES + glOrthof(-1.0, +1.0, -1.0, +1.0, -90.0, +90.0); +#else glOrtho(-1.0, +1.0, -1.0, +1.0, -90.0, +90.0); +#endif glMatrixMode(GL_MODELVIEW); } -- cgit v0.12 From e3b0faf03a2db5b0e38d97ceda09024ec8daf458 Mon Sep 17 00:00:00 2001 From: Rhys Weatherley Date: Mon, 16 Nov 2009 09:38:10 +1000 Subject: Fix context sharing in QGLPixelBuffer for EGL Reviewed-by: Sarah Smith --- src/opengl/qglpixelbuffer_egl.cpp | 65 +++++++++++++++++++++++---------------- 1 file changed, 39 insertions(+), 26 deletions(-) diff --git a/src/opengl/qglpixelbuffer_egl.cpp b/src/opengl/qglpixelbuffer_egl.cpp index 744fbd4..de08655 100644 --- a/src/opengl/qglpixelbuffer_egl.cpp +++ b/src/opengl/qglpixelbuffer_egl.cpp @@ -72,37 +72,53 @@ bool QGLPixelBufferPrivate::init(const QSize &size, const QGLFormat &f, QGLWidge return false; } + // Find the shared context. + QEglContext *shareContext = 0; + if (shareWidget && shareWidget->d_func()->glcx) + shareContext = shareWidget->d_func()->glcx->d_func()->eglContext; + // Choose an appropriate configuration. We use the best format // we can find, even if it is greater than the requested format. // We try for a pbuffer that is capable of texture rendering if possible. - QEglProperties configProps; - qt_egl_set_format(configProps, QInternal::Pbuffer, f); - configProps.setRenderableType(ctx->api()); - bool ok = false; + textureFormat = EGL_NONE; + if (shareContext) { + // Use the same configuration as the widget we are sharing with. + ctx->setConfig(shareContext->config()); +#if QGL_RENDER_TEXTURE + EGLint value = EGL_FALSE; + if (ctx->configAttrib(EGL_BIND_TO_TEXTURE_RGBA, &value) && value) + textureFormat = EGL_TEXTURE_RGBA; + else if (ctx->configAttrib(EGL_BIND_TO_TEXTURE_RGB, &value) && value) + textureFormat = EGL_TEXTURE_RGB; +#endif + } else { + QEglProperties configProps; + qt_egl_set_format(configProps, QInternal::Pbuffer, f); + configProps.setRenderableType(ctx->api()); + bool ok = false; #if QGL_RENDER_TEXTURE - textureFormat = EGL_TEXTURE_RGBA; - configProps.setValue(EGL_BIND_TO_TEXTURE_RGBA, EGL_TRUE); - ok = ctx->chooseConfig(configProps, QEgl::BestPixelFormat); - if (!ok) { - // Try again with RGB texture rendering. - textureFormat = EGL_TEXTURE_RGB; - configProps.removeValue(EGL_BIND_TO_TEXTURE_RGBA); - configProps.setValue(EGL_BIND_TO_TEXTURE_RGB, EGL_TRUE); + textureFormat = EGL_TEXTURE_RGBA; + configProps.setValue(EGL_BIND_TO_TEXTURE_RGBA, EGL_TRUE); ok = ctx->chooseConfig(configProps, QEgl::BestPixelFormat); if (!ok) { - // One last try for a pbuffer with no texture rendering. - configProps.removeValue(EGL_BIND_TO_TEXTURE_RGB); - textureFormat = EGL_NONE; + // Try again with RGB texture rendering. + textureFormat = EGL_TEXTURE_RGB; + configProps.removeValue(EGL_BIND_TO_TEXTURE_RGBA); + configProps.setValue(EGL_BIND_TO_TEXTURE_RGB, EGL_TRUE); + ok = ctx->chooseConfig(configProps, QEgl::BestPixelFormat); + if (!ok) { + // One last try for a pbuffer with no texture rendering. + configProps.removeValue(EGL_BIND_TO_TEXTURE_RGB); + textureFormat = EGL_NONE; + } } - } -#else - textureFormat = EGL_NONE; #endif - if (!ok) { - if (!ctx->chooseConfig(configProps, QEgl::BestPixelFormat)) { - delete ctx; - ctx = 0; - return false; + if (!ok) { + if (!ctx->chooseConfig(configProps, QEgl::BestPixelFormat)) { + delete ctx; + ctx = 0; + return false; + } } } @@ -137,9 +153,6 @@ bool QGLPixelBufferPrivate::init(const QSize &size, const QGLFormat &f, QGLWidge } // Create a new context for the configuration. - QEglContext *shareContext = 0; - if (shareWidget && shareWidget->d_func()->glcx) - shareContext = shareWidget->d_func()->glcx->d_func()->eglContext; if (!ctx->createContext(shareContext)) { delete ctx; ctx = 0; -- cgit v0.12 From cc6befac3780a34eefb4e02e2a4fd6266d454242 Mon Sep 17 00:00:00 2001 From: Martin Jones Date: Mon, 16 Nov 2009 16:33:51 +1000 Subject: Install Qt declarative (if available) and QmlPatterns on S60 Reviewed-by: Warwick Allison --- src/s60installs/qt.iby | 2 ++ src/s60installs/s60installs.pro | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/src/s60installs/qt.iby b/src/s60installs/qt.iby index bc69dce..41eb562 100644 --- a/src/s60installs/qt.iby +++ b/src/s60installs/qt.iby @@ -57,6 +57,8 @@ file=ABI_DIR\BUILD_DIR\QtTest.dll SHARED_LIB_DIR\QtTest.dll PAG file=ABI_DIR\BUILD_DIR\QtWebKit.dll SHARED_LIB_DIR\QtWebKit.dll PAGED file=ABI_DIR\BUILD_DIR\phonon.dll SHARED_LIB_DIR\phonon.dll PAGED file=ABI_DIR\BUILD_DIR\QtMultimedia.dll SHARED_LIB_DIR\QtMultimedia.dll PAGED +file=ABI_DIR\BUILD_DIR\QtXmlPatterns.dll SHARED_LIB_DIR\QtXmlPatterns.dll PAGED +file=ABI_DIR\BUILD_DIR\QtDeclarative.dll SHARED_LIB_DIR\QtDeclarative.dll PAGED // imageformats file=ABI_DIR\BUILD_DIR\qgif.dll SHARED_LIB_DIR\qgif.dll PAGED diff --git a/src/s60installs/s60installs.pro b/src/s60installs/s60installs.pro index 90c9f27..2d9c489 100644 --- a/src/s60installs/s60installs.pro +++ b/src/s60installs/s60installs.pro @@ -101,6 +101,10 @@ symbian: { qtlibraries.sources += QtXmlPatterns.dll } + contains(QT_CONFIG, declarative): { + qtlibraries.sources += QtDeclarative.dll + } + contains(QT_CONFIG, webkit): { qtlibraries.sources += QtWebKit.dll } -- cgit v0.12 From b84208e523354abf68904d0d494ab41015b19408 Mon Sep 17 00:00:00 2001 From: stefan thomasson Date: Mon, 16 Nov 2009 17:21:13 +1000 Subject: Fixed false positives in bic autotest Adding QRegion::QRegionData, tagMENUITEMINFOA, tagMENUITEMINFOW, tagENHMETAHEADER to the class blacklist Merge-request: 2085 Reviewed-by: Rohan McGovern --- tests/auto/bic/tst_bic.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/auto/bic/tst_bic.cpp b/tests/auto/bic/tst_bic.cpp index 8c6056e..b7c79cf 100644 --- a/tests/auto/bic/tst_bic.cpp +++ b/tests/auto/bic/tst_bic.cpp @@ -96,6 +96,9 @@ tst_Bic::tst_Bic() /* QtOpenGL includes qt_windows.h, and some SDKs dont have these structs present */ bic.addBlacklistedClass(QLatin1String("tagTITLEBARINFO")); + bic.addBlacklistedClass(QLatin1String("tagMENUITEMINFOA")); + bic.addBlacklistedClass(QLatin1String("tagMENUITEMINFOW")); + bic.addBlacklistedClass(QLatin1String("tagENHMETAHEADER")); /* some bug in gcc also reported template instanciations */ bic.addBlacklistedClass(QLatin1String("QTypeInfo<*>")); @@ -115,6 +118,7 @@ tst_Bic::tst_Bic() bic.addBlacklistedClass(QLatin1String("QObjectData")); bic.addBlacklistedClass(QLatin1String("QAtomic")); bic.addBlacklistedClass(QLatin1String("QBasicAtomic")); + bic.addBlacklistedClass(QLatin1String("QRegion::QRegionData")); /* Jambi-related classes in Designer */ bic.addBlacklistedClass(QLatin1String("QDesignerLanguageExtension")); -- cgit v0.12 From 15384f3017978a3d552077c8400b018efcfd793c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sami=20Meril=C3=A4?= Date: Mon, 16 Nov 2009 10:26:33 +0200 Subject: Define own palette for web-based widgets in QS60Style It makes no sense to use the S60-theme based palette in web based widgets. Web pages do not generally show theme background, but their own (or by default white) which clashes badly with WindowText and Text that are set to work with theme background. Therefore, QWebView and QGraphicsWebView need to be set their own palette for texts in theme palette hash. This improves visibility of text in webkit when QS60Style is active. Task-number: QTBUG-4885 Reviewed-by: Janne Koskinen --- src/gui/styles/qs60style.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/gui/styles/qs60style.cpp b/src/gui/styles/qs60style.cpp index 939ea45..7c3e11f 100644 --- a/src/gui/styles/qs60style.cpp +++ b/src/gui/styles/qs60style.cpp @@ -783,6 +783,14 @@ void QS60StylePrivate::setThemePaletteHash(QPalette *palette) const widgetPalette.setBrush(QPalette::Window, QBrush()); QApplication::setPalette(widgetPalette, "QScrollArea"); widgetPalette = *palette; + + //Webpages should not use S60 theme colors as they are designed to work + //with themeBackground and do not generally mesh well with web page backgrounds. + QPalette webPalette = *palette; + webPalette.setColor(QPalette::WindowText, Qt::black); + webPalette.setColor(QPalette::Text, Qt::black); + QApplication::setPalette(webPalette, "QWebView"); + QApplication::setPalette(webPalette, "QGraphicsWebView"); } QSize QS60StylePrivate::partSize(QS60StyleEnums::SkinParts part, SkinElementFlags flags) @@ -2007,7 +2015,7 @@ void QS60Style::drawPrimitive(PrimitiveElement element, const QStyleOption *opti buttonRect.adjust(0,-newY,0,-newY); painter->save(); - QColor themeColor = d->s60Color(QS60StyleEnums::CL_QsnIconColors, 13, option); + QColor themeColor = d->s60Color(QS60StyleEnums::CL_QsnTextColors, 6, option); QColor buttonTextColor = option->palette.buttonText().color(); if (themeColor != buttonTextColor) painter->setPen(buttonTextColor); -- cgit v0.12 From 2b60b542a5f51cb983e4ad99c5fdf4e962b59b89 Mon Sep 17 00:00:00 2001 From: axis Date: Wed, 11 Nov 2009 13:54:27 +0100 Subject: Made widgets not clear their contents after losing edit focus. This is a behavior change from Qt 4.5. The motivation for the change is the following use case: A user types into a line or text edit, and gets interrupted by for example phone call or an SMS. This causes the active application to lose focus, which again causes edit focus to be lost. When resuming the application the focus gets set back, but the edit focus does not (nor should it). However, when the user types the next character, the line edit will erase *all* contents of the widget because it did not have edit focus. This is extremely destructive for a mobile phone user, especially since undo is not easily available. Another reason for doing that fix is that it seems that this is the mode of operation that most existing phones use. The fix is enabled for Symbian only at the moment, but will be followed by a patch for all platforms which will go into 4.7. Task: QTBUG-5698 RevBy: Jason Barron --- src/gui/widgets/qlineedit.cpp | 4 ++++ src/gui/widgets/qtextedit.cpp | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/src/gui/widgets/qlineedit.cpp b/src/gui/widgets/qlineedit.cpp index f5dbe1c..9372ddd 100644 --- a/src/gui/widgets/qlineedit.cpp +++ b/src/gui/widgets/qlineedit.cpp @@ -1594,7 +1594,9 @@ void QLineEdit::keyPressEvent(QKeyEvent *event) && !isReadOnly()) { setEditFocus(true); +#ifndef Q_OS_SYMBIAN clear(); +#endif } else { event->ignore(); return; @@ -1651,7 +1653,9 @@ void QLineEdit::inputMethodEvent(QInputMethodEvent *e) && hasFocus() && !hasEditFocus() && !e->preeditString().isEmpty()) { setEditFocus(true); +#ifndef Q_OS_SYMBIAN selectAll(); // so text is replaced rather than appended to +#endif } #endif diff --git a/src/gui/widgets/qtextedit.cpp b/src/gui/widgets/qtextedit.cpp index 88502e3..14de719 100644 --- a/src/gui/widgets/qtextedit.cpp +++ b/src/gui/widgets/qtextedit.cpp @@ -1210,7 +1210,9 @@ void QTextEdit::keyPressEvent(QKeyEvent *e) if (!hasEditFocus() && !(e->modifiers() & Qt::ControlModifier)) { if (e->text()[0].isPrint()) { setEditFocus(true); +#ifndef Q_OS_SYMBIAN clear(); +#endif } else { e->ignore(); return; @@ -1672,7 +1674,9 @@ void QTextEdit::inputMethodEvent(QInputMethodEvent *e) && QApplication::keypadNavigationEnabled() && !hasEditFocus()) { setEditFocus(true); +#ifndef Q_OS_SYMBIAN selectAll(); // so text is replaced rather than appended to +#endif } #endif d->sendControlEvent(e); -- cgit v0.12 From dbaea6fa5a90742d89691685baa44a1a34598f21 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Trond=20Kjern=C3=A5sen?= Date: Mon, 16 Nov 2009 10:42:35 +0100 Subject: Fixed a crash in QPixmap::fromImage() when passing in a null image. Task-number: QTBUG-5840 Reviewed-by: Kim --- src/gui/image/qpixmap_x11.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/gui/image/qpixmap_x11.cpp b/src/gui/image/qpixmap_x11.cpp index 3f297df..7008fbd 100644 --- a/src/gui/image/qpixmap_x11.cpp +++ b/src/gui/image/qpixmap_x11.cpp @@ -416,6 +416,11 @@ void QX11PixmapData::fromImage(const QImage &img, d = img.depth(); is_null = (w <= 0 || h <= 0); + if (is_null) { + w = h = 0; + return; + } + if (defaultScreen >= 0 && defaultScreen != xinfo.screen()) { QX11InfoData* xd = xinfo.getX11Data(true); xd->screen = defaultScreen; -- cgit v0.12 From 7e1f19c3e3036f166a84dbaa916ec1da1cc818c6 Mon Sep 17 00:00:00 2001 From: Thomas Zander Date: Mon, 16 Nov 2009 11:16:47 +0100 Subject: Fix regression in emitting of QTextDocument::undoCommandAdded() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The test I wrote was not testing if calling undo/redo had any effect on emitting undoCommandAdded(), added these test cases and fixed the QTextDocumentPrivate::endEditBlock so we now again emit only when an undo command is added, not also on calling undo or redo. Reviewed-by: mae Reviewed-by: Samuel Rødal --- src/gui/text/qtextdocument_p.cpp | 4 +++- tests/auto/qtextdocument/tst_qtextdocument.cpp | 11 +++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/gui/text/qtextdocument_p.cpp b/src/gui/text/qtextdocument_p.cpp index 2ad6512..18e1ffc 100644 --- a/src/gui/text/qtextdocument_p.cpp +++ b/src/gui/text/qtextdocument_p.cpp @@ -1114,9 +1114,11 @@ void QTextDocumentPrivate::endEditBlock() return; if (undoEnabled && undoState > 0) { + const bool wasBlocking = !undoStack[undoState - 1].block_end; if (undoStack[undoState - 1].block_part) { undoStack[undoState - 1].block_end = true; - emit document()->undoCommandAdded(); + if (wasBlocking) + emit document()->undoCommandAdded(); } } diff --git a/tests/auto/qtextdocument/tst_qtextdocument.cpp b/tests/auto/qtextdocument/tst_qtextdocument.cpp index 1d54409..11e32b0 100644 --- a/tests/auto/qtextdocument/tst_qtextdocument.cpp +++ b/tests/auto/qtextdocument/tst_qtextdocument.cpp @@ -2615,6 +2615,17 @@ void tst_QTextDocument::testUndoCommandAdded() cf.setFontItalic(true); cursor.mergeCharFormat(cf); QCOMPARE(spy.count(), 1); + + spy.clear(); + doc->undo(); + QCOMPARE(spy.count(), 0); + doc->undo(); + QCOMPARE(spy.count(), 0); + spy.clear(); + doc->redo(); + QCOMPARE(spy.count(), 0); + doc->redo(); + QCOMPARE(spy.count(), 0); } void tst_QTextDocument::testUndoBlocks() -- cgit v0.12