From 182efb3d2c5182a89d7416f474811309d7939786 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Morten=20Johan=20S=C3=B8rvig?= Date: Fri, 20 Nov 2009 13:28:34 +0100 Subject: Doc: Document QSystemTrayIcon::showMessage() Mac behavior. Document that that QSystemTrayIcon::showMessage requires Growl. --- src/gui/util/qsystemtrayicon.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/gui/util/qsystemtrayicon.cpp b/src/gui/util/qsystemtrayicon.cpp index c6ea00f..6f2b501 100644 --- a/src/gui/util/qsystemtrayicon.cpp +++ b/src/gui/util/qsystemtrayicon.cpp @@ -380,6 +380,9 @@ bool QSystemTrayIcon::supportsMessages() On Windows, the \a millisecondsTimeoutHint is usually ignored by the system when the application has focus. + On Mac OS X, the Growl notification system must be installed for this function to + display messages. + \sa show() supportsMessages() */ void QSystemTrayIcon::showMessage(const QString& title, const QString& msg, -- cgit v0.12 From cfe40854c0c6731317ec73a55d222d73b6bd613e Mon Sep 17 00:00:00 2001 From: ninerider Date: Mon, 23 Nov 2009 15:03:42 +0100 Subject: Compilation fix for Windows Mobile The default style (plastique) used was not available if not included in the build. Using now the windows style instead. Reviewed-by: Maurice --- tests/auto/qgraphicslinearlayout/tst_qgraphicslinearlayout.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/auto/qgraphicslinearlayout/tst_qgraphicslinearlayout.cpp b/tests/auto/qgraphicslinearlayout/tst_qgraphicslinearlayout.cpp index d3087dc..ab110e6 100644 --- a/tests/auto/qgraphicslinearlayout/tst_qgraphicslinearlayout.cpp +++ b/tests/auto/qgraphicslinearlayout/tst_qgraphicslinearlayout.cpp @@ -146,7 +146,7 @@ void tst_QGraphicsLinearLayout::initTestCase() { // since the style will influence the results, we have to ensure // that the tests are run using the same style on all platforms -#ifdef Q_WS_S60 +#if defined( Q_WS_S60 )|| defined (Q_WS_WINCE) QApplication::setStyle(new QWindowsStyle); #else QApplication::setStyle(new QPlastiqueStyle); -- cgit v0.12 From 2ef40cee608ddc57a5bfc4ceb91c149b526fe53a Mon Sep 17 00:00:00 2001 From: "Eduardo M. Fleury" Date: Wed, 25 Nov 2009 13:27:36 -0300 Subject: QGAL: default spacing can be unset using a negative value After a default spacing is set through QGAL::setSpacing() family of methods, the user must be able to unset it. To avoid adding another public method, we enabled this feature by allowing a negative value to be passed to those methods. Signed-off-by: Eduardo M. Fleury Reviewed-by: Anselmo Lacerda S. de Melo --- src/gui/graphicsview/qgraphicsanchorlayout.cpp | 23 ++---------- .../tst_qgraphicsanchorlayout.cpp | 41 ++++++++++++++++++++++ 2 files changed, 43 insertions(+), 21 deletions(-) diff --git a/src/gui/graphicsview/qgraphicsanchorlayout.cpp b/src/gui/graphicsview/qgraphicsanchorlayout.cpp index 7e5929e..686096c 100644 --- a/src/gui/graphicsview/qgraphicsanchorlayout.cpp +++ b/src/gui/graphicsview/qgraphicsanchorlayout.cpp @@ -370,12 +370,6 @@ void QGraphicsAnchorLayout::setHorizontalSpacing(qreal spacing) { Q_D(QGraphicsAnchorLayout); - // ### We don't support negative spacing yet - if (spacing < 0) { - spacing = 0; - qWarning() << "QGraphicsAnchorLayout does not support negative spacing."; - } - d->spacings[0] = spacing; invalidate(); } @@ -389,12 +383,6 @@ void QGraphicsAnchorLayout::setVerticalSpacing(qreal spacing) { Q_D(QGraphicsAnchorLayout); - // ### We don't support negative spacing yet - if (spacing < 0) { - spacing = 0; - qWarning() << "QGraphicsAnchorLayout does not support negative spacing."; - } - d->spacings[1] = spacing; invalidate(); } @@ -405,7 +393,8 @@ void QGraphicsAnchorLayout::setVerticalSpacing(qreal spacing) If an item is anchored with no spacing associated with the anchor, it will use the default spacing. - Currently QGraphicsAnchorLayout does not support negative default spacings. + QGraphicsAnchorLayout does not support negative spacings. Setting a negative value will unset the + previous spacing and make the layout use the spacing provided by the current widget style. \sa setHorizontalSpacing(), setVerticalSpacing() */ @@ -413,14 +402,6 @@ void QGraphicsAnchorLayout::setSpacing(qreal spacing) { Q_D(QGraphicsAnchorLayout); - // ### Currently we do not support negative anchors inside the graph. - // To avoid those being created by a negative spacing, we must - // make this test. - if (spacing < 0) { - spacing = 0; - qWarning() << "QGraphicsAnchorLayout does not support negative spacing."; - } - d->spacings[0] = d->spacings[1] = spacing; invalidate(); } diff --git a/tests/auto/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp b/tests/auto/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp index e2f87b8..aa67ac5 100644 --- a/tests/auto/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp +++ b/tests/auto/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp @@ -88,6 +88,7 @@ private slots: void spacingPersistency(); void snakeParallelWithLayout(); void parallelToHalfLayout(); + void globalSpacing(); }; class RectWidget : public QGraphicsWidget @@ -1976,5 +1977,45 @@ void tst_QGraphicsAnchorLayout::parallelToHalfLayout() QCOMPARE(maximumSizeHint, QSizeF(400, 100) + overhead); } +void tst_QGraphicsAnchorLayout::globalSpacing() +{ + QGraphicsWidget *a = createItem(); + QGraphicsWidget *b = createItem(); + + QGraphicsWidget w; + QGraphicsAnchorLayout *l = new QGraphicsAnchorLayout(&w); + + l->addCornerAnchors(l, Qt::TopLeftCorner, a, Qt::TopLeftCorner); + l->addCornerAnchors(a, Qt::BottomRightCorner, b, Qt::TopLeftCorner); + l->addCornerAnchors(b, Qt::BottomRightCorner, l, Qt::BottomRightCorner); + + w.resize(w.effectiveSizeHint(Qt::PreferredSize)); + qreal vSpacing = b->geometry().top() - a->geometry().bottom(); + qreal hSpacing = b->geometry().left() - a->geometry().right(); + + // Set spacings manually + l->setVerticalSpacing(vSpacing + 10); + l->setHorizontalSpacing(hSpacing + 5); + + w.resize(w.effectiveSizeHint(Qt::PreferredSize)); + qreal newVSpacing = b->geometry().top() - a->geometry().bottom(); + qreal newHSpacing = b->geometry().left() - a->geometry().right(); + + QCOMPARE(newVSpacing, vSpacing + 10); + QCOMPARE(newHSpacing, hSpacing + 5); + + // Set a negative spacing. This will unset the previous spacing and + // bring back the widget-defined spacing. + l->setSpacing(-1); + + w.resize(w.effectiveSizeHint(Qt::PreferredSize)); + newVSpacing = b->geometry().top() - a->geometry().bottom(); + newHSpacing = b->geometry().left() - a->geometry().right(); + + QCOMPARE(newVSpacing, vSpacing); + QCOMPARE(newHSpacing, hSpacing); +} + + QTEST_MAIN(tst_QGraphicsAnchorLayout) #include "tst_qgraphicsanchorlayout.moc" -- cgit v0.12 From a8893f8d17d37ac4a68fc2cf0bdec1c3b124c8f4 Mon Sep 17 00:00:00 2001 From: "Eduardo M. Fleury" Date: Fri, 27 Nov 2009 14:52:21 -0300 Subject: QGAL (Test): Add QGraphicsAnchor handling test This test ensures that internal anchors are not exposed through the QGAL::anchor() API and also that the QGraphicsAnchors are deleted when the associated anchors are deleted internally. Signed-off-by: Eduardo M. Fleury Reviewed-by: Artur Duque de Souza --- .../tst_qgraphicsanchorlayout.cpp | 37 ++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/tests/auto/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp b/tests/auto/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp index aa67ac5..a7297c9 100644 --- a/tests/auto/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp +++ b/tests/auto/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp @@ -89,6 +89,7 @@ private slots: void snakeParallelWithLayout(); void parallelToHalfLayout(); void globalSpacing(); + void graphicsAnchorHandling(); }; class RectWidget : public QGraphicsWidget @@ -2016,6 +2017,42 @@ void tst_QGraphicsAnchorLayout::globalSpacing() QCOMPARE(newHSpacing, hSpacing); } +void tst_QGraphicsAnchorLayout::graphicsAnchorHandling() +{ + QGraphicsAnchorLayout *l = new QGraphicsAnchorLayout(); + QGraphicsWidget *a = createItem(); + + l->addAnchors(l, a); + + QGraphicsAnchor *layoutAnchor = l->anchor(l, Qt::AnchorTop, l, Qt::AnchorBottom); + QGraphicsAnchor *itemAnchor = l->anchor(a, Qt::AnchorTop, a, Qt::AnchorBottom); + QGraphicsAnchor *invalidAnchor = l->anchor(a, Qt::AnchorTop, l, Qt::AnchorBottom); + + // Ensure none of these anchors are accessible. + QVERIFY(layoutAnchor == 0); + QVERIFY(itemAnchor == 0); + QVERIFY(invalidAnchor == 0); + + // Hook the anchors to a QObject + QObject object; + QGraphicsAnchor *userAnchor = l->anchor(l, Qt::AnchorTop, a, Qt::AnchorTop); + userAnchor->setParent(&object); + userAnchor = l->anchor(l, Qt::AnchorBottom, a, Qt::AnchorBottom); + userAnchor->setParent(&object); + userAnchor = l->anchor(l, Qt::AnchorRight, a, Qt::AnchorRight); + userAnchor->setParent(&object); + userAnchor = l->anchor(l, Qt::AnchorLeft, a, Qt::AnchorLeft); + userAnchor->setParent(&object); + + QCOMPARE(object.children().size(), 4); + + // Delete layout, this will cause all anchors to be deleted internally. + // We expect the public QGraphicsAnchor instances to be deleted too. + delete l; + QCOMPARE(object.children().size(), 0); + + delete a; +} QTEST_MAIN(tst_QGraphicsAnchorLayout) #include "tst_qgraphicsanchorlayout.moc" -- cgit v0.12 From 5b9d7f05aa369c07c2f498280d8a8b9c81f7aff1 Mon Sep 17 00:00:00 2001 From: "Eduardo M. Fleury" Date: Fri, 27 Nov 2009 11:14:23 -0300 Subject: QGAL: Prevent internal anchors from being exposed by QGAL::anchor() Adding check to prevent the structural layout anchors as well as those internal to items, from being exposed through the public API. These checks also ensure no QGraphicsAnchor instances will be created for those anchors. Signed-off-by: Eduardo M. Fleury Reviewed-by: Artur Duque de Souza --- src/gui/graphicsview/qgraphicsanchorlayout_p.cpp | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/gui/graphicsview/qgraphicsanchorlayout_p.cpp b/src/gui/graphicsview/qgraphicsanchorlayout_p.cpp index a6f5992..137806a 100644 --- a/src/gui/graphicsview/qgraphicsanchorlayout_p.cpp +++ b/src/gui/graphicsview/qgraphicsanchorlayout_p.cpp @@ -1652,6 +1652,10 @@ QGraphicsAnchor *QGraphicsAnchorLayoutPrivate::getAnchor(QGraphicsLayoutItem *fi QGraphicsLayoutItem *secondItem, Qt::AnchorPoint secondEdge) { + // Do not expose internal anchors + if (firstItem == secondItem) + return 0; + const Orientation orientation = edgeOrientation(firstEdge); AnchorVertex *v1 = internalVertex(firstItem, firstEdge); AnchorVertex *v2 = internalVertex(secondItem, secondEdge); @@ -1659,8 +1663,16 @@ QGraphicsAnchor *QGraphicsAnchorLayoutPrivate::getAnchor(QGraphicsLayoutItem *fi QGraphicsAnchor *graphicsAnchor = 0; AnchorData *data = graph[orientation].edgeData(v1, v2); - if (data) - graphicsAnchor = acquireGraphicsAnchor(data); + if (data) { + // We could use "acquireGraphicsAnchor" here, but to avoid a regression where + // an internal anchor was wrongly exposed, I want to ensure no new + // QGraphicsAnchor instances are created by this call. + // This assumption must hold because anchors are either user-created (and already + // have their public object created), or they are internal (and must not reach + // this point). + Q_ASSERT(data->graphicsAnchor); + graphicsAnchor = data->graphicsAnchor; + } return graphicsAnchor; } -- cgit v0.12 From b70256432c2393afb5686c9ef61e38ff399be954 Mon Sep 17 00:00:00 2001 From: "Eduardo M. Fleury" Date: Fri, 27 Nov 2009 15:38:48 -0300 Subject: QGAL: Fix memory management issues (leak + invalid read) Fixing QGraphicsAnchor memory leak and access to free'd region. -- Leak: User-created anchors have two representations in QGAL, one visible externally (QGraphicsAnchor) and other internal (AnchorData). When such anchors are removed externally (QGraphicsAnchor is deleted), the former implementation ensured that the internal representation would be deleted too. However the opposite was not true. In cases where the anchors are deleted internally (in the layout destructor, for instance, or when an item is removed through the removeAt API), the public QGraphicsAnchor object would leak. This commit ensures the deletion will happen in both directions and adds protection to avoid a deletion loop. -- Invalid read: In QGAL::removeAnchor(vertex1, vertex2), we read vertex information after calling removeAnchor_helper(vertex1, vertex2). The problem is that in cases where the removed anchor is the last anchor to connect to a center vertex, its removal will cause also the removal of such vertex. Thus, accessing the vertices after the removeAnchor_helper() call is unsafe. To solve that we cache the information we need and then clear the vertex pointers to avoid errors in the future. Signed-off-by: Eduardo M. Fleury Reviewed-by: Artur Duque de Souza --- src/gui/graphicsview/qgraphicsanchorlayout_p.cpp | 30 ++++++++++++++++++++---- src/gui/graphicsview/qgraphicsanchorlayout_p.h | 3 +-- 2 files changed, 27 insertions(+), 6 deletions(-) diff --git a/src/gui/graphicsview/qgraphicsanchorlayout_p.cpp b/src/gui/graphicsview/qgraphicsanchorlayout_p.cpp index 137806a..b698c02 100644 --- a/src/gui/graphicsview/qgraphicsanchorlayout_p.cpp +++ b/src/gui/graphicsview/qgraphicsanchorlayout_p.cpp @@ -62,7 +62,13 @@ QGraphicsAnchorPrivate::QGraphicsAnchorPrivate(int version) QGraphicsAnchorPrivate::~QGraphicsAnchorPrivate() { - layoutPrivate->removeAnchor(data->from, data->to); + if (data) { + // The QGraphicsAnchor was already deleted at this moment. We must clean + // the dangling pointer to avoid double deletion in the AnchorData dtor. + data->graphicsAnchor = 0; + + layoutPrivate->removeAnchor(data->from, data->to); + } } void QGraphicsAnchorPrivate::setSizePolicy(QSizePolicy::Policy policy) @@ -167,6 +173,18 @@ static void internalSizeHints(QSizePolicy::Policy policy, *prefSize = prefSizeHint; } +AnchorData::~AnchorData() +{ + if (graphicsAnchor) { + // Remove reference to ourself to avoid double removal in + // QGraphicsAnchorPrivate dtor. + graphicsAnchor->d_func()->data = 0; + + delete graphicsAnchor; + } +} + + void AnchorData::refreshSizeHints(const QLayoutStyleInfo *styleInfo) { QSizePolicy::Policy policy; @@ -1687,12 +1705,16 @@ void QGraphicsAnchorLayoutPrivate::removeAnchor(AnchorVertex *firstVertex, { Q_Q(QGraphicsAnchorLayout); - // Actually delete the anchor - removeAnchor_helper(firstVertex, secondVertex); - + // Save references to items while it's safe to assume the vertices exist QGraphicsLayoutItem *firstItem = firstVertex->m_item; QGraphicsLayoutItem *secondItem = secondVertex->m_item; + // Delete the anchor (may trigger deletion of center vertices) + removeAnchor_helper(firstVertex, secondVertex); + + // Ensure no dangling pointer is left behind + firstVertex = secondVertex = 0; + // Checking if the item stays in the layout or not bool keepFirstItem = false; bool keepSecondItem = false; diff --git a/src/gui/graphicsview/qgraphicsanchorlayout_p.h b/src/gui/graphicsview/qgraphicsanchorlayout_p.h index 8529e2e..e96110c 100644 --- a/src/gui/graphicsview/qgraphicsanchorlayout_p.h +++ b/src/gui/graphicsview/qgraphicsanchorlayout_p.h @@ -128,12 +128,11 @@ struct AnchorData : public QSimplexVariable { type(Normal), isLayoutAnchor(false), isCenterAnchor(false), orientation(0), dependency(Independent) {} + virtual ~AnchorData(); virtual void updateChildrenSizes() {} void refreshSizeHints(const QLayoutStyleInfo *styleInfo = 0); - virtual ~AnchorData() {} - #ifdef QT_DEBUG void dump(int indent = 2); inline QString toString() const; -- cgit v0.12 From 7a930ec85684a38212165aff29ed84d95bd43d32 Mon Sep 17 00:00:00 2001 From: "Eduardo M. Fleury" Date: Thu, 26 Nov 2009 20:13:35 -0300 Subject: QGAL (Test): Fix memory leaks in example and tests Some tests and the example were leaking memory what made it harder to investigate leaks on the layout itself. Those were simple errors like not deleting the layout at the end of the test and were corrected. Signed-off-by: Eduardo M. Fleury Reviewed-by: Artur Duque de Souza --- examples/graphicsview/anchorlayout/main.cpp | 4 +-- .../tst_qgraphicsanchorlayout.cpp | 19 ++++++++----- .../tst_qgraphicsanchorlayout1.cpp | 31 ++++++++++++++-------- 3 files changed, 34 insertions(+), 20 deletions(-) diff --git a/examples/graphicsview/anchorlayout/main.cpp b/examples/graphicsview/anchorlayout/main.cpp index f898d1d..389bc9e 100644 --- a/examples/graphicsview/anchorlayout/main.cpp +++ b/examples/graphicsview/anchorlayout/main.cpp @@ -122,8 +122,8 @@ int main(int argc, char **argv) scene.addItem(w); scene.setBackgroundBrush(Qt::darkGreen); - QGraphicsView *view = new QGraphicsView(&scene); - view->show(); + QGraphicsView view(&scene); + view.show(); return app.exec(); } diff --git a/tests/auto/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp b/tests/auto/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp index a7297c9..d566498 100644 --- a/tests/auto/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp +++ b/tests/auto/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp @@ -1197,7 +1197,7 @@ void tst_QGraphicsAnchorLayout::styleDefaults() QSizeF pref(20, 20); QSizeF max (50, 50); - /* + /* create this layout, where a,b have controlType QSizePolicy::RadioButton c,d have controlType QSizePolicy::PushButton: +-------+ @@ -1244,9 +1244,9 @@ void tst_QGraphicsAnchorLayout::styleDefaults() scene.addItem(window); window->show(); - QGraphicsView *view = new QGraphicsView(&scene); - view->resize(200, 200); - view->show(); + QGraphicsView view(&scene); + view.resize(200, 200); + view.show(); window->adjustSize(); QCOMPARE(a->geometry(), QRectF(0, 3, 20, 20)); //radio @@ -1265,10 +1265,13 @@ void tst_QGraphicsAnchorLayout::styleDefaults() window->setStyle(style); window->adjustSize(); QCOMPARE(a->geometry(), QRectF(0, 3, 20, 20)); - QCOMPARE(b->geometry(), QRectF(21, 25, 20, 20)); + QCOMPARE(b->geometry(), QRectF(21, 25, 20, 20)); QCOMPARE(c->geometry(), QRectF(42, 47, 20, 20)); QCOMPARE(d->geometry(), QRectF(63, 69, 20, 20)); QCOMPARE(l->geometry(), QRectF(0, 0, 89, 98)); + + window->setStyle(0); + delete style; } @@ -1777,7 +1780,8 @@ void tst_QGraphicsAnchorLayout::simplificationVsOrder() QGraphicsWidget *b = createItem(min, pref, max, "B"); QGraphicsWidget *c = createItem(min, pref, max, "C"); - QGraphicsAnchorLayout *l = new QGraphicsAnchorLayout; + QGraphicsWidget frame; + QGraphicsAnchorLayout *l = new QGraphicsAnchorLayout(&frame); // Bulk anchors l->addAnchor(l, Qt::AnchorLeft, a, Qt::AnchorLeft); @@ -1847,7 +1851,8 @@ void tst_QGraphicsAnchorLayout::simplificationVsRedundance() QGraphicsWidget *b = createItem(min, pref, max, "B"); QGraphicsWidget *c = createItem(min, pref, max, "C"); - QGraphicsAnchorLayout *l = new QGraphicsAnchorLayout; + QGraphicsWidget frame; + QGraphicsAnchorLayout *l = new QGraphicsAnchorLayout(&frame); l->addCornerAnchors(a, Qt::TopLeftCorner, l, Qt::TopLeftCorner); l->addCornerAnchors(a, Qt::BottomLeftCorner, l, Qt::BottomLeftCorner); diff --git a/tests/auto/qgraphicsanchorlayout1/tst_qgraphicsanchorlayout1.cpp b/tests/auto/qgraphicsanchorlayout1/tst_qgraphicsanchorlayout1.cpp index baa1ba1..57dc90d 100644 --- a/tests/auto/qgraphicsanchorlayout1/tst_qgraphicsanchorlayout1.cpp +++ b/tests/auto/qgraphicsanchorlayout1/tst_qgraphicsanchorlayout1.cpp @@ -356,6 +356,8 @@ void tst_QGraphicsAnchorLayout1::testItemAt() QVERIFY( layout->itemAt(0) == widget2 ); + delete widget1; + widget->setLayout(layout); delete widget; } @@ -460,6 +462,12 @@ void tst_QGraphicsAnchorLayout1::testAddAndRemoveAnchor() QCOMPARE( layout->count(), 0 ); + delete widget1; + delete widget2; + delete widget3; + delete widget4; + delete widget5; + widget->setLayout(layout); delete widget; } @@ -1740,9 +1748,9 @@ void tst_QGraphicsAnchorLayout1::testBasicLayout() QRectF actual = truncate(widgets[item.index]->geometry()); QCOMPARE(actual, expected); - delete widgets[item.index]; } + qDeleteAll(widgets); delete widget; } @@ -2231,8 +2239,9 @@ void tst_QGraphicsAnchorLayout1::testRemoveCenterAnchor() const BasicLayoutTestResult item = result[i]; QCOMPARE(widgets[item.index]->geometry(), item.rect); - delete widgets[item.index]; } + + qDeleteAll(widgets); delete widget; } @@ -2360,7 +2369,7 @@ void tst_QGraphicsAnchorLayout1::testSingleSizePolicy() QFETCH(bool, valid); // create objects - QGraphicsWidget *widget = new QGraphicsWidget; + QGraphicsWidget widget; TheAnchorLayout *layout = new TheAnchorLayout; TestWidget *childWidget = new TestWidget; @@ -2370,11 +2379,11 @@ void tst_QGraphicsAnchorLayout1::testSingleSizePolicy() layout->setAnchor( layout, Qt::AnchorTop, childWidget, Qt::AnchorTop, 10 ); layout->setAnchor( childWidget, Qt::AnchorBottom, layout, Qt::AnchorBottom, 10 ); - widget->setLayout( layout ); + widget.setLayout( layout ); // set test case specific: policy and size childWidget->setSizePolicy( policy ); - widget->setGeometry( QRectF( QPoint(0,0), size ) ); + widget.setGeometry( QRectF( QPoint(0,0), size ) ); QCOMPARE( layout->isValid() , valid ); @@ -2516,7 +2525,7 @@ void tst_QGraphicsAnchorLayout1::testDoubleSizePolicy() QFETCH(qreal, width2); // create objects - QGraphicsWidget *widget = new QGraphicsWidget; + QGraphicsWidget widget; TheAnchorLayout *layout = new TheAnchorLayout; TestWidget *childWidget1 = new TestWidget; TestWidget *childWidget2 = new TestWidget; @@ -2526,13 +2535,13 @@ void tst_QGraphicsAnchorLayout1::testDoubleSizePolicy() layout->setAnchor( childWidget1, Qt::AnchorRight, childWidget2, Qt::AnchorLeft, 10 ); layout->setAnchor( childWidget2, Qt::AnchorRight, layout, Qt::AnchorRight, 10 ); - widget->setLayout( layout ); + widget.setLayout( layout ); // set test case specific: policy childWidget1->setSizePolicy( policy1 ); childWidget2->setSizePolicy( policy2 ); - widget->setGeometry( QRectF( QPoint(0,0), QSize( 100,100 ) ) ); + widget.setGeometry( QRectF( QPoint(0,0), QSize( 100,100 ) ) ); // check results: if ( width1 == -1.0f ) { @@ -2649,7 +2658,7 @@ void tst_QGraphicsAnchorLayout1::testSizeDistribution() QFETCH(qreal, width2); // create objects - QGraphicsWidget *widget = new QGraphicsWidget; + QGraphicsWidget widget; TheAnchorLayout *layout = new TheAnchorLayout; TestWidget *childWidget1 = new TestWidget; TestWidget *childWidget2 = new TestWidget; @@ -2659,7 +2668,7 @@ void tst_QGraphicsAnchorLayout1::testSizeDistribution() layout->setAnchor( childWidget1, Qt::AnchorRight, childWidget2, Qt::AnchorLeft, 10 ); layout->setAnchor( childWidget2, Qt::AnchorRight, layout, Qt::AnchorRight, 10 ); - widget->setLayout( layout ); + widget.setLayout( layout ); // set test case specific: size hints childWidget1->setMinimumWidth( sizeHints1.value( Qt::MinimumSize ) ); @@ -2670,7 +2679,7 @@ void tst_QGraphicsAnchorLayout1::testSizeDistribution() childWidget2->setPreferredWidth( sizeHints2.value( Qt::PreferredSize ) ); childWidget2->setMaximumWidth( sizeHints2.value( Qt::MaximumSize ) ); - widget->setGeometry( QRectF( QPoint(0,0), QSize( 100,100 ) ) ); + widget.setGeometry( QRectF( QPoint(0,0), QSize( 100,100 ) ) ); // check results: if ( width1 == -1.0f ) { -- cgit v0.12 From a801b57a403548cccd081d8a0ae1f174d2201f9a Mon Sep 17 00:00:00 2001 From: "Eduardo M. Fleury" Date: Thu, 19 Nov 2009 17:07:02 -0300 Subject: QGAL: Rename internalSizeHints to applySizePolicy Former name did not reflect actual work done by the function. Signed-off-by: Eduardo M. Fleury Reviewed-by: Caio Marcelo de Oliveira Filho --- src/gui/graphicsview/qgraphicsanchorlayout_p.cpp | 25 ++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/src/gui/graphicsview/qgraphicsanchorlayout_p.cpp b/src/gui/graphicsview/qgraphicsanchorlayout_p.cpp index b698c02..d9f4e32 100644 --- a/src/gui/graphicsview/qgraphicsanchorlayout_p.cpp +++ b/src/gui/graphicsview/qgraphicsanchorlayout_p.cpp @@ -138,10 +138,10 @@ qreal QGraphicsAnchorPrivate::spacing() const } -static void internalSizeHints(QSizePolicy::Policy policy, - qreal minSizeHint, qreal prefSizeHint, qreal maxSizeHint, - qreal *minSize, qreal *prefSize, - qreal *maxSize) +static void applySizePolicy(QSizePolicy::Policy policy, + qreal minSizeHint, qreal prefSizeHint, qreal maxSizeHint, + qreal *minSize, qreal *prefSize, + qreal *maxSize) { // minSize, prefSize and maxSize are initialized // with item's preferred Size: this is QSizePolicy::Fixed. @@ -224,14 +224,18 @@ void AnchorData::refreshSizeHints(const QLayoutStyleInfo *styleInfo) // It is a user-created anchor, fetch size information from the associated QGraphicsAnchor Q_ASSERT(graphicsAnchor); QGraphicsAnchorPrivate *anchorPrivate = graphicsAnchor->d_func(); + + // Policy, min and max sizes are straightforward policy = anchorPrivate->sizePolicy; minSizeHint = 0; + maxSizeHint = QWIDGETSIZE_MAX; + + // Preferred Size 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. + // Anchor has user-defined size prefSizeHint = anchorPrivate->preferredSize; } else { + // Fetch size information from style const Qt::Orientation orient = Qt::Orientation(QGraphicsAnchorLayoutPrivate::edgeOrientation(from->m_edge) + 1); qreal s = styleInfo->defaultSpacing(orient); if (s < 0) { @@ -247,10 +251,11 @@ void AnchorData::refreshSizeHints(const QLayoutStyleInfo *styleInfo) } prefSizeHint = s; } - maxSizeHint = QWIDGETSIZE_MAX; } - internalSizeHints(policy, minSizeHint, prefSizeHint, maxSizeHint, - &minSize, &prefSize, &maxSize); + + // Fill minSize, prefSize and maxSize based on policy and sizeHints + applySizePolicy(policy, minSizeHint, prefSizeHint, maxSizeHint, + &minSize, &prefSize, &maxSize); // Set the anchor effective sizes to preferred. // -- cgit v0.12 From 2aa9303031d9d9f4b123034f4a7fd84f1d1270ba Mon Sep 17 00:00:00 2001 From: "Eduardo M. Fleury" Date: Tue, 27 Oct 2009 18:04:17 -0300 Subject: QGAL: Limit absolute size of anchors and add offset to calculation This commit is groundwork for the support of negative-sized anchors by the simplex solver. The idea is to add to all variables an offset large enough to ensure they are never negative. The implementation limits all variable sizes in the range [-limit, limit] and feed them into the simplex with an offset of "limit". Subtracting this offset later to find out the real values. "limit" is defined as QWIDGETSIZE_MAX for platforms where qreal is double and as QWIDGETSIZE_MAX / 32 when it is float. This is to avoid numerical errors in the simplex solver. This commit also modifies the ASSERT clause inside QSimplex so it becomes less prone to false positives due to numerical errors. Signed-off-by: Eduardo M. Fleury Signed-off-by: Caio Marcelo de Oliveira Filho --- src/gui/graphicsview/qgraphicsanchorlayout_p.cpp | 67 ++++++++++++++++++++---- src/gui/graphicsview/qsimplex_p.h | 2 +- 2 files changed, 57 insertions(+), 12 deletions(-) diff --git a/src/gui/graphicsview/qgraphicsanchorlayout_p.cpp b/src/gui/graphicsview/qgraphicsanchorlayout_p.cpp index d9f4e32..f3a1a69 100644 --- a/src/gui/graphicsview/qgraphicsanchorlayout_p.cpp +++ b/src/gui/graphicsview/qgraphicsanchorlayout_p.cpp @@ -49,9 +49,17 @@ #endif #include "qgraphicsanchorlayout_p.h" + #ifndef QT_NO_GRAPHICSVIEW QT_BEGIN_NAMESPACE +// To ensure that all variables inside the simplex solver are non-negative, +// we limit the size of anchors in the interval [-limit, limit]. Then before +// sending them to the simplex solver we add "limit" as an offset, so that +// they are actually calculated in the interval [0, 2 * limit] +// To avoid numerical errors in platforms where we use single precision, +// we use a tighter limit for the variables range. +const qreal limit = (sizeof(qreal) == sizeof(double)) ? QWIDGETSIZE_MAX : QWIDGETSIZE_MAX / 32; QGraphicsAnchorPrivate::QGraphicsAnchorPrivate(int version) : QObjectPrivate(version), layoutPrivate(0), data(0), @@ -2086,6 +2094,25 @@ void QGraphicsAnchorLayoutPrivate::calculateGraphs( /*! \internal + Shift all the constraints by a certain amount. This allows us to deal with negative values in + the linear program if they are bounded by a certain limit. Functions should be careful to + call it again with a negative amount, to shift the constraints back. +*/ +static void shiftConstraints(const QList &constraints, qreal amount) +{ + for (int i = 0; i < constraints.count(); ++i) { + QSimplexConstraint *c = constraints.at(i); + qreal multiplier = 0; + foreach (qreal v, c->variables.values()) { + multiplier += v; + } + c->constant += multiplier * amount; + } +} + +/*! + \internal + Calculate the sizes for all anchors which are part of the trunk. This works on top of a (possibly) simplified graph. */ @@ -2106,6 +2133,8 @@ bool QGraphicsAnchorLayoutPrivate::calculateTrunk(Orientation orientation, const QList sizeHintConstraints = constraintsFromSizeHints(variables); QList allConstraints = constraints + sizeHintConstraints; + shiftConstraints(allConstraints, limit); + // Solve min and max size hints qreal min, max; feasible = solveMinMax(allConstraints, path, &min, &max); @@ -2129,6 +2158,7 @@ bool QGraphicsAnchorLayoutPrivate::calculateTrunk(Orientation orientation, const } qDeleteAll(sizeHintConstraints); + shiftConstraints(constraints, -limit); } else { // No Simplex is necessary because the path was simplified all the way to a single @@ -2160,6 +2190,10 @@ bool QGraphicsAnchorLayoutPrivate::calculateNonTrunk(const QList &variables) { QList sizeHintConstraints = constraintsFromSizeHints(variables); + + shiftConstraints(sizeHintConstraints, limit); + shiftConstraints(constraints, limit); + bool feasible = solvePreferred(constraints + sizeHintConstraints, variables); if (feasible) { @@ -2174,6 +2208,9 @@ bool QGraphicsAnchorLayoutPrivate::calculateNonTrunk(const QList QGraphicsAnchorLayoutPrivate::constraintsFromSizeHin if (ad->dependency == AnchorData::Slave) continue; - if ((ad->minSize == ad->maxSize) || qFuzzyCompare(ad->minSize, ad->maxSize)) { + // To use negative variables inside simplex, we shift them so the minimum negative value is + // mapped to zero before solving. To make sure that it works, we need to guarantee that the + // variables are all inside a certain boundary. + qreal boundedMin = qBound(-limit, ad->minSize, limit); + qreal boundedMax = qBound(-limit, ad->maxSize, limit); + + if ((boundedMin == boundedMax) || qFuzzyCompare(boundedMin, boundedMax)) { QSimplexConstraint *c = new QSimplexConstraint; c->variables.insert(ad, 1.0); - c->constant = ad->minSize; + c->constant = boundedMin; c->ratio = QSimplexConstraint::Equal; anchorConstraints += c; unboundedProblem = false; } else { QSimplexConstraint *c = new QSimplexConstraint; c->variables.insert(ad, 1.0); - c->constant = ad->minSize; + c->constant = boundedMin; c->ratio = QSimplexConstraint::MoreOrEqual; anchorConstraints += c; @@ -2359,7 +2402,7 @@ QList QGraphicsAnchorLayoutPrivate::constraintsFromSizeHin c = new QSimplexConstraint; c->variables.insert(ad, 1.0); - c->constant = ad->maxSize; + c->constant = boundedMax; c->ratio = QSimplexConstraint::LessOrEqual; anchorConstraints += c; unboundedProblem = false; @@ -2370,7 +2413,8 @@ QList QGraphicsAnchorLayoutPrivate::constraintsFromSizeHin if (unboundedProblem) { QSimplexConstraint *c = new QSimplexConstraint; c->variables.insert(layoutEdge, 1.0); - c->constant = QWIDGETSIZE_MAX; + // The maximum size that the layout can take + c->constant = limit; c->ratio = QSimplexConstraint::LessOrEqual; anchorConstraints += c; } @@ -2691,27 +2735,28 @@ bool QGraphicsAnchorLayoutPrivate::solveMinMax(const QList for (iter = path.negatives.constBegin(); iter != path.negatives.constEnd(); ++iter) objective.variables.insert(*iter, -1.0); + const qreal objectiveOffset = (path.positives.count() - path.negatives.count()) * limit; simplex.setObjective(&objective); // Calculate minimum values - *min = simplex.solveMin(); + *min = simplex.solveMin() - objectiveOffset; // Save sizeAtMinimum results QList variables = getVariables(constraints); for (int i = 0; i < variables.size(); ++i) { AnchorData *ad = static_cast(variables.at(i)); - ad->sizeAtMinimum = ad->result; + ad->sizeAtMinimum = ad->result - limit; Q_ASSERT(ad->sizeAtMinimum >= ad->minSize || qAbs(ad->sizeAtMinimum - ad->minSize) < 0.00000001); } // Calculate maximum values - *max = simplex.solveMax(); + *max = simplex.solveMax() - objectiveOffset; // Save sizeAtMaximum results for (int i = 0; i < variables.size(); ++i) { AnchorData *ad = static_cast(variables.at(i)); - ad->sizeAtMaximum = ad->result; + ad->sizeAtMaximum = ad->result - limit; // Q_ASSERT(ad->sizeAtMaximum <= ad->maxSize || // qAbs(ad->sizeAtMaximum - ad->maxSize) < 0.00000001); } @@ -2756,7 +2801,7 @@ bool QGraphicsAnchorLayoutPrivate::solvePreferred(const QListvariables.insert(ad, 1.0); c->variables.insert(shrinker, 1.0); c->variables.insert(grower, -1.0); - c->constant = ad->prefSize; + c->constant = ad->prefSize + limit; preferredConstraints += c; preferredVariables += grower; @@ -2778,7 +2823,7 @@ bool QGraphicsAnchorLayoutPrivate::solvePreferred(const QListsizeAtPreferred = ad->result; + ad->sizeAtPreferred = ad->result - limit; } // Make sure we delete the simplex solver -before- we delete the diff --git a/src/gui/graphicsview/qsimplex_p.h b/src/gui/graphicsview/qsimplex_p.h index a5816d1..2004471 100644 --- a/src/gui/graphicsview/qsimplex_p.h +++ b/src/gui/graphicsview/qsimplex_p.h @@ -107,7 +107,7 @@ struct QSimplexConstraint Q_ASSERT(constant > 0 || qFuzzyCompare(1, 1 + constant)); - if ((leftHandSide == constant) || qAbs(leftHandSide - constant) < 0.00000001) + if ((leftHandSide == constant) || qAbs(leftHandSide - constant) < 0.0000001) return true; switch (ratio) { -- cgit v0.12 From 33116cf737b6ded48ccbb14af401ecb18adeec96 Mon Sep 17 00:00:00 2001 From: Jesus Sanchez-Palencia Date: Thu, 5 Nov 2009 13:41:36 -0300 Subject: QGAL: Do not revert negative anchors Since we now support anchors with size less then zero, we no longer need to revert anchors with negative spacing. Signed-off-by: Eduardo M. Fleury Reviewed-by: Caio Marcelo de Oliveira Filho --- src/gui/graphicsview/qgraphicsanchorlayout_p.cpp | 26 ++++-------------------- src/gui/graphicsview/qgraphicsanchorlayout_p.h | 1 - 2 files changed, 4 insertions(+), 23 deletions(-) diff --git a/src/gui/graphicsview/qgraphicsanchorlayout_p.cpp b/src/gui/graphicsview/qgraphicsanchorlayout_p.cpp index f3a1a69..3154630 100644 --- a/src/gui/graphicsview/qgraphicsanchorlayout_p.cpp +++ b/src/gui/graphicsview/qgraphicsanchorlayout_p.cpp @@ -64,7 +64,7 @@ const qreal limit = (sizeof(qreal) == sizeof(double)) ? QWIDGETSIZE_MAX : QWIDGE QGraphicsAnchorPrivate::QGraphicsAnchorPrivate(int version) : QObjectPrivate(version), layoutPrivate(0), data(0), sizePolicy(QSizePolicy::Fixed), preferredSize(0), - hasSize(true), reversed(false) + hasSize(true) { } @@ -94,27 +94,12 @@ void QGraphicsAnchorPrivate::setSpacing(qreal value) return; } - const qreal rawValue = reversed ? -preferredSize : preferredSize; - if (hasSize && (rawValue == value)) + if (hasSize && (preferredSize == 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; - } + preferredSize = value; layoutPrivate->q_func()->invalidate(); } @@ -128,9 +113,6 @@ void QGraphicsAnchorPrivate::unsetSpacing() // Return to standard direction hasSize = false; - if (reversed) - qSwap(data->from, data->to); - reversed = false; layoutPrivate->q_func()->invalidate(); } @@ -142,7 +124,7 @@ qreal QGraphicsAnchorPrivate::spacing() const return 0; } - return reversed ? -preferredSize : preferredSize; + return preferredSize; } diff --git a/src/gui/graphicsview/qgraphicsanchorlayout_p.h b/src/gui/graphicsview/qgraphicsanchorlayout_p.h index e96110c..925d7ef 100644 --- a/src/gui/graphicsview/qgraphicsanchorlayout_p.h +++ b/src/gui/graphicsview/qgraphicsanchorlayout_p.h @@ -342,7 +342,6 @@ public: 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 }; -- cgit v0.12 From 666576b39da04f4185036d9eee1b8edeae10ccf7 Mon Sep 17 00:00:00 2001 From: "Eduardo M. Fleury" Date: Thu, 5 Nov 2009 11:54:33 -0300 Subject: QGAL: Support for out-of-order sequential anchors Now sequential anchors account for the fact they may be composed of anchors with different directions. Both refreshSizeHints and updateChildrenSizes have been updated to support this situation. Signed-off-by: Eduardo M. Fleury Reviewed-by: Caio Marcelo de Oliveira Filho --- src/gui/graphicsview/qgraphicsanchorlayout_p.cpp | 40 ++++++++++++++++++++---- 1 file changed, 34 insertions(+), 6 deletions(-) diff --git a/src/gui/graphicsview/qgraphicsanchorlayout_p.cpp b/src/gui/graphicsview/qgraphicsanchorlayout_p.cpp index 3154630..1f1769f 100644 --- a/src/gui/graphicsview/qgraphicsanchorlayout_p.cpp +++ b/src/gui/graphicsview/qgraphicsanchorlayout_p.cpp @@ -416,12 +416,27 @@ void SequentialAnchorData::updateChildrenSizes() const QPair maxFactor = getFactor(sizeAtMaximum, minSize, prefSize, maxSize); + // XXX This is not safe if Vertex simplification takes place after the sequential + // anchor is created. In that case, "prev" will be a group-vertex, different from + // "from" or "to", that _contains_ one of them. + AnchorVertex *prev = from; + for (int i = 0; i < m_edges.count(); ++i) { AnchorData *e = m_edges.at(i); - e->sizeAtMinimum = interpolate(minFactor, e->minSize, e->prefSize, e->maxSize); - e->sizeAtPreferred = interpolate(prefFactor, e->minSize, e->prefSize, e->maxSize); - e->sizeAtMaximum = interpolate(maxFactor, e->minSize, e->prefSize, e->maxSize); + const bool edgeIsForward = (e->from == prev); + if (edgeIsForward) { + e->sizeAtMinimum = interpolate(minFactor, e->minSize, e->prefSize, e->maxSize); + e->sizeAtPreferred = interpolate(prefFactor, e->minSize, e->prefSize, e->maxSize); + e->sizeAtMaximum = interpolate(maxFactor, e->minSize, e->prefSize, e->maxSize); + prev = e->to; + } else { + Q_ASSERT(prev == e->to); + e->sizeAtMinimum = interpolate(minFactor, e->maxSize, e->prefSize, e->minSize); + e->sizeAtPreferred = interpolate(prefFactor, e->maxSize, e->prefSize, e->minSize); + e->sizeAtMaximum = interpolate(maxFactor, e->maxSize, e->prefSize, e->minSize); + prev = e->from; + } e->updateChildrenSizes(); } @@ -433,11 +448,24 @@ void SequentialAnchorData::calculateSizeHints() prefSize = 0; maxSize = 0; + AnchorVertex *prev = from; + for (int i = 0; i < m_edges.count(); ++i) { AnchorData *edge = m_edges.at(i); - minSize += edge->minSize; - prefSize += edge->prefSize; - maxSize += edge->maxSize; + + const bool edgeIsForward = (edge->from == prev); + if (edgeIsForward) { + minSize += edge->minSize; + prefSize += edge->prefSize; + maxSize += edge->maxSize; + prev = edge->to; + } else { + Q_ASSERT(prev == edge->to); + minSize -= edge->maxSize; + prefSize -= edge->prefSize; + maxSize -= edge->minSize; + prev = edge->from; + } } // See comment in AnchorData::refreshSizeHints() about sizeAt* values -- cgit v0.12 From 89f83f99242d67b5079f16c8db0960fc71bda3f0 Mon Sep 17 00:00:00 2001 From: "Eduardo M. Fleury" Date: Thu, 5 Nov 2009 23:19:29 -0300 Subject: QGAL: Enable out-of-order sequential simplification Modify the simplification code to allow the creation of out-of-order sequential anchors. Basically the "changedDirection" end-of-sequence condition was removed, also note that createSequence no longer bothers to revert the direction of anchors if the order it receives is not standard. Removing expect-fail clause from test since now we pass :-) Signed-off-by: Eduardo M. Fleury Reviewed-by: Caio Marcelo de Oliveira Filho --- src/gui/graphicsview/qgraphicsanchorlayout_p.cpp | 69 ++++++++-------------- .../tst_qgraphicsanchorlayout.cpp | 1 - 2 files changed, 23 insertions(+), 47 deletions(-) diff --git a/src/gui/graphicsview/qgraphicsanchorlayout_p.cpp b/src/gui/graphicsview/qgraphicsanchorlayout_p.cpp index 1f1769f..a69d8f3 100644 --- a/src/gui/graphicsview/qgraphicsanchorlayout_p.cpp +++ b/src/gui/graphicsview/qgraphicsanchorlayout_p.cpp @@ -669,24 +669,10 @@ static AnchorData *createSequence(Graph *graph, const QVector &vertices, AnchorVertex *after) { - AnchorData *data = graph->edgeData(before, vertices.first()); - Q_ASSERT(data); - - const bool forward = (before == data->from); - QVector orderedVertices; - - if (forward) { - orderedVertices = vertices; - } else { - qSwap(before, after); - for (int i = vertices.count() - 1; i >= 0; --i) - orderedVertices.append(vertices.at(i)); - } - #if defined(QT_DEBUG) && 0 QString strVertices; - for (int i = 0; i < orderedVertices.count(); ++i) { - strVertices += QString::fromAscii("%1 - ").arg(orderedVertices.at(i)->toString()); + for (int i = 0; i < vertices.count(); ++i) { + strVertices += QString::fromAscii("%1 - ").arg(vertices.at(i)->toString()); } QString strPath = QString::fromAscii("%1 - %2%3").arg(before->toString(), strVertices, after->toString()); qDebug("simplifying [%s] to [%s - %s]", qPrintable(strPath), qPrintable(before->toString()), qPrintable(after->toString())); @@ -695,15 +681,22 @@ static AnchorData *createSequence(Graph *graph, AnchorVertex *prev = before; QVector edges; - for (int i = 0; i <= orderedVertices.count(); ++i) { - AnchorVertex *next = (i < orderedVertices.count()) ? orderedVertices.at(i) : after; + // Take from the graph, the edges that will be simplificated + for (int i = 0; i < vertices.count(); ++i) { + AnchorVertex *next = vertices.at(i); AnchorData *ad = graph->takeEdge(prev, next); Q_ASSERT(ad); edges.append(ad); prev = next; } - SequentialAnchorData *sequence = new SequentialAnchorData(orderedVertices, edges); + // Take the last edge (not covered in the loop above) + AnchorData *ad = graph->takeEdge(vertices.last(), after); + Q_ASSERT(ad); + edges.append(ad); + + // Create sequence + SequentialAnchorData *sequence = new SequentialAnchorData(vertices, edges); sequence->from = before; sequence->to = after; @@ -963,7 +956,6 @@ bool QGraphicsAnchorLayoutPrivate::simplifyGraphIteration(QGraphicsAnchorLayoutP QStack > stack; stack.push(qMakePair(static_cast(0), layoutFirstVertex[orientation])); QVector candidates; - bool candidatesForward = true; // Walk depth-first, in the stack we store start of the candidate sequence (beforeSequence) // and the vertex to be visited. @@ -979,9 +971,8 @@ bool QGraphicsAnchorLayoutPrivate::simplifyGraphIteration(QGraphicsAnchorLayoutP // A vertex can trigger an end of sequence if // (a) it is a layout vertex, we don't simplify away the layout vertices; // (b) it does not have exactly 2 adjacents; - // (c) it will change the direction of the sequence; - // (d) its next adjacent is already visited (a cycle in the graph); - // (e) the next anchor is a center anchor. + // (c) its next adjacent is already visited (a cycle in the graph). + // (d) the next anchor is a center anchor. const QList &adjacents = g.adjacentVertices(v); const bool isLayoutVertex = v->m_item == q; @@ -996,19 +987,10 @@ bool QGraphicsAnchorLayoutPrivate::simplifyGraphIteration(QGraphicsAnchorLayoutP endOfSequence = isLayoutVertex || adjacents.count() != 2; if (!endOfSequence) { - // If this is the first vertice, determine what is the direction to use for this - // sequence. - if (candidates.isEmpty()) { - const AnchorData *data = g.edgeData(beforeSequence, v); - Q_ASSERT(data); - candidatesForward = (beforeSequence == data->from); - } - // This is a tricky part. We peek at the next vertex to find out whether // - // - the edge from this vertex to the next vertex has the same direction; - // - we already visited the next vertex; - // - the next anchor is a center. + // - we already visited the next vertex (c); + // - the next anchor is a center (d). // // Those are needed to identify the remaining end of sequence cases. Note that unlike // (a) and (b), we preempt the end of sequence by looking into the next vertex. @@ -1026,22 +1008,17 @@ bool QGraphicsAnchorLayoutPrivate::simplifyGraphIteration(QGraphicsAnchorLayoutP const AnchorData *data = g.edgeData(v, after); Q_ASSERT(data); - const bool willChangeDirection = (candidatesForward != (v == data->from)); const bool cycleFound = visited.contains(after); - // Now cases (c), (d) and (e)... - endOfSequence = willChangeDirection || cycleFound || data->isCenterAnchor; + // Now cases (c) and (d)... + endOfSequence = cycleFound || data->isCenterAnchor; - if (endOfSequence) { - if (!willChangeDirection) { - // If the direction will not change, we can add the current vertex to the - // candidates list and we know that 'after' can be used as afterSequence. - candidates.append(v); - afterSequence = after; - } - } else { + if (!endOfSequence) { // If it's not an end of sequence, then the vertex didn't trigger neither of the - // previously four cases, so it can be added to the candidates list. + // previously three cases, so it can be added to the candidates list. + candidates.append(v); + } else if (cycleFound && (beforeSequence != after)) { + afterSequence = after; candidates.append(v); } } diff --git a/tests/auto/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp b/tests/auto/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp index d566498..6e78522 100644 --- a/tests/auto/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp +++ b/tests/auto/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp @@ -1806,7 +1806,6 @@ void tst_QGraphicsAnchorLayout::simplificationVsOrder() l->effectiveSizeHint(Qt::MinimumSize); if (hasSimplification) { - QEXPECT_FAIL("", "Sequential anchors cannot handle children of opposite directions", Continue); QCOMPARE(usedSimplex(l, Qt::Horizontal), false); QCOMPARE(usedSimplex(l, Qt::Vertical), false); } -- cgit v0.12 From 12341a4e33a498037679e27edee829fa245a0148 Mon Sep 17 00:00:00 2001 From: "Eduardo M. Fleury" Date: Tue, 17 Nov 2009 16:35:28 -0300 Subject: QGAL: Use single arrow in "dumpGraph" Modify the "dot" format graph to use a single arrow between each pair of vertices. Previously we would use two anchors (a black forward one and a gray backwards). With a single arrow the graph loooks cleaner. Signed-off-by: Eduardo M. Fleury Reviewed-by: Caio Marcelo de Oliveira Filho --- src/gui/graphicsview/qgraph_p.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/graphicsview/qgraph_p.h b/src/gui/graphicsview/qgraph_p.h index 0a2bf27..d429714 100644 --- a/src/gui/graphicsview/qgraph_p.h +++ b/src/gui/graphicsview/qgraph_p.h @@ -236,7 +236,7 @@ public: EdgeData *data = edgeData(v, v1); bool forward = data->from == v; if (forward) { - edges += QString::fromAscii("\"%1\"->\"%2\" [label=\"[%3,%4,%5]\" dir=both color=\"#000000:#a0a0a0\"] \n") + edges += QString::fromAscii("\"%1\"->\"%2\" [label=\"[%3,%4,%5]\" color=\"#000000\"] \n") .arg(v->toString()) .arg(v1->toString()) .arg(data->minSize) -- cgit v0.12 From d622aef01e5c2624cd64c92ce77064718c6576af Mon Sep 17 00:00:00 2001 From: Caio Marcelo de Oliveira Filho Date: Wed, 18 Nov 2009 16:00:32 -0300 Subject: QGAL: move second child direction check to a function In a parallel anchor, the second child anchor may be forward or backwards in relation to the parallel itself. Moves the directionality check to a function. It'll be useful in the next commit. Signed-off-by: Caio Marcelo de Oliveira Filho Reviewed-by: Eduardo M. Fleury --- src/gui/graphicsview/qgraphicsanchorlayout_p.cpp | 26 ++++++++++++++---------- src/gui/graphicsview/qgraphicsanchorlayout_p.h | 10 ++++++++- 2 files changed, 24 insertions(+), 12 deletions(-) diff --git a/src/gui/graphicsview/qgraphicsanchorlayout_p.cpp b/src/gui/graphicsview/qgraphicsanchorlayout_p.cpp index a69d8f3..4ee58d1 100644 --- a/src/gui/graphicsview/qgraphicsanchorlayout_p.cpp +++ b/src/gui/graphicsview/qgraphicsanchorlayout_p.cpp @@ -265,13 +265,7 @@ void ParallelAnchorData::updateChildrenSizes() firstEdge->sizeAtPreferred = sizeAtPreferred; firstEdge->sizeAtMaximum = sizeAtMaximum; - // 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) { + if (secondForward()) { secondEdge->sizeAtMinimum = sizeAtMinimum; secondEdge->sizeAtPreferred = sizeAtPreferred; secondEdge->sizeAtMaximum = sizeAtMaximum; @@ -296,10 +290,20 @@ bool ParallelAnchorData::calculateSizeHints() // to a backwards anchor of size (-max, -pref, -min) // 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; + + qreal secondMin; + qreal secondPref; + qreal secondMax; + + if (secondForward()) { + secondMin = secondEdge->minSize; + secondPref = secondEdge->prefSize; + secondMax = secondEdge->maxSize; + } else { + secondMin = -secondEdge->maxSize; + secondPref = -secondEdge->prefSize; + secondMax = -secondEdge->minSize; + } minSize = qMax(firstEdge->minSize, secondMin); maxSize = qMin(firstEdge->maxSize, secondMax); diff --git a/src/gui/graphicsview/qgraphicsanchorlayout_p.h b/src/gui/graphicsview/qgraphicsanchorlayout_p.h index 925d7ef..8d2d691 100644 --- a/src/gui/graphicsview/qgraphicsanchorlayout_p.h +++ b/src/gui/graphicsview/qgraphicsanchorlayout_p.h @@ -212,7 +212,8 @@ struct ParallelAnchorData : public AnchorData Q_ASSERT(((first->from == second->from) && (first->to == second->to)) || ((first->from == second->to) && (first->to == second->from))); - // We arbitrarily choose the direction of the first child as "our" direction + // Our convention will be that the parallel group anchor will have the same + // direction as the first anchor. from = first->from; to = first->to; #ifdef QT_DEBUG @@ -223,6 +224,13 @@ struct ParallelAnchorData : public AnchorData virtual void updateChildrenSizes(); bool calculateSizeHints(); + bool secondForward() const { + // We have the convention that the first children will define the direction of the + // pararell group. Note that we can't rely on 'this->from' or 'this->to' because they + // might be changed by vertex simplification. + return firstEdge->from == secondEdge->from; + } + AnchorData* firstEdge; AnchorData* secondEdge; -- cgit v0.12 From c7d63a44b315bf945c055330c24b24bca6ef7fdb Mon Sep 17 00:00:00 2001 From: Caio Marcelo de Oliveira Filho Date: Wed, 18 Nov 2009 17:46:52 -0300 Subject: QGAL: parallel anchors sometimes have to fix constraints For an out-of-order parallel anchor, i.e. when the second child is backwards in relation to the parallel anchor, we need to fix the constraints that used to have the second child. The parallel anchor will replace its child, but we must change the multiplier signal, so the constraint remain valid. This commit also changes the order of restoration steps, since now we depend on correct vertex information to fix back the constraints, we do it before the restoring of pair vertices. Signed-off-by: Caio Marcelo de Oliveira Filho Reviewed-by: Eduardo M. Fleury --- src/gui/graphicsview/qgraphicsanchorlayout_p.cpp | 51 ++++++++++++++++-------- 1 file changed, 35 insertions(+), 16 deletions(-) diff --git a/src/gui/graphicsview/qgraphicsanchorlayout_p.cpp b/src/gui/graphicsview/qgraphicsanchorlayout_p.cpp index 4ee58d1..9114fc3 100644 --- a/src/gui/graphicsview/qgraphicsanchorlayout_p.cpp +++ b/src/gui/graphicsview/qgraphicsanchorlayout_p.cpp @@ -633,16 +633,25 @@ AnchorData *QGraphicsAnchorLayoutPrivate::addAnchorMaybeParallel(AnchorData *new AnchorData *child = children[i]; QList *childConstraints = childrenConstraints[i]; + // We need to fix the second child constraints if the parallel group will have the + // opposite direction of the second child anchor. For the point of view of external + // entities, this anchor was reversed. So if at some point we say that the parallel + // has a value of 20, this mean that the second child (when reversed) will be + // assigned -20. + const bool needsReverse = i == 1 && !parallel->secondForward(); + if (!child->isCenterAnchor) continue; parallel->isCenterAnchor = true; - for (int i = 0; i < constraints.count(); ++i) { - QSimplexConstraint *c = constraints[i]; + for (int j = 0; j < constraints.count(); ++j) { + QSimplexConstraint *c = constraints[j]; if (c->variables.contains(child)) { childConstraints->append(c); qreal v = c->variables.take(child); + if (needsReverse) + v *= -1; c->variables.insert(parallel, v); } } @@ -1165,9 +1174,15 @@ void QGraphicsAnchorLayoutPrivate::restoreSimplifiedConstraints(ParallelAnchorDa c->variables.insert(parallel->firstEdge, v); } + // When restoring, we might have to revert constraints back. See comments on + // addAnchorMaybeParallel(). + const bool needsReverse = !parallel->secondForward(); + for (int i = 0; i < parallel->m_secondConstraints.count(); ++i) { QSimplexConstraint *c = parallel->m_secondConstraints.at(i); qreal v = c->variables[parallel]; + if (needsReverse) + v *= -1; c->variables.remove(parallel); c->variables.insert(parallel->secondEdge, v); } @@ -1209,7 +1224,24 @@ void QGraphicsAnchorLayoutPrivate::restoreVertices(Orientation orientation) Graph &g = graph[orientation]; QList &toRestore = simplifiedVertices[orientation]; - // We will restore the vertices in the inverse order of creation, this way we ensure that + // Since we keep a list of parallel anchors and vertices that were created during vertex + // simplification, we can now iterate on those lists instead of traversing the graph + // recursively. + + // First, restore the constraints changed when we created parallel anchors. Note that this + // works at this point because the constraints doesn't depend on vertex information and at + // this point it's always safe to identify whether the second child is forward or backwards. + // In the next step, we'll change the anchors vertices so that would not be possible anymore. + QList ¶llelAnchors = anchorsFromSimplifiedVertices[orientation]; + + for (int i = parallelAnchors.count() - 1; i >= 0; --i) { + ParallelAnchorData *parallel = static_cast(parallelAnchors.at(i)); + restoreSimplifiedConstraints(parallel); + delete parallel; + } + parallelAnchors.clear(); + + // Then, we will restore the vertices in the inverse order of creation, this way we ensure that // the vertex being restored was not wrapped by another simplification. for (int i = toRestore.count() - 1; i >= 0; --i) { AnchorVertexPair *pair = toRestore.at(i); @@ -1254,19 +1286,6 @@ void QGraphicsAnchorLayoutPrivate::restoreVertices(Orientation orientation) delete pair; } toRestore.clear(); - - // The restoration process for vertex simplification also restored the effect of the - // parallel anchors created during vertex simplification, so we just need to restore - // the constraints in case of parallels that contain center anchors. For the same - // reason as above, order matters here. - QList ¶llelAnchors = anchorsFromSimplifiedVertices[orientation]; - - for (int i = parallelAnchors.count() - 1; i >= 0; --i) { - ParallelAnchorData *parallel = static_cast(parallelAnchors.at(i)); - restoreSimplifiedConstraints(parallel); - delete parallel; - } - parallelAnchors.clear(); } QGraphicsAnchorLayoutPrivate::Orientation -- cgit v0.12 From 7fbb8aae666a86091cb7f7f3326e9e05781c02f3 Mon Sep 17 00:00:00 2001 From: "Eduardo M. Fleury" Date: Wed, 18 Nov 2009 17:20:24 -0300 Subject: QGAL: Add AnchorData::minPrefSize and maxPrefSize With the addition of out-of-order sequential simplification, the calculation of preferred sizes became more complicated. In the past, when parallel anchors or the simplex solver had to decide between conflicting preferred sizes, they could assume that increasing the size of an anchor was better than decreasing it. That assumption comes from early discussions with Jan-Arve regarding the preferred size calculation algorithm. However, when ooo-sequential anchors exist, we can have a situation where increasing the size of an anchor can actually reduce the size of a simplified anchor inside it. To solve that, we need to expose some information regarding the internal anchors to the decision makers outside, ie. the simplex solver and parallel anchors. This information is now being provided in terms of two additional values present in each anchor, as follows: - minPrefSize: Always in the interval [minSize, prefSize]. Denotes the minimum size an anchor can assume as to avoid shrinking anchors below their preferred sizes. - maxPrefSize: Always in the interval [prefSize, maxSize]. Similar to the value above, but refering to the maximum size the anchor should assume. Some examples: 1) Standard anchor: 10 / 50 / 500 o----------------------------> Becomes: 10 / 50 / 50 / 500 / 500 o----------------------------> We'd rather grow than shrink, so we say that our preferred size is 50, but if we need to grow up to 500, that's OK. Note that we are still able to shrink all the way to 10, but it will hurt us more. 2) Two anchors: 100 / 200 / 500 10 / 20 / 40 o--------------------> <-------------------o Resulting sequential anchor: 60 / 160 / 180 / 480 / 490 o------------------------------------------> The resulting anchor have a preferred size of 180 but it can "easily" grow to 480 (only the first half grows). If it had to go all the way to 490 the second half would have to shrink below its preferred size. OTOH, if it had to shrink, it could go to 160 if the second half grew. However, shrinking even more, towards 60, would require the first half to shrink below its preferred size. With this information parallel and simplex are now able to choose the best solutions when solving conflicts. Signed-off-by: Eduardo M. Fleury Reviewed-by: Caio Marcelo de Oliveira Filho --- src/gui/graphicsview/qgraph_p.h | 4 +- src/gui/graphicsview/qgraphicsanchorlayout_p.cpp | 181 +++++++++++++++++------ src/gui/graphicsview/qgraphicsanchorlayout_p.h | 10 +- 3 files changed, 149 insertions(+), 46 deletions(-) diff --git a/src/gui/graphicsview/qgraph_p.h b/src/gui/graphicsview/qgraph_p.h index d429714..076b8fa 100644 --- a/src/gui/graphicsview/qgraph_p.h +++ b/src/gui/graphicsview/qgraph_p.h @@ -236,11 +236,13 @@ public: EdgeData *data = edgeData(v, v1); bool forward = data->from == v; if (forward) { - edges += QString::fromAscii("\"%1\"->\"%2\" [label=\"[%3,%4,%5]\" color=\"#000000\"] \n") + edges += QString::fromAscii("\"%1\"->\"%2\" [label=\"[%3,%4,%5,%6,%7]\" color=\"#000000\"] \n") .arg(v->toString()) .arg(v1->toString()) .arg(data->minSize) + .arg(data->minPrefSize) .arg(data->prefSize) + .arg(data->maxPrefSize) .arg(data->maxSize) ; } diff --git a/src/gui/graphicsview/qgraphicsanchorlayout_p.cpp b/src/gui/graphicsview/qgraphicsanchorlayout_p.cpp index 9114fc3..6d90d3a 100644 --- a/src/gui/graphicsview/qgraphicsanchorlayout_p.cpp +++ b/src/gui/graphicsview/qgraphicsanchorlayout_p.cpp @@ -190,6 +190,9 @@ void AnchorData::refreshSizeHints(const QLayoutStyleInfo *styleInfo) maxSize = QWIDGETSIZE_MAX; if (isCenterAnchor) maxSize /= 2; + + minPrefSize = prefSize; + maxPrefSize = maxSize; return; } else { if (orientation == QGraphicsAnchorLayoutPrivate::Horizontal) { @@ -247,6 +250,9 @@ void AnchorData::refreshSizeHints(const QLayoutStyleInfo *styleInfo) applySizePolicy(policy, minSizeHint, prefSizeHint, maxSizeHint, &minSize, &prefSize, &maxSize); + minPrefSize = prefSize; + maxPrefSize = maxSize; + // Set the anchor effective sizes to preferred. // // Note: The idea here is that all items should remain at their @@ -279,29 +285,38 @@ void ParallelAnchorData::updateChildrenSizes() secondEdge->updateChildrenSizes(); } -bool ParallelAnchorData::calculateSizeHints() -{ - // 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 - // to a backwards anchor of size (-max, -pref, -min) +/* + \internal - // Also see comments in updateChildrenSizes(). + Initialize the parallel anchor size hints using the sizeHint information from + its children. + 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. + */ +bool ParallelAnchorData::calculateSizeHints() +{ + // Normalize second child sizes. + // A negative anchor of sizes min, minPref, pref, maxPref and max, is equivalent + // to a forward anchor of sizes -max, -maxPref, -pref, -minPref, -min qreal secondMin; + qreal secondMinPref; qreal secondPref; + qreal secondMaxPref; qreal secondMax; if (secondForward()) { secondMin = secondEdge->minSize; + secondMinPref = secondEdge->minPrefSize; secondPref = secondEdge->prefSize; + secondMaxPref = secondEdge->maxPrefSize; secondMax = secondEdge->maxSize; } else { secondMin = -secondEdge->maxSize; + secondMinPref = -secondEdge->maxPrefSize; secondPref = -secondEdge->prefSize; + secondMaxPref = -secondEdge->minPrefSize; secondMax = -secondEdge->minSize; } @@ -315,23 +330,72 @@ bool ParallelAnchorData::calculateSizeHints() return false; } - // The equivalent preferred Size of a parallel anchor is calculated as to - // reduce the deviation from the original preferred sizes _and_ to avoid shrinking - // items below their preferred sizes, unless strictly needed. - - // ### This logic only holds if all anchors in the layout are "well-behaved" in the - // following terms: + // Preferred size calculation + // The calculation of preferred size is done as follows: + // + // 1) Check whether one of the child anchors is the layout structural anchor + // If so, we can simply copy the preferred information from the other child, + // after bounding it to our minimum and maximum sizes. + // If not, then we proceed with the actual calculations. // - // - There are no negative-sized anchors - // - All sequential anchors are composed of children in the same direction as the - // sequential anchor itself + // 2) The whole algorithm for preferred size calculation is based on the fact + // that, if a given anchor cannot remain at its preferred size, it'd rather + // grow than shrink. // - // With these assumptions we can grow a child knowing that no hidden items will - // have to shrink as the result of that. - // If any of these does not hold, we have a situation where the ParallelAnchor - // does not have enough information to calculate its equivalent prefSize. - prefSize = qMax(firstEdge->prefSize, secondPref); - prefSize = qMin(prefSize, maxSize); + // What happens though is that while this affirmative is true for simple + // anchors, it may not be true for sequential anchors that have one or more + // reversed anchors inside it. That happens because when a sequential anchor + // grows, any reversed anchors inside it may be required to shrink, something + // we try to avoid, as said above. + // + // To overcome this, besides their actual preferred size "prefSize", each anchor + // exports what we call "minPrefSize" and "maxPrefSize". These two values define + // a surrounding interval where, if required to move, the anchor would rather + // remain inside. + // + // For standard anchors, this area simply represents the region between + // prefSize and maxSize, which makes sense since our first affirmation. + // For composed anchors, these values are calculated as to reduce the global + // "damage", that is, to reduce the total deviation and the total amount of + // anchors that had to shrink. + + if (firstEdge->isLayoutAnchor) { + prefSize = qBound(minSize, secondPref, maxSize); + minPrefSize = qBound(minSize, secondMinPref, maxSize); + maxPrefSize = qBound(minSize, secondMaxPref, maxSize); + } else if (secondEdge->isLayoutAnchor) { + prefSize = qBound(minSize, firstEdge->prefSize, maxSize); + minPrefSize = qBound(minSize, firstEdge->minPrefSize, maxSize); + maxPrefSize = qBound(minSize, firstEdge->maxPrefSize, maxSize); + } else { + // Calculate the intersection between the "preferred" regions of each child + const qreal lowerBoundary = + qBound(minSize, qMax(firstEdge->minPrefSize, secondMinPref), maxSize); + const qreal upperBoundary = + qBound(minSize, qMin(firstEdge->maxPrefSize, secondMaxPref), maxSize); + const qreal prefMean = + qBound(minSize, (firstEdge->prefSize + secondPref) / 2, maxSize); + + if (lowerBoundary < upperBoundary) { + // If there is an intersection between the two regions, this intersection + // will be used as the preferred region of the parallel anchor itself. + // The preferred size will be the bounded average between the two preferred + // sizes. + prefSize = qBound(lowerBoundary, prefMean, upperBoundary); + minPrefSize = lowerBoundary; + maxPrefSize = upperBoundary; + } else { + // If there is no intersection, we have to attribute "damage" to at least + // one of the children. The minimum total damage is achieved in points + // inside the region that extends from (1) the upper boundary of the lower + // region to (2) the lower boundary of the upper region. + // Then, we expose this region as _our_ preferred region and once again, + // use the bounded average as our preferred size. + prefSize = qBound(upperBoundary, prefMean, lowerBoundary); + minPrefSize = upperBoundary; + maxPrefSize = lowerBoundary; + } + } // See comment in AnchorData::refreshSizeHints() about sizeAt* values sizeAtMinimum = prefSize; @@ -349,19 +413,28 @@ bool ParallelAnchorData::calculateSizeHints() 1 is at Maximum */ static QPair getFactor(qreal value, qreal min, - qreal pref, qreal max) + qreal minPref, qreal pref, + qreal maxPref, qreal max) { QGraphicsAnchorLayoutPrivate::Interval interval; qreal lower; qreal upper; - if (value < pref) { - interval = QGraphicsAnchorLayoutPrivate::MinToPreferred; + if (value < minPref) { + interval = QGraphicsAnchorLayoutPrivate::MinimumToMinPreferred; lower = min; + upper = minPref; + } else if (value < pref) { + interval = QGraphicsAnchorLayoutPrivate::MinPreferredToPreferred; + lower = minPref; upper = pref; - } else { - interval = QGraphicsAnchorLayoutPrivate::PreferredToMax; + } else if (value < maxPref) { + interval = QGraphicsAnchorLayoutPrivate::PreferredToMaxPreferred; lower = pref; + upper = maxPref; + } else { + interval = QGraphicsAnchorLayoutPrivate::MaxPreferredToMaximum; + lower = maxPref; upper = max; } @@ -376,19 +449,26 @@ static QPair getFactor(qreal valu } static qreal interpolate(const QPair &factor, - qreal min, qreal pref, - qreal max) + qreal min, qreal minPref, qreal pref, qreal maxPref, qreal max) { qreal lower; qreal upper; switch (factor.first) { - case QGraphicsAnchorLayoutPrivate::MinToPreferred: + case QGraphicsAnchorLayoutPrivate::MinimumToMinPreferred: lower = min; + upper = minPref; + break; + case QGraphicsAnchorLayoutPrivate::MinPreferredToPreferred: + lower = minPref; upper = pref; break; - case QGraphicsAnchorLayoutPrivate::PreferredToMax: + case QGraphicsAnchorLayoutPrivate::PreferredToMaxPreferred: lower = pref; + upper = maxPref; + break; + case QGraphicsAnchorLayoutPrivate::MaxPreferredToMaximum: + lower = maxPref; upper = max; break; } @@ -414,11 +494,11 @@ void SequentialAnchorData::updateChildrenSizes() // band (the lower band) or the Preferred To Maximum (the upper band). const QPair minFactor = - getFactor(sizeAtMinimum, minSize, prefSize, maxSize); + getFactor(sizeAtMinimum, minSize, minPrefSize, prefSize, maxPrefSize, maxSize); const QPair prefFactor = - getFactor(sizeAtPreferred, minSize, prefSize, maxSize); + getFactor(sizeAtPreferred, minSize, minPrefSize, prefSize, maxPrefSize, maxSize); const QPair maxFactor = - getFactor(sizeAtMaximum, minSize, prefSize, maxSize); + getFactor(sizeAtMaximum, minSize, minPrefSize, prefSize, maxPrefSize, maxSize); // XXX This is not safe if Vertex simplification takes place after the sequential // anchor is created. In that case, "prev" will be a group-vertex, different from @@ -430,15 +510,21 @@ void SequentialAnchorData::updateChildrenSizes() const bool edgeIsForward = (e->from == prev); if (edgeIsForward) { - e->sizeAtMinimum = interpolate(minFactor, e->minSize, e->prefSize, e->maxSize); - e->sizeAtPreferred = interpolate(prefFactor, e->minSize, e->prefSize, e->maxSize); - e->sizeAtMaximum = interpolate(maxFactor, e->minSize, e->prefSize, e->maxSize); + e->sizeAtMinimum = interpolate(minFactor, e->minSize, e->minPrefSize, + e->prefSize, e->maxPrefSize, e->maxSize); + e->sizeAtPreferred = interpolate(prefFactor, e->minSize, e->minPrefSize, + e->prefSize, e->maxPrefSize, e->maxSize); + e->sizeAtMaximum = interpolate(maxFactor, e->minSize, e->minPrefSize, + e->prefSize, e->maxPrefSize, e->maxSize); prev = e->to; } else { Q_ASSERT(prev == e->to); - e->sizeAtMinimum = interpolate(minFactor, e->maxSize, e->prefSize, e->minSize); - e->sizeAtPreferred = interpolate(prefFactor, e->maxSize, e->prefSize, e->minSize); - e->sizeAtMaximum = interpolate(maxFactor, e->maxSize, e->prefSize, e->minSize); + e->sizeAtMinimum = interpolate(minFactor, e->maxSize, e->maxPrefSize, + e->prefSize, e->minPrefSize, e->minSize); + e->sizeAtPreferred = interpolate(prefFactor, e->maxSize, e->maxPrefSize, + e->prefSize, e->minPrefSize, e->minSize); + e->sizeAtMaximum = interpolate(maxFactor, e->maxSize, e->maxPrefSize, + e->prefSize, e->minPrefSize, e->minSize); prev = e->from; } @@ -451,6 +537,8 @@ void SequentialAnchorData::calculateSizeHints() minSize = 0; prefSize = 0; maxSize = 0; + minPrefSize = 0; + maxPrefSize = 0; AnchorVertex *prev = from; @@ -462,12 +550,16 @@ void SequentialAnchorData::calculateSizeHints() minSize += edge->minSize; prefSize += edge->prefSize; maxSize += edge->maxSize; + minPrefSize += edge->minPrefSize; + maxPrefSize += edge->maxPrefSize; prev = edge->to; } else { Q_ASSERT(prev == edge->to); minSize -= edge->maxSize; prefSize -= edge->prefSize; maxSize -= edge->minSize; + minPrefSize -= edge->maxPrefSize; + maxPrefSize -= edge->minPrefSize; prev = edge->from; } } @@ -2690,6 +2782,8 @@ void QGraphicsAnchorLayoutPrivate::setupEdgesInterpolation( result = getFactor(current, sizeHints[orientation][Qt::MinimumSize], sizeHints[orientation][Qt::PreferredSize], + sizeHints[orientation][Qt::PreferredSize], + sizeHints[orientation][Qt::PreferredSize], sizeHints[orientation][Qt::MaximumSize]); interpolationInterval[orientation] = result.first; @@ -2718,6 +2812,7 @@ void QGraphicsAnchorLayoutPrivate::interpolateEdge(AnchorVertex *base, AnchorDat interpolationProgress[orientation]); qreal edgeDistance = interpolate(factor, edge->sizeAtMinimum, edge->sizeAtPreferred, + edge->sizeAtPreferred, edge->sizeAtPreferred, edge->sizeAtMaximum); Q_ASSERT(edge->from == base || edge->to == base); diff --git a/src/gui/graphicsview/qgraphicsanchorlayout_p.h b/src/gui/graphicsview/qgraphicsanchorlayout_p.h index 8d2d691..3be9d41 100644 --- a/src/gui/graphicsview/qgraphicsanchorlayout_p.h +++ b/src/gui/graphicsview/qgraphicsanchorlayout_p.h @@ -123,6 +123,7 @@ struct AnchorData : public QSimplexVariable { AnchorData() : QSimplexVariable(), from(0), to(0), minSize(0), prefSize(0), maxSize(0), + minPrefSize(0), maxPrefSize(0), sizeAtMinimum(0), sizeAtPreferred(0), sizeAtMaximum(0), item(0), graphicsAnchor(0), type(Normal), isLayoutAnchor(false), @@ -153,6 +154,9 @@ struct AnchorData : public QSimplexVariable { qreal prefSize; qreal maxSize; + qreal minPrefSize; + qreal maxPrefSize; + // 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 @@ -371,8 +375,10 @@ public: // // Interval represents which interpolation interval are we operating in. enum Interval { - MinToPreferred = 0, - PreferredToMax + MinimumToMinPreferred = 0, + MinPreferredToPreferred, + PreferredToMaxPreferred, + MaxPreferredToMaximum }; // Several structures internal to the layout are duplicated to handle -- cgit v0.12 From f2eeef396296a3563c006b77c0ce3708d6256bd3 Mon Sep 17 00:00:00 2001 From: "Eduardo M. Fleury" Date: Wed, 18 Nov 2009 17:15:23 -0300 Subject: QGAL: Refactor solvePreferred to support min/maxPrefSize With the addition of min and maxPrefSizeHints, the logic used in the preferred simplex had to be changed. The concept behind it is still the same, we minimize the deviation from each item's preferred size. Previously we would make an special effort to avoid items being shrunk, that's why the "shinker" simplex variables had larger multipliers in the objective function. Now we still have variables with large multipliers and others with small mutlipliers, but rather than differentiating between shrinker and/or grower variables, we classify them as "soft" or "hard". "Soft" variables, or slacks, are those that allow the anchor to change its value up to the minPref or maxPref boundaries, OTOH, "hard" slacks are those that allow the item to go all the way to its minimum or maximum sizes. Naturally, the "hard" slacks get large coeficients in the objective function while the "soft" ones get small ones. Now all the slack variables are restricted in size as to respect the boundaries of each interval: - Minimum to MinimumPreferred, - MinimumPreferred to Preferred, - Preferred to MaximumPreferred and - MaximumPreferred to Maximum With such limits, the SizeHint constraints became redundant in the calculation of preferred sizes so they are no longer used. Additionally, as an optimization, if a given interval is NULL (for instance, MinimumPreferred is equal to Preferred), then the associated slack variable would have its size restricted to zero, therefore it is not created at all. Signed-off-by: Eduardo M. Fleury Reviewed-by: Caio Marcelo de Oliveira Filho --- src/gui/graphicsview/qgraphicsanchorlayout_p.cpp | 93 ++++++++++++++++++------ 1 file changed, 69 insertions(+), 24 deletions(-) diff --git a/src/gui/graphicsview/qgraphicsanchorlayout_p.cpp b/src/gui/graphicsview/qgraphicsanchorlayout_p.cpp index 6d90d3a..2f4ec26 100644 --- a/src/gui/graphicsview/qgraphicsanchorlayout_p.cpp +++ b/src/gui/graphicsview/qgraphicsanchorlayout_p.cpp @@ -2242,7 +2242,7 @@ bool QGraphicsAnchorLayoutPrivate::calculateTrunk(Orientation orientation, const feasible = solveMinMax(allConstraints, path, &min, &max); if (feasible) { - solvePreferred(allConstraints, variables); + solvePreferred(constraints, variables); // Calculate and set the preferred size for the layout, // from the edge sizes that were calculated above. @@ -2291,12 +2291,8 @@ bool QGraphicsAnchorLayoutPrivate::calculateTrunk(Orientation orientation, const bool QGraphicsAnchorLayoutPrivate::calculateNonTrunk(const QList &constraints, const QList &variables) { - QList sizeHintConstraints = constraintsFromSizeHints(variables); - - shiftConstraints(sizeHintConstraints, limit); shiftConstraints(constraints, limit); - - bool feasible = solvePreferred(constraints + sizeHintConstraints, variables); + bool feasible = solvePreferred(constraints, variables); if (feasible) { // Propagate size at preferred to other sizes. Semi-floats always will be @@ -2309,10 +2305,7 @@ bool QGraphicsAnchorLayoutPrivate::calculateNonTrunk(const QList return feasible; } +enum slackType { Grower = -1, Shrinker = 1 }; +static QPair createSlack(QSimplexConstraint *sizeConstraint, + qreal interval, slackType type) +{ + QSimplexVariable *slack = new QSimplexVariable; + sizeConstraint->variables.insert(slack, type); + + QSimplexConstraint *limit = new QSimplexConstraint; + limit->variables.insert(slack, 1.0); + limit->ratio = QSimplexConstraint::LessOrEqual; + limit->constant = interval; + + return qMakePair(slack, limit); +} + bool QGraphicsAnchorLayoutPrivate::solvePreferred(const QList &constraints, const QList &variables) { @@ -2879,7 +2887,8 @@ bool QGraphicsAnchorLayoutPrivate::solvePreferred(const QListisLayoutAnchor) continue; - QSimplexVariable *grower = new QSimplexVariable; - QSimplexVariable *shrinker = new QSimplexVariable; - QSimplexConstraint *c = new QSimplexConstraint; - c->variables.insert(ad, 1.0); - c->variables.insert(shrinker, 1.0); - c->variables.insert(grower, -1.0); - c->constant = ad->prefSize + limit; + // By default, all variables are equal to their preferred size. If they have room to + // grow or shrink, such flexibility will be added by the additional variables below. + QSimplexConstraint *sizeConstraint = new QSimplexConstraint; + preferredConstraints += sizeConstraint; + sizeConstraint->variables.insert(ad, 1.0); + sizeConstraint->constant = ad->prefSize + limit; + + // Can easily shrink + QPair slack; + const qreal softShrinkInterval = ad->prefSize - ad->minPrefSize; + if (softShrinkInterval) { + slack = createSlack(sizeConstraint, softShrinkInterval, Shrinker); + preferredVariables += slack.first; + preferredConstraints += slack.second; + + // Add to objective with ratio == 1 (soft) + objective.variables.insert(slack.first, 1.0); + } - preferredConstraints += c; - preferredVariables += grower; - preferredVariables += shrinker; + // Can easily grow + const qreal softGrowInterval = ad->maxPrefSize - ad->prefSize; + if (softGrowInterval) { + slack = createSlack(sizeConstraint, softGrowInterval, Grower); + preferredVariables += slack.first; + preferredConstraints += slack.second; - objective.variables.insert(grower, 1.0); - objective.variables.insert(shrinker, variables.size()); - } + // Add to objective with ratio == 1 (soft) + objective.variables.insert(slack.first, 1.0); + } + // Can shrink if really necessary + const qreal hardShrinkInterval = ad->minPrefSize - ad->minSize; + if (hardShrinkInterval) { + slack = createSlack(sizeConstraint, hardShrinkInterval, Shrinker); + preferredVariables += slack.first; + preferredConstraints += slack.second; + + // Add to objective with ratio == N (hard) + objective.variables.insert(slack.first, variables.size()); + } + + // Can grow if really necessary + const qreal hardGrowInterval = ad->maxSize - ad->maxPrefSize; + if (hardGrowInterval) { + slack = createSlack(sizeConstraint, hardGrowInterval, Grower); + preferredVariables += slack.first; + preferredConstraints += slack.second; + + // Add to objective with ratio == N (hard) + objective.variables.insert(slack.first, variables.size()); + } + } QSimplex *simplex = new QSimplex; bool feasible = simplex->setConstraints(constraints + preferredConstraints); -- cgit v0.12 From 89e26da4374563c9419da1357a24cf9618d804d6 Mon Sep 17 00:00:00 2001 From: "Eduardo M. Fleury" Date: Thu, 19 Nov 2009 19:35:53 -0300 Subject: QGAL: Remove deprecated assert clauses These assert messages are no longer valid since some anchors can have their size not respected if they are in parallel with the layout and have size equal to "QWIDGETSIZE_MAX". Signed-off-by: Eduardo M. Fleury Reviewed-by: Caio Marcelo de Oliveira Filho --- src/gui/graphicsview/qgraphicsanchorlayout_p.cpp | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/src/gui/graphicsview/qgraphicsanchorlayout_p.cpp b/src/gui/graphicsview/qgraphicsanchorlayout_p.cpp index 2f4ec26..b35ee46 100644 --- a/src/gui/graphicsview/qgraphicsanchorlayout_p.cpp +++ b/src/gui/graphicsview/qgraphicsanchorlayout_p.cpp @@ -478,18 +478,6 @@ static qreal interpolate(const QPair minSize || qAbs(sizeAtMinimum - minSize) < 0.00000001); - Q_ASSERT(sizeAtPreferred > minSize || qAbs(sizeAtPreferred - minSize) < 0.00000001); - Q_ASSERT(sizeAtMaximum > minSize || qAbs(sizeAtMaximum - minSize) < 0.00000001); - - // These may be false if this anchor was in parallel with the layout stucture - // Q_ASSERT(sizeAtMinimum < maxSize || qAbs(sizeAtMinimum - maxSize) < 0.00000001); - // Q_ASSERT(sizeAtPreferred < maxSize || qAbs(sizeAtPreferred - maxSize) < 0.00000001); - // Q_ASSERT(sizeAtMaximum < maxSize || qAbs(sizeAtMaximum - maxSize) < 0.00000001); - // Band here refers if the value is in the Minimum To Preferred // band (the lower band) or the Preferred To Maximum (the upper band). @@ -2844,8 +2832,6 @@ bool QGraphicsAnchorLayoutPrivate::solveMinMax(const QList for (int i = 0; i < variables.size(); ++i) { AnchorData *ad = static_cast(variables.at(i)); ad->sizeAtMinimum = ad->result - limit; - Q_ASSERT(ad->sizeAtMinimum >= ad->minSize || - qAbs(ad->sizeAtMinimum - ad->minSize) < 0.00000001); } // Calculate maximum values @@ -2855,8 +2841,6 @@ bool QGraphicsAnchorLayoutPrivate::solveMinMax(const QList for (int i = 0; i < variables.size(); ++i) { AnchorData *ad = static_cast(variables.at(i)); ad->sizeAtMaximum = ad->result - limit; - // Q_ASSERT(ad->sizeAtMaximum <= ad->maxSize || - // qAbs(ad->sizeAtMaximum - ad->maxSize) < 0.00000001); } } return feasible; -- cgit v0.12 From 9e4cefd82d3c4f67f8f182ed3956f5e92e4356e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan-Arve=20S=C3=A6ther?= Date: Mon, 30 Nov 2009 09:49:01 +0100 Subject: Revert "Compile fix for win32-icc." This reverts commit db5e4496229a776768464d1d3d2e1f8e81bd6ba0. --- src/corelib/kernel/qobject.cpp | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/src/corelib/kernel/qobject.cpp b/src/corelib/kernel/qobject.cpp index 4321c59..30cd011 100644 --- a/src/corelib/kernel/qobject.cpp +++ b/src/corelib/kernel/qobject.cpp @@ -153,15 +153,6 @@ QObjectPrivate::QObjectPrivate(int version) hasGuards = false; } -#ifdef Q_CC_INTEL -/* Workaround for a bug in win32-icc where it seems to inline ~QObjectPrivate too aggressive. - When icc compiles QtGui, it inlines ~QObjectPrivate so that it would generate a call to - ~QObjectData. However, ~QObjectData is not exported from QtCore, so it does not link. - See also QTBUG-5145 for info on how this manifested itself. - */ -# pragma auto_inline(off) -#endif - QObjectPrivate::~QObjectPrivate() { delete static_cast(metaObject); @@ -173,9 +164,6 @@ QObjectPrivate::~QObjectPrivate() delete extraData; #endif } -#ifdef Q_CC_INTEL -# pragma auto_inline(on) -#endif int *QObjectPrivate::setDeleteWatch(QObjectPrivate *d, int *w) { -- cgit v0.12 From e112bc5d2e1eb567aef3077a014a021244ed2ece Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan-Arve=20S=C3=A6ther?= Date: Thu, 3 Dec 2009 10:03:19 +0100 Subject: Rename the global limit to g_offset. It is both a limit and an offset (the offset is dictated by the limit), but in the code is it interpreted as an offset. --- src/gui/graphicsview/qgraphicsanchorlayout_p.cpp | 26 ++++++++++++------------ 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/src/gui/graphicsview/qgraphicsanchorlayout_p.cpp b/src/gui/graphicsview/qgraphicsanchorlayout_p.cpp index b35ee46..b33e228 100644 --- a/src/gui/graphicsview/qgraphicsanchorlayout_p.cpp +++ b/src/gui/graphicsview/qgraphicsanchorlayout_p.cpp @@ -59,7 +59,7 @@ QT_BEGIN_NAMESPACE // they are actually calculated in the interval [0, 2 * limit] // To avoid numerical errors in platforms where we use single precision, // we use a tighter limit for the variables range. -const qreal limit = (sizeof(qreal) == sizeof(double)) ? QWIDGETSIZE_MAX : QWIDGETSIZE_MAX / 32; +const qreal g_offset = (sizeof(qreal) == sizeof(double)) ? QWIDGETSIZE_MAX : QWIDGETSIZE_MAX / 32; QGraphicsAnchorPrivate::QGraphicsAnchorPrivate(int version) : QObjectPrivate(version), layoutPrivate(0), data(0), @@ -2223,7 +2223,7 @@ bool QGraphicsAnchorLayoutPrivate::calculateTrunk(Orientation orientation, const QList sizeHintConstraints = constraintsFromSizeHints(variables); QList allConstraints = constraints + sizeHintConstraints; - shiftConstraints(allConstraints, limit); + shiftConstraints(allConstraints, g_offset); // Solve min and max size hints qreal min, max; @@ -2248,7 +2248,7 @@ bool QGraphicsAnchorLayoutPrivate::calculateTrunk(Orientation orientation, const } qDeleteAll(sizeHintConstraints); - shiftConstraints(constraints, -limit); + shiftConstraints(constraints, -g_offset); } else { // No Simplex is necessary because the path was simplified all the way to a single @@ -2279,7 +2279,7 @@ bool QGraphicsAnchorLayoutPrivate::calculateTrunk(Orientation orientation, const bool QGraphicsAnchorLayoutPrivate::calculateNonTrunk(const QList &constraints, const QList &variables) { - shiftConstraints(constraints, limit); + shiftConstraints(constraints, g_offset); bool feasible = solvePreferred(constraints, variables); if (feasible) { @@ -2293,7 +2293,7 @@ bool QGraphicsAnchorLayoutPrivate::calculateNonTrunk(const QList QGraphicsAnchorLayoutPrivate::constraintsFromSizeHin // To use negative variables inside simplex, we shift them so the minimum negative value is // mapped to zero before solving. To make sure that it works, we need to guarantee that the // variables are all inside a certain boundary. - qreal boundedMin = qBound(-limit, ad->minSize, limit); - qreal boundedMax = qBound(-limit, ad->maxSize, limit); + qreal boundedMin = qBound(-g_offset, ad->minSize, g_offset); + qreal boundedMax = qBound(-g_offset, ad->maxSize, g_offset); if ((boundedMin == boundedMax) || qFuzzyCompare(boundedMin, boundedMax)) { QSimplexConstraint *c = new QSimplexConstraint; @@ -2497,7 +2497,7 @@ QList QGraphicsAnchorLayoutPrivate::constraintsFromSizeHin QSimplexConstraint *c = new QSimplexConstraint; c->variables.insert(layoutEdge, 1.0); // The maximum size that the layout can take - c->constant = limit; + c->constant = g_offset; c->ratio = QSimplexConstraint::LessOrEqual; anchorConstraints += c; } @@ -2821,7 +2821,7 @@ bool QGraphicsAnchorLayoutPrivate::solveMinMax(const QList for (iter = path.negatives.constBegin(); iter != path.negatives.constEnd(); ++iter) objective.variables.insert(*iter, -1.0); - const qreal objectiveOffset = (path.positives.count() - path.negatives.count()) * limit; + const qreal objectiveOffset = (path.positives.count() - path.negatives.count()) * g_offset; simplex.setObjective(&objective); // Calculate minimum values @@ -2831,7 +2831,7 @@ bool QGraphicsAnchorLayoutPrivate::solveMinMax(const QList QList variables = getVariables(constraints); for (int i = 0; i < variables.size(); ++i) { AnchorData *ad = static_cast(variables.at(i)); - ad->sizeAtMinimum = ad->result - limit; + ad->sizeAtMinimum = ad->result - g_offset; } // Calculate maximum values @@ -2840,7 +2840,7 @@ bool QGraphicsAnchorLayoutPrivate::solveMinMax(const QList // Save sizeAtMaximum results for (int i = 0; i < variables.size(); ++i) { AnchorData *ad = static_cast(variables.at(i)); - ad->sizeAtMaximum = ad->result - limit; + ad->sizeAtMaximum = ad->result - g_offset; } } return feasible; @@ -2898,7 +2898,7 @@ bool QGraphicsAnchorLayoutPrivate::solvePreferred(const QListvariables.insert(ad, 1.0); - sizeConstraint->constant = ad->prefSize + limit; + sizeConstraint->constant = ad->prefSize + g_offset; // Can easily shrink QPair slack; @@ -2957,7 +2957,7 @@ bool QGraphicsAnchorLayoutPrivate::solvePreferred(const QListsizeAtPreferred = ad->result - limit; + ad->sizeAtPreferred = ad->result - g_offset; } // Make sure we delete the simplex solver -before- we delete the -- cgit v0.12 From 39609930e066f93197d518f33e320b58ae7f618b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan-Arve=20S=C3=A6ther?= Date: Thu, 3 Dec 2009 10:24:20 +0100 Subject: Make lrelease link again with the win32-icc and win32-g++ mkspecs Reviewed-by: Thierry --- tools/linguist/lrelease/lrelease.pro | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/linguist/lrelease/lrelease.pro b/tools/linguist/lrelease/lrelease.pro index b13c03e..6beafa3 100644 --- a/tools/linguist/lrelease/lrelease.pro +++ b/tools/linguist/lrelease/lrelease.pro @@ -16,7 +16,7 @@ include(../../../src/tools/bootstrap/bootstrap.pri) include(../shared/formats.pri) include(../shared/proparser.pri) -win32-msvc*:LIBS += advapi32.lib # for qsettings_win.cpp +win32:LIBS += -ladvapi32 # for qsettings_win.cpp target.path=$$[QT_INSTALL_BINS] INSTALLS += target -- cgit v0.12 From a024829184dcde9b6fdaf5ea884fe7e42efdaf29 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sami=20Meril=C3=A4?= Date: Thu, 3 Dec 2009 12:18:04 +0200 Subject: QS60Style: Always store changed theme palette When style updates its background brush, it updates QApplication's palette with new background. Also member variable m_backgroundBrush is updated. What is NOT updated is the member variable m_themePalette, which should also contain correct updated palette. This change updates m_themePalette and moves palette updations to occur in one place so that in all use-cases the palettes are modified in a unified way. Task-number: QTBUG-6427 Reviewed-by: Alessandro Portale --- src/gui/styles/qs60style.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/gui/styles/qs60style.cpp b/src/gui/styles/qs60style.cpp index dca78ca..5f7ec69 100644 --- a/src/gui/styles/qs60style.cpp +++ b/src/gui/styles/qs60style.cpp @@ -454,9 +454,6 @@ void QS60StylePrivate::setThemePalette(QApplication *app) const Q_UNUSED(app) QPalette widgetPalette = QPalette(Qt::white); setThemePalette(&widgetPalette); - QApplication::setPalette(widgetPalette); //calling QApplication::setPalette clears palette hash - setThemePaletteHash(&widgetPalette); - storeThemePalette(&widgetPalette); } QPalette* QS60StylePrivate::themePalette() @@ -470,8 +467,6 @@ void QS60StylePrivate::setBackgroundTexture(QApplication *app) const QPalette applicationPalette = QApplication::palette(); applicationPalette.setBrush(QPalette::Window, backgroundTexture()); setThemePalette(&applicationPalette); - QApplication::setPalette(applicationPalette); - setThemePaletteHash(&applicationPalette); } void QS60StylePrivate::deleteBackground() @@ -687,6 +682,10 @@ void QS60StylePrivate::setThemePalette(QPalette *palette) const palette->setColor(QPalette::Midlight, palette->color(QPalette::Button).lighter(125)); palette->setColor(QPalette::Mid, palette->color(QPalette::Button).darker(150)); palette->setColor(QPalette::Shadow, Qt::black); + + QApplication::setPalette(*palette); //calling QApplication::setPalette clears palette hash + setThemePaletteHash(palette); + storeThemePalette(palette); } void QS60StylePrivate::deleteThemePalette() -- cgit v0.12 From d672687a3dc79d3b59887986cf4d64cf339d7981 Mon Sep 17 00:00:00 2001 From: Jouni Hiltunen Date: Tue, 24 Nov 2009 16:11:57 +0200 Subject: Unnecessary symbian version checks in sqldrivers.pro Version checks in sqldrivers.pro are not needed. These version checks also fail if symbian version does not match to 3.1 3.2 or 5.0. The included sqlite_symbian.pro checks if the binaries are already present or not. Reviewed-By: Shane Kearns --- src/plugins/sqldrivers/sqldrivers.pro | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/plugins/sqldrivers/sqldrivers.pro b/src/plugins/sqldrivers/sqldrivers.pro index 2bd5f2c..83d71e4 100644 --- a/src/plugins/sqldrivers/sqldrivers.pro +++ b/src/plugins/sqldrivers/sqldrivers.pro @@ -10,6 +10,4 @@ contains(sql-plugins, sqlite) : SUBDIRS += sqlite contains(sql-plugins, sqlite2) : SUBDIRS += sqlite2 contains(sql-plugins, ibase) : SUBDIRS += ibase -contains(S60_VERSION, 3.1)|contains(S60_VERSION, 3.2)|contains(S60_VERSION, 5.0) { - symbian:contains(CONFIG, system-sqlite): SUBDIRS += sqlite_symbian - } +symbian:contains(CONFIG, system-sqlite): SUBDIRS += sqlite_symbian -- cgit v0.12 From 14c01d35cd132bb1a5e5725877d28d5f75c086ab Mon Sep 17 00:00:00 2001 From: Janne Anttila Date: Thu, 3 Dec 2009 13:50:43 +0200 Subject: Fixed "...QString::QString(const char *)... is deprecated" warning. Task-number: QTBUG-6290 Reviewed-by: TrustMe --- src/gui/kernel/qsoftkeymanager.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/kernel/qsoftkeymanager.cpp b/src/gui/kernel/qsoftkeymanager.cpp index 1acc9b3..30c67f4 100644 --- a/src/gui/kernel/qsoftkeymanager.cpp +++ b/src/gui/kernel/qsoftkeymanager.cpp @@ -246,7 +246,7 @@ void QSoftKeyManagerPrivate::updateSoftKeys_sys(const QList &softkeys) break; } - int command = (softKeyAction->objectName().contains("_q_menuSoftKeyAction")) + int command = (softKeyAction->objectName().contains(QLatin1String("_q_menuSoftKeyAction"))) ? EAknSoftkeyOptions : s60CommandStart + index; -- cgit v0.12 From 43e4e8969942e58ca0ecb3b8ad23ebe32ac4aa44 Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Fri, 4 Dec 2009 11:12:01 +0100 Subject: Fix crash when QGraphicsItem destructor deletes other QGraphicsItem Same fix as e7a10b00be3e4aa197900ecf424e6d44b07248ae Reviewed-by: Alexis --- src/gui/graphicsview/qgraphicsitem.cpp | 4 ++-- tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp | 6 ++++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/gui/graphicsview/qgraphicsitem.cpp b/src/gui/graphicsview/qgraphicsitem.cpp index bb45e7e..b54596b 100644 --- a/src/gui/graphicsview/qgraphicsitem.cpp +++ b/src/gui/graphicsview/qgraphicsitem.cpp @@ -1341,8 +1341,8 @@ QGraphicsItem::~QGraphicsItem() } if (!d_ptr->children.isEmpty()) { - QList oldChildren = d_ptr->children; - qDeleteAll(oldChildren); + while (!d_ptr->children.isEmpty()) + delete d_ptr->children.first(); Q_ASSERT(d_ptr->children.isEmpty()); } diff --git a/tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp b/tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp index 38abc3d..32206db 100644 --- a/tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp +++ b/tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp @@ -1462,6 +1462,7 @@ void tst_QGraphicsScene::focusItemLostFocus() class ClearTestItem : public QGraphicsRectItem { public: + ClearTestItem(QGraphicsItem *parent = 0) : QGraphicsRectItem(parent) {} ~ClearTestItem() { qDeleteAll(items); } QList items; }; @@ -1486,6 +1487,11 @@ void tst_QGraphicsScene::clear() scene.addItem(secondItem); QCOMPARE(scene.items().at(0), firstItem); QCOMPARE(scene.items().at(1), secondItem); + + ClearTestItem *thirdItem = new ClearTestItem(firstItem); + QGraphicsItem *forthItem = new QGraphicsRectItem(firstItem); + thirdItem->items += forthItem; + // must not crash even if firstItem deletes secondItem scene.clear(); QVERIFY(scene.items().isEmpty()); -- cgit v0.12 From a9303804ab9f46c21f6c5592907449876e7e2f89 Mon Sep 17 00:00:00 2001 From: Tom Cooksey Date: Fri, 4 Dec 2009 13:02:18 +0100 Subject: Remove the linux-g++-gles2-experimental mkspec This mkspec has been replaced by linux-g++-maemo. Reviewed-by: Harald Fernengel --- mkspecs/linux-g++-gles2-experimental/qmake.conf | 22 --- .../linux-g++-gles2-experimental/qplatformdefs.h | 166 --------------------- 2 files changed, 188 deletions(-) delete mode 100644 mkspecs/linux-g++-gles2-experimental/qmake.conf delete mode 100644 mkspecs/linux-g++-gles2-experimental/qplatformdefs.h diff --git a/mkspecs/linux-g++-gles2-experimental/qmake.conf b/mkspecs/linux-g++-gles2-experimental/qmake.conf deleted file mode 100644 index 9c28d17..0000000 --- a/mkspecs/linux-g++-gles2-experimental/qmake.conf +++ /dev/null @@ -1,22 +0,0 @@ -# -# Experimental qmake configuration for GLES2 -# - -MAKEFILE_GENERATOR = UNIX -TEMPLATE = app -CONFIG += qt warn_on release incremental link_prl -QT += core gui -QMAKE_INCREMENTAL_STYLE = sublib - -include(../common/g++.conf) - -QMAKE_LFLAGS += -Wl,-rpath-link=/usr/lib - -include(../common/linux.conf) - -QMAKE_LIBS_EGL = -lEGL -QMAKE_LIBS_OPENGL = -lGLESv2 -QMAKE_LIBS_OPENGL_QT = -lGLESv2 -lEGL - - -load(qt_config) diff --git a/mkspecs/linux-g++-gles2-experimental/qplatformdefs.h b/mkspecs/linux-g++-gles2-experimental/qplatformdefs.h deleted file mode 100644 index ecfbc73..0000000 --- a/mkspecs/linux-g++-gles2-experimental/qplatformdefs.h +++ /dev/null @@ -1,166 +0,0 @@ -/**************************************************************************** -** -** 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$ -** -****************************************************************************/ - -#ifndef QPLATFORMDEFS_H -#define QPLATFORMDEFS_H - -// Get Qt defines/settings - -#include "qglobal.h" - -// Set any POSIX/XOPEN defines at the top of this file to turn on specific APIs - -// 1) need to reset default environment if _BSD_SOURCE is defined -// 2) need to specify POSIX thread interfaces explicitly in glibc 2.0 -// 3) it seems older glibc need this to include the X/Open stuff -#ifndef _GNU_SOURCE -# define _GNU_SOURCE -#endif - -#include - - -// We are hot - unistd.h should have turned on the specific APIs we requested - -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#ifndef QT_NO_IPV6IFNAME -#include -#endif - -#ifdef QT_LARGEFILE_SUPPORT -#define QT_STATBUF struct stat64 -#define QT_STATBUF4TSTAT struct stat64 -#define QT_STAT ::stat64 -#define QT_FSTAT ::fstat64 -#define QT_LSTAT ::lstat64 -#define QT_OPEN ::open64 -#define QT_TRUNCATE ::truncate64 -#define QT_FTRUNCATE ::ftruncate64 -#define QT_LSEEK ::lseek64 -#else -#define QT_STATBUF struct stat -#define QT_STATBUF4TSTAT struct stat -#define QT_STAT ::stat -#define QT_FSTAT ::fstat -#define QT_LSTAT ::lstat -#define QT_OPEN ::open -#define QT_TRUNCATE ::truncate -#define QT_FTRUNCATE ::ftruncate -#define QT_LSEEK ::lseek -#endif - -#ifdef QT_LARGEFILE_SUPPORT -#define QT_FOPEN ::fopen64 -#define QT_FSEEK ::fseeko64 -#define QT_FTELL ::ftello64 -#define QT_FGETPOS ::fgetpos64 -#define QT_FSETPOS ::fsetpos64 -#define QT_MMAP ::mmap64 -#define QT_FPOS_T fpos64_t -#define QT_OFF_T off64_t -#else -#define QT_FOPEN ::fopen -#define QT_FSEEK ::fseek -#define QT_FTELL ::ftell -#define QT_FGETPOS ::fgetpos -#define QT_FSETPOS ::fsetpos -#define QT_MMAP ::mmap -#define QT_FPOS_T fpos_t -#define QT_OFF_T long -#endif - -#define QT_STAT_REG S_IFREG -#define QT_STAT_DIR S_IFDIR -#define QT_STAT_MASK S_IFMT -#define QT_STAT_LNK S_IFLNK -#define QT_SOCKET_CONNECT ::connect -#define QT_SOCKET_BIND ::bind -#define QT_FILENO fileno -#define QT_CLOSE ::close -#define QT_READ ::read -#define QT_WRITE ::write -#define QT_ACCESS ::access -#define QT_GETCWD ::getcwd -#define QT_CHDIR ::chdir -#define QT_MKDIR ::mkdir -#define QT_RMDIR ::rmdir -#define QT_OPEN_LARGEFILE O_LARGEFILE -#define QT_OPEN_RDONLY O_RDONLY -#define QT_OPEN_WRONLY O_WRONLY -#define QT_OPEN_RDWR O_RDWR -#define QT_OPEN_CREAT O_CREAT -#define QT_OPEN_TRUNC O_TRUNC -#define QT_OPEN_APPEND O_APPEND - -#define QT_SIGNAL_RETTYPE void -#define QT_SIGNAL_ARGS int -#define QT_SIGNAL_IGNORE SIG_IGN - -#if defined(__GLIBC__) && (__GLIBC__ >= 2) -#define QT_SOCKLEN_T socklen_t -#else -#define QT_SOCKLEN_T int -#endif - -#if defined(_XOPEN_SOURCE) && (_XOPEN_SOURCE >= 500) -#define QT_SNPRINTF ::snprintf -#define QT_VSNPRINTF ::vsnprintf -#endif - - -#endif // QPLATFORMDEFS_H -- cgit v0.12 From 9a76f02a3147c2da969cb1b942ee7228b13c84cc Mon Sep 17 00:00:00 2001 From: Tom Cooksey Date: Fri, 4 Dec 2009 13:03:21 +0100 Subject: Add QMake configuration for Scratchbox's host-gcc compilera Reviewed-by: Harald Fernengel --- mkspecs/unsupported/linux-host-g++/qmake.conf | 138 +++++++++++++++++++++ mkspecs/unsupported/linux-host-g++/qplatformdefs.h | 42 +++++++ 2 files changed, 180 insertions(+) create mode 100644 mkspecs/unsupported/linux-host-g++/qmake.conf create mode 100644 mkspecs/unsupported/linux-host-g++/qplatformdefs.h diff --git a/mkspecs/unsupported/linux-host-g++/qmake.conf b/mkspecs/unsupported/linux-host-g++/qmake.conf new file mode 100644 index 0000000..237477c --- /dev/null +++ b/mkspecs/unsupported/linux-host-g++/qmake.conf @@ -0,0 +1,138 @@ +# +# QMake configuration for Scratchbox's host-gcc compiler. +# +# This mkspec can be used as the platform mkspec when building +# Qt in scratchbox. If used as such, qmake and similar host +# tools will be compiled for the host architecture (E.g. x86) +# and thus not run in the emulator. This results in a +# significant improvement in build times. +# +# Note: The mkspec copied & pasted parts from common/gcc.conf +# and common/linux.conf as setBootstrapVariable in +# configure has a bug which stops re-assignments working +# for QMake variables (I.e. "QMAKE_foo = bar" is broken). + +MAKEFILE_GENERATOR = UNIX +TEMPLATE = app +CONFIG += qt warn_on release incremental link_prl +QT += core gui +QMAKE_INCREMENTAL_STYLE = sublib + +# +# qmake configuration for common gcc +# + +QMAKE_CC = host-gcc +QMAKE_CFLAGS += -pipe +QMAKE_CFLAGS_DEPS += -M +QMAKE_CFLAGS_WARN_ON += -Wall -W +QMAKE_CFLAGS_WARN_OFF += -w +QMAKE_CFLAGS_RELEASE += -O2 +QMAKE_CFLAGS_DEBUG += -g +QMAKE_CFLAGS_SHLIB += -fPIC +QMAKE_CFLAGS_STATIC_LIB += -fPIC +QMAKE_CFLAGS_YACC += -Wno-unused -Wno-parentheses +QMAKE_CFLAGS_HIDESYMS += -fvisibility=hidden +QMAKE_CFLAGS_PRECOMPILE += -x c-header -c ${QMAKE_PCH_INPUT} -o ${QMAKE_PCH_OUTPUT} +QMAKE_CFLAGS_USE_PRECOMPILE += -include ${QMAKE_PCH_OUTPUT_BASE} + +QMAKE_CXX = host-g++ +QMAKE_CXXFLAGS += $$QMAKE_CFLAGS +QMAKE_CXXFLAGS_DEPS += $$QMAKE_CFLAGS_DEPS +QMAKE_CXXFLAGS_WARN_ON += $$QMAKE_CFLAGS_WARN_ON +QMAKE_CXXFLAGS_WARN_OFF += $$QMAKE_CFLAGS_WARN_OFF +QMAKE_CXXFLAGS_RELEASE += $$QMAKE_CFLAGS_RELEASE +QMAKE_CXXFLAGS_DEBUG += $$QMAKE_CFLAGS_DEBUG +QMAKE_CXXFLAGS_SHLIB += $$QMAKE_CFLAGS_SHLIB +QMAKE_CXXFLAGS_STATIC_LIB += $$QMAKE_CFLAGS_STATIC_LIB +QMAKE_CXXFLAGS_YACC += $$QMAKE_CFLAGS_YACC +QMAKE_CXXFLAGS_HIDESYMS += $$QMAKE_CFLAGS_HIDESYMS -fvisibility-inlines-hidden +QMAKE_CXXFLAGS_PRECOMPILE += -x c++-header -c ${QMAKE_PCH_INPUT} -o ${QMAKE_PCH_OUTPUT} +QMAKE_CXXFLAGS_USE_PRECOMPILE = $$QMAKE_CFLAGS_USE_PRECOMPILE + +QMAKE_LINK = host-g++ +QMAKE_LINK_SHLIB = host-g++ +QMAKE_LINK_C = host-gcc +QMAKE_LINK_C_SHLIB = host-gcc +QMAKE_LFLAGS += +QMAKE_LFLAGS_RELEASE += -Wl,-O1 +QMAKE_LFLAGS_DEBUG += +QMAKE_LFLAGS_APP += +QMAKE_LFLAGS_SHLIB += -shared +QMAKE_LFLAGS_PLUGIN += $$QMAKE_LFLAGS_SHLIB +QMAKE_LFLAGS_SONAME += -Wl,-soname, +QMAKE_LFLAGS_THREAD += +QMAKE_LFLAGS_NOUNDEF += -Wl,--no-undefined +QMAKE_RPATH = -Wl,-rpath, + +QMAKE_PCH_OUTPUT_EXT = .gch + +# -Bsymbolic-functions (ld) support +QMAKE_LFLAGS_BSYMBOLIC_FUNC = -Wl,-Bsymbolic-functions +QMAKE_LFLAGS_DYNAMIC_LIST = -Wl,--dynamic-list, + +# +# qmake configuration for common linux +# + +QMAKE_CFLAGS_THREAD += -D_REENTRANT +QMAKE_CXXFLAGS_THREAD += $$QMAKE_CFLAGS_THREAD + +QMAKE_INCDIR = +QMAKE_LIBDIR = +QMAKE_INCDIR_X11 = /usr/X11R6/include +QMAKE_LIBDIR_X11 = /usr/X11R6/lib +QMAKE_INCDIR_QT = $$[QT_INSTALL_HEADERS] +QMAKE_LIBDIR_QT = $$[QT_INSTALL_LIBS] +QMAKE_INCDIR_OPENGL = /usr/X11R6/include +QMAKE_LIBDIR_OPENGL = /usr/X11R6/lib +QMAKE_INCDIR_OPENGL_ES1 = $$QMAKE_INCDIR_OPENGL +QMAKE_LIBDIR_OPENGL_ES1 = $$QMAKE_LIBDIR_OPENGL +QMAKE_INCDIR_OPENGL_ES1CL = $$QMAKE_INCDIR_OPENGL +QMAKE_LIBDIR_OPENGL_ES1CL = $$QMAKE_LIBDIR_OPENGL +QMAKE_INCDIR_OPENGL_ES2 = $$QMAKE_INCDIR_OPENGL +QMAKE_LIBDIR_OPENGL_ES2 = $$QMAKE_LIBDIR_OPENGL +QMAKE_INCDIR_EGL = +QMAKE_LIBDIR_EGL = +QMAKE_INCDIR_OPENVG = +QMAKE_LIBDIR_OPENVG = + +QMAKE_LIBS = +QMAKE_LIBS_DYNLOAD = -ldl +QMAKE_LIBS_X11 = -lXext -lX11 -lm +QMAKE_LIBS_X11SM = -lSM -lICE +QMAKE_LIBS_NIS = -lnsl +QMAKE_LIBS_EGL = -lEGL +QMAKE_LIBS_OPENGL = -lGLU -lGL +QMAKE_LIBS_OPENGL_QT = -lGL +QMAKE_LIBS_OPENGL_ES1 = -lGLES_CM +QMAKE_LIBS_OPENGL_ES1CL = -lGLES_CL +QMAKE_LIBS_OPENGL_ES2 = -lGLESv2 +QMAKE_LIBS_OPENVG = -lOpenVG +QMAKE_LIBS_THREAD = -lpthread + +QMAKE_MOC = $$[QT_INSTALL_BINS]/moc +QMAKE_UIC = $$[QT_INSTALL_BINS]/uic + +QMAKE_AR = host-ar cqs +QMAKE_OBJCOPY = host-objcopy +QMAKE_RANLIB = + +QMAKE_TAR = tar -cf +QMAKE_GZIP = gzip -9f + +QMAKE_COPY = cp -f +QMAKE_COPY_FILE = $(COPY) +QMAKE_COPY_DIR = $(COPY) -r +QMAKE_MOVE = mv -f +QMAKE_DEL_FILE = rm -f +QMAKE_DEL_DIR = rmdir +QMAKE_STRIP = host-strip +QMAKE_STRIPFLAGS_LIB += --strip-unneeded +QMAKE_CHK_DIR_EXISTS = test -d +QMAKE_MKDIR = mkdir -p +QMAKE_INSTALL_FILE = install -m 644 -p +QMAKE_INSTALL_PROGRAM = install -m 755 -p + +include(../common/unix.conf) +load(qt_config) diff --git a/mkspecs/unsupported/linux-host-g++/qplatformdefs.h b/mkspecs/unsupported/linux-host-g++/qplatformdefs.h new file mode 100644 index 0000000..60e0f5e --- /dev/null +++ b/mkspecs/unsupported/linux-host-g++/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 62fac968df5fb3632e458aeacfe5a8ef5cfd32bf Mon Sep 17 00:00:00 2001 From: Janne Anttila Date: Fri, 4 Dec 2009 14:23:24 +0200 Subject: Switched S60 QDesktopServices implementation to CDocumentHandler based. RApaLsSession based implementation did not succeed to start music player in some S60 devices to playing mode. The only found solution to this problem was to start using CDocumentHandler based implementation. CDocumentHandler adds a new S60 dependency, but it is needed to make QDesktopServices APIs fully fuonctional. However if Qt is comfigured without S60 we still fallback to RApaLsSession implementation. With CDocumentHandler the files are also opened as embedded, due to the fact that swicthing files in stand-alone mode would require SwEvent capability. Task-number: QTBUG-4699 Reviewed-by: Miikka Heikkinen --- src/gui/util/qdesktopservices_s60.cpp | 72 +++++++++++++++------- .../auto/qdesktopservices/tst_qdesktopservices.cpp | 16 ++++- 2 files changed, 64 insertions(+), 24 deletions(-) diff --git a/src/gui/util/qdesktopservices_s60.cpp b/src/gui/util/qdesktopservices_s60.cpp index 1890d56..c6932de 100644 --- a/src/gui/util/qdesktopservices_s60.cpp +++ b/src/gui/util/qdesktopservices_s60.cpp @@ -41,7 +41,7 @@ // This flag changes the implementation to use S60 CDcoumentHandler // instead of apparch when opening the files -#undef USE_DOCUMENTHANDLER +#define USE_DOCUMENTHANDLER #include #include @@ -58,12 +58,14 @@ #include // RSendAsMessage #ifdef Q_WS_S60 -# include // PathInfo +# include // PathInfo # ifdef USE_DOCUMENTHANDLER -# include // CDocumentHandler +# include // CDocumentHandler +# include # endif -#elif defined(USE_DOCUMENTHANDLER) -# error CDocumentHandler requires support for S60 +#else +# warning CDocumentHandler requires support for S60 +# undef USE_DOCUMENTHANDLER // Fallback to RApaLsSession based implementation #endif QT_BEGIN_NAMESPACE @@ -95,6 +97,42 @@ private: R* mPtr; }; +#ifdef USE_DOCUMENTHANDLER +class QS60DocumentHandler : public MAknServerAppExitObserver +{ +public: + QS60DocumentHandler() :docHandler(0) {} + + ~QS60DocumentHandler() { + delete docHandler; + } + + CDocumentHandler& documentHandler() { + // In case user calls openUrl twice subsequently, before the first embedded app is closed + // we use the same CDocumentHandler instance. Using same instance makes sure the first + // launched embedded app is closed and latter one gets embedded to our app. + // Using different instance would help only theoretically since user cannot interact with + // several embedded apps at the same time. + if(!docHandler) { + QT_TRAP_THROWING(docHandler = CDocumentHandler::NewL()); + docHandler->SetExitObserver(this); + } + return *docHandler; + } + +private: // From MAknServerAppExitObserver + void HandleServerAppExit(TInt /*aReason*/) { + delete docHandler; + docHandler = 0; + } + +private: + CDocumentHandler* docHandler; +}; +Q_GLOBAL_STATIC(QS60DocumentHandler, qt_s60_documenthandler); +#endif + + static void handleMailtoSchemeLX(const QUrl &url) { // this function has many intermingled leaves and throws. Qt and Symbian objects do not have @@ -264,21 +302,9 @@ static void openDocumentL(const TDesC& aUrl) CleanupStack::PopAndDestroy(); // appArcSession #else // This is an alternative way to launch app associated to MIME type - // CDocumentHandler would support opening apps in embedded mode, - // but our Qt application window group seems to always get switched on top of embedded one - // -> Cannot use menus etc of embedded app -> used - - CDocumentHandler* docHandler = CDocumentHandler::NewLC(); + // CDocumentHandler also supports opening apps in embedded mode. TDataType temp; - //Standalone file opening fails for some file-types at least in S60 3.1 emulator - //For example .txt file fails with KErrAlreadyInUse and music files with KERN-EXEC 0 - //Workaround is to use OpenFileEmbeddedL - //docHandler->OpenFileL(aUrl, temp); - - // Opening file with CDocumentHandler will leave if file does not exist - // Leave is trapped in openDocument and false returned to user. - docHandler->OpenFileEmbeddedL(aUrl, temp); - CleanupStack::PopAndDestroy(docHandler); + qt_s60_documenthandler()->documentHandler().OpenFileEmbeddedL(aUrl, temp); #endif } @@ -349,7 +375,7 @@ QString QDesktopServices::storageLocation(StandardLocation type) case DesktopLocation: qWarning("No desktop concept in Symbian OS"); // But lets still use some feasible default - path.Append(writableDataRoot()); + path.Append(writableDataRoot()); break; case DocumentsLocation: path.Append(writableDataRoot()); @@ -380,7 +406,7 @@ QString QDesktopServices::storageLocation(StandardLocation type) #endif break; case TempLocation: - return QDir::tempPath(); + return QDir::tempPath(); break; case HomeLocation: path.Append(writableDataRoot()); @@ -394,10 +420,10 @@ QString QDesktopServices::storageLocation(StandardLocation type) CEikonEnv::Static()->FsSession().PrivatePath(path); path.Insert(0, writableExeDrive().Name()); path.Append(KCacheSubDir); - break; + break; default: // Lets use feasible default - path.Append(writableDataRoot()); + path.Append(writableDataRoot()); break; } diff --git a/tests/auto/qdesktopservices/tst_qdesktopservices.cpp b/tests/auto/qdesktopservices/tst_qdesktopservices.cpp index 2d9e5dc..c105a97 100644 --- a/tests/auto/qdesktopservices/tst_qdesktopservices.cpp +++ b/tests/auto/qdesktopservices/tst_qdesktopservices.cpp @@ -70,6 +70,7 @@ private slots: void openMailtoUrl(); void openFileUrl_data(); void openFileUrl(); + void openMultipleFileUrls(); #endif void handlers(); void storageLocation_data(); @@ -197,6 +198,7 @@ void tst_qdesktopservices::openMailtoUrl() QFETCH(QUrl, url); QFETCH(bool, result); QCOMPARE(QDesktopServices::openUrl(url), result); + QTest::qWait(5000); } void tst_qdesktopservices::openFileUrl_data() @@ -239,7 +241,19 @@ void tst_qdesktopservices::openFileUrl() QFETCH(QUrl, url); QFETCH(bool, result); QCOMPARE(QDesktopServices::openUrl(url), result); - QTest::qWait(15000); + QTest::qWait(5000); +} + +void tst_qdesktopservices::openMultipleFileUrls() +{ +#ifndef RUN_MANUAL_TESTS + QSKIP("Test disabled -- only for manual purposes", SkipAll); +#endif + + QCOMPARE(QDesktopServices::openUrl(QUrl("file:///c:/data/images/image.bmp")), true); + QCOMPARE(QDesktopServices::openUrl(QUrl("file:///c:/data/images/image.png")), true); + QCOMPARE(QDesktopServices::openUrl(QUrl("file:///c:/data/others/noendofline.txt")), true); + QCOMPARE(QDesktopServices::openUrl(QUrl("file:///c:/data/installs/ErrRd.sisx")), true); } #endif -- cgit v0.12 From fe785ec5fa818b3b31777d22b434621522a532b4 Mon Sep 17 00:00:00 2001 From: Miikka Heikkinen Date: Fri, 4 Dec 2009 15:07:41 +0200 Subject: MMP_RULES overriding qmake variables now warns user Added warning to qmake when it detects MMP_RULES that override MMP statements created by qmake variables. Also harmonized the way << operator is used with #defined strings in symmake.cpp. Task-number: QTBUG-5407 Reviewed-by: Janne Anttila --- qmake/generators/symbian/symmake.cpp | 152 ++++++++++++++++++++++++----------- qmake/generators/symbian/symmake.h | 9 ++- 2 files changed, 111 insertions(+), 50 deletions(-) diff --git a/qmake/generators/symbian/symmake.cpp b/qmake/generators/symbian/symmake.cpp index afaf338..8379ed9 100644 --- a/qmake/generators/symbian/symmake.cpp +++ b/qmake/generators/symbian/symmake.cpp @@ -77,6 +77,15 @@ #define MMP_LINKEROPTION_CW "LINKEROPTION CW" #define MMP_LINKEROPTION_ARMCC "LINKEROPTION ARMCC" #define MMP_LINKEROPTION_GCCE "LINKEROPTION GCCE" +#define MMP_CAPABILITY "CAPABILITY" +#define MMP_EPOCALLOWDLLDATA "EPOCALLOWDLLDATA" +#define MMP_EPOCHEAPSIZE "EPOCHEAPSIZE" +#define MMP_EPOCSTACKSIZE "EPOCSTACKSIZE" +#define MMP_UID "UID" +#define MMP_VENDORID "VENDORID" +#define MMP_VERSION "VERSION" +#define MMP_START_RESOURCE "START RESOURCE" +#define MMP_END_RESOURCE "END" #define SIS_TARGET "sis" #define OK_SIS_TARGET "ok_sis" @@ -155,7 +164,7 @@ void SymbianMakefileGenerator::writeHeader(QTextStream &t) { t << "// ============================================================================" << endl; t << "// * Makefile for building: " << escapeFilePath(var("TARGET")) << endl; - t << "// * Generated by qmake (" << qmake_version() << ") (Qt " << QT_VERSION_STR << ") on: "; + t << "// * Generated by qmake (" << qmake_version() << ") (Qt " QT_VERSION_STR ") on: "; t << QDateTime::currentDateTime().toString(Qt::ISODate) << endl; t << "// * This file is generated by qmake and should not be modified by the" << endl; t << "// * user." << endl; @@ -444,7 +453,7 @@ void SymbianMakefileGenerator::writeCustomDefFile() QTextStream t(&ft); t << "; ==============================================================================" << endl; - t << "; Generated by qmake (" << qmake_version() << ") (Qt " << QT_VERSION_STR << ") on: "; + t << "; Generated by qmake (" << qmake_version() << ") (Qt " QT_VERSION_STR ") on: "; t << QDateTime::currentDateTime().toString(Qt::ISODate) << endl; t << "; This file is generated by qmake and should not be modified by the" << endl; t << "; user." << endl; @@ -646,30 +655,76 @@ void SymbianMakefileGenerator::initMmpVariables() // Check MMP_RULES for singleton keywords that are overridden QStringList overridableMmpKeywords; + QStringList restrictableMmpKeywords; + QStringList restrictedMmpKeywords; + bool inResourceBlock = false; + overridableMmpKeywords << QLatin1String(MMP_TARGETTYPE); + restrictableMmpKeywords << QLatin1String(MMP_TARGET) << QLatin1String(MMP_SECUREID) + << QLatin1String(MMP_OPTION_CW) << QLatin1String(MMP_OPTION_ARMCC) + << QLatin1String(MMP_OPTION_GCCE) << QLatin1String(MMP_LINKEROPTION_CW) + << QLatin1String(MMP_LINKEROPTION_ARMCC) << QLatin1String(MMP_LINKEROPTION_GCCE) + << QLatin1String(MMP_CAPABILITY) << QLatin1String(MMP_EPOCALLOWDLLDATA) + << QLatin1String(MMP_EPOCHEAPSIZE) << QLatin1String(MMP_EPOCSTACKSIZE) + << QLatin1String(MMP_UID) << QLatin1String(MMP_VENDORID) + << QLatin1String(MMP_VERSION); foreach (QString item, project->values("MMP_RULES")) { if (project->values(item).isEmpty()) { - checkOverridability(overridableMmpKeywords, item); + handleMmpRulesOverrides(item, inResourceBlock, restrictedMmpKeywords, + restrictableMmpKeywords, overridableMmpKeywords); } else { foreach (QString itemRow, project->values(item)) { - checkOverridability(overridableMmpKeywords, itemRow); + handleMmpRulesOverrides(itemRow, inResourceBlock, restrictedMmpKeywords, + restrictableMmpKeywords, overridableMmpKeywords); } } } + + if (restrictedMmpKeywords.size()) { + fprintf(stderr, "Warning: Restricted statements detected in MMP_RULES:\n" + " (%s)\n" + " Use corresponding qmake variable(s) instead.\n", + qPrintable(restrictedMmpKeywords.join(", "))); + } } -void SymbianMakefileGenerator::checkOverridability(QStringList &overridableKeywords, QString &checkString) +void SymbianMakefileGenerator::handleMmpRulesOverrides(QString &checkString, + bool &inResourceBlock, + QStringList &restrictedMmpKeywords, + const QStringList &restrictableMmpKeywords, + const QStringList &overridableMmpKeywords) { - // Check if checkString contains overridable keyword and - // add the keyword to overridden keywords list if so. QString simplifiedString = checkString.simplified(); - foreach (QString item, overridableKeywords) { - if (simplifiedString.startsWith(item)) - appendIfnotExist(overriddenMmpKeywords, item); + + if (!inResourceBlock && simplifiedString.startsWith(MMP_START_RESOURCE, Qt::CaseInsensitive)) + inResourceBlock = true; + else if (inResourceBlock && simplifiedString.startsWith(MMP_END_RESOURCE, Qt::CaseInsensitive)) + inResourceBlock = false; + + // Allow restricted and overridable items in RESOURCE blocks as those do not actually + // override anything. + if (!inResourceBlock) { + appendKeywordIfMatchFound(overriddenMmpKeywords, overridableMmpKeywords, simplifiedString); + appendKeywordIfMatchFound(restrictedMmpKeywords, restrictableMmpKeywords, simplifiedString); + } +} + +void SymbianMakefileGenerator::appendKeywordIfMatchFound(QStringList &list, + const QStringList &keywordList, + QString &checkString) +{ + // Check if checkString starts with any supplied keyword and + // add the found keyword to list if it does. + foreach (QString item, keywordList) { + if (checkString.startsWith(QString(item).append(" "), Qt::CaseInsensitive) + || checkString.compare(item, Qt::CaseInsensitive) == 0) { + appendIfnotExist(list, item); + } } } + bool SymbianMakefileGenerator::removeDuplicatedStrings(QStringList &stringList) { QStringList tmpStringList; @@ -690,7 +745,7 @@ bool SymbianMakefileGenerator::removeDuplicatedStrings(QStringList &stringList) void SymbianMakefileGenerator::writeMmpFileHeader(QTextStream &t) { t << "// ==============================================================================" << endl; - t << "// Generated by qmake (" << qmake_version() << ") (Qt " << QT_VERSION_STR << ") on: "; + t << "// Generated by qmake (" << qmake_version() << ") (Qt " QT_VERSION_STR ") on: "; t << QDateTime::currentDateTime().toString(Qt::ISODate) << endl; t << "// This file is generated by qmake and should not be modified by the" << endl; t << "// user." << endl; @@ -775,7 +830,7 @@ void SymbianMakefileGenerator::writeMmpFileMacrosPart(QTextStream& t) void SymbianMakefileGenerator::addMacro(QTextStream& t, const QString& value) { - t << "MACRO" << "\t\t" << value << endl; + t << "MACRO\t\t" << value << endl; } @@ -784,28 +839,28 @@ void SymbianMakefileGenerator::writeMmpFileTargetPart(QTextStream& t) bool skipTargetType = overriddenMmpKeywords.contains(MMP_TARGETTYPE); if (targetType == TypeExe) { - t << MMP_TARGET << "\t\t" << fixedTarget << ".exe" << endl; + t << MMP_TARGET "\t\t" << fixedTarget << ".exe" << endl; if (!skipTargetType) { if (project->values("CONFIG").contains("stdbinary", Qt::CaseInsensitive)) - t << MMP_TARGETTYPE << "\t\t" << "STDEXE" << endl; + t << MMP_TARGETTYPE "\t\tSTDEXE" << endl; else - t << MMP_TARGETTYPE << "\t\t" << "EXE" << endl; + t << MMP_TARGETTYPE "\t\tEXE" << endl; } } else if (targetType == TypeDll || targetType == TypePlugin) { - t << MMP_TARGET << "\t\t" << fixedTarget << ".dll" << endl; + t << MMP_TARGET "\t\t" << fixedTarget << ".dll" << endl; if (!skipTargetType) { if (project->values("CONFIG").contains("stdbinary", Qt::CaseInsensitive)) - t << MMP_TARGETTYPE << "\t\t" << "STDDLL" << endl; + t << MMP_TARGETTYPE "\t\tSTDDLL" << endl; else - t << MMP_TARGETTYPE << "\t\t" << "DLL" << endl; + t << MMP_TARGETTYPE "\t\tDLL" << endl; } } else if (targetType == TypeLib) { - t << MMP_TARGET << "\t\t" << fixedTarget << ".lib" << endl; + t << MMP_TARGET "\t\t" << fixedTarget << ".lib" << endl; if (!skipTargetType) { if (project->values("CONFIG").contains("stdbinary", Qt::CaseInsensitive)) - t << MMP_TARGETTYPE << "\t\t" << "STDLIB" << endl; + t << MMP_TARGETTYPE "\t\tSTDLIB" << endl; else - t << MMP_TARGETTYPE << "\t\t" << "LIB" << endl; + t << MMP_TARGETTYPE "\t\tLIB" << endl; } } else { fprintf(stderr, "Error: Unexpected targettype (%d) in SymbianMakefileGenerator::writeMmpFileTargetPart\n", targetType); @@ -813,30 +868,30 @@ void SymbianMakefileGenerator::writeMmpFileTargetPart(QTextStream& t) t << endl; - t << "UID" << "\t\t" << uid2 << " " << uid3 << endl; + t << MMP_UID "\t\t" << uid2 << " " << uid3 << endl; if (0 != project->values("TARGET.SID").size()) { - t << MMP_SECUREID << "\t\t" << project->values("TARGET.SID").join(" ") << endl; + t << MMP_SECUREID "\t\t" << project->values("TARGET.SID").join(" ") << endl; } else { if (0 == uid3.size()) - t << MMP_SECUREID << "\t\t" << "0" << endl; + t << MMP_SECUREID "\t\t0" << endl; else - t << MMP_SECUREID << "\t\t" << uid3 << endl; + t << MMP_SECUREID "\t\t" << uid3 << endl; } // default value used from mkspecs is 0 if (0 != project->values("TARGET.VID").size()) { - t << "VENDORID" << "\t\t" << project->values("TARGET.VID").join(" ") << endl; + t << MMP_VENDORID "\t\t" << project->values("TARGET.VID").join(" ") << endl; } t << endl; if (0 != project->first("TARGET.EPOCSTACKSIZE").size()) - t << "EPOCSTACKSIZE" << "\t\t" << project->first("TARGET.EPOCSTACKSIZE") << endl; + t << MMP_EPOCSTACKSIZE "\t\t" << project->first("TARGET.EPOCSTACKSIZE") << endl; if (0 != project->values("TARGET.EPOCHEAPSIZE").size()) - t << "EPOCHEAPSIZE" << "\t\t" << project->values("TARGET.EPOCHEAPSIZE").join(" ") << endl; + t << MMP_EPOCHEAPSIZE "\t\t" << project->values("TARGET.EPOCHEAPSIZE").join(" ") << endl; if (0 != project->values("TARGET.EPOCALLOWDLLDATA").size()) - t << "EPOCALLOWDLLDATA" << endl; + t << MMP_EPOCALLOWDLLDATA << endl; if (targetType == TypePlugin && !project->values("CONFIG").contains("stdbinary", Qt::CaseInsensitive)) { // Use custom def file for Qt plugins @@ -865,20 +920,20 @@ void SymbianMakefileGenerator::writeMmpFileResourcePart(QTextStream& t, QStringL t << lang << " "; // no endl } t << endl; - t << "START RESOURCE\t\t" << locTarget << endl; + t << MMP_START_RESOURCE "\t\t" << locTarget << endl; t << "HEADER" << endl; t << "TARGETPATH\t\t\t" RESOURCE_DIRECTORY_MMP << endl; - t << "END" << endl << endl; + t << MMP_END_RESOURCE << endl << endl; QString regTarget = fixedTarget; regTarget.append("_reg.rss"); t << "SOURCEPATH\t\t\t." << endl; - t << "START RESOURCE\t\t" << regTarget << endl; + t << MMP_START_RESOURCE "\t\t" << regTarget << endl; if (isForSymbianSbsv2()) t << "DEPENDS " << fixedTarget << ".rsg" << endl; t << "TARGETPATH\t\t" REGISTRATION_RESOURCE_DIRECTORY_HW << endl; - t << "END" << endl << endl; + t << MMP_END_RESOURCE << endl << endl; } } @@ -890,7 +945,7 @@ void SymbianMakefileGenerator::writeMmpFileSystemIncludePart(QTextStream& t) QStringList values = it.value(); for (int i = 0; i < values.size(); ++i) { QString handledPath = values.at(i); - t << "SYSTEMINCLUDE" << "\t\t" << fixPathForMmp(handledPath, current) << endl; + t << "SYSTEMINCLUDE\t\t" << fixPathForMmp(handledPath, current) << endl; } } @@ -946,14 +1001,14 @@ void SymbianMakefileGenerator::writeMmpFileCapabilityPart(QTextStream& t) { if (0 != project->first("TARGET.CAPABILITY").size()) { QStringList &capabilities = project->values("TARGET.CAPABILITY"); - t << "CAPABILITY" << "\t\t"; + t << MMP_CAPABILITY "\t\t"; for (int i = 0; i < capabilities.size(); ++i) { QString cap = capabilities.at(i); t << cap << " "; } } else { - t << "CAPABILITY" << "\t\t" << "None"; + t << MMP_CAPABILITY "\t\tNone"; } t << endl << endl; } @@ -1048,21 +1103,21 @@ void SymbianMakefileGenerator::writeMmpFileCompilerOptionPart(QTextStream& t) if (!gccelink.isEmpty() && gccelink[gccelink.size()-1] == ' ') gccelink.chop(1); - if (!cw.isEmpty() && !overriddenMmpKeywords.contains(MMP_OPTION_CW)) + if (!cw.isEmpty()) t << MMP_OPTION_CW " " << cw << endl; - if (!armcc.isEmpty() && !overriddenMmpKeywords.contains(MMP_OPTION_ARMCC)) + if (!armcc.isEmpty()) t << MMP_OPTION_ARMCC " " << armcc << endl; - if (!gcce.isEmpty() && !overriddenMmpKeywords.contains(MMP_OPTION_GCCE)) + if (!gcce.isEmpty()) t << MMP_OPTION_GCCE " " << gcce << endl; - if (!cwlink.isEmpty() && !overriddenMmpKeywords.contains(MMP_LINKEROPTION_CW)) + if (!cwlink.isEmpty()) t << MMP_LINKEROPTION_CW " " << cwlink << endl; - if (!armlink.isEmpty() && !overriddenMmpKeywords.contains(MMP_LINKEROPTION_ARMCC)) + if (!armlink.isEmpty()) t << MMP_LINKEROPTION_ARMCC " " << armlink << endl; - if (!gccelink.isEmpty() && !overriddenMmpKeywords.contains(MMP_LINKEROPTION_GCCE)) + if (!gccelink.isEmpty()) t << MMP_LINKEROPTION_GCCE " " << gccelink << endl; - t << endl; + t << endl; } void SymbianMakefileGenerator::writeMmpFileBinaryVersionPart(QTextStream& t) @@ -1098,7 +1153,7 @@ void SymbianMakefileGenerator::writeMmpFileBinaryVersionPart(QTextStream& t) mmpVersion = "10.0"; // Default binary version for symbian is 10.0 } - t << "VERSION " << mmpVersion << endl; + t << MMP_VERSION " " << mmpVersion << endl; } void SymbianMakefileGenerator::writeMmpFileRulesPart(QTextStream& t) @@ -1265,7 +1320,7 @@ void SymbianMakefileGenerator::writeRegRssFile(QStringList &userItems) generatedFiles << ft.fileName(); QTextStream t(&ft); t << "// ============================================================================" << endl; - t << "// * Generated by qmake (" << qmake_version() << ") (Qt " << QT_VERSION_STR << ") on: "; + t << "// * Generated by qmake (" << qmake_version() << ") (Qt " QT_VERSION_STR ") on: "; t << QDateTime::currentDateTime().toString(Qt::ISODate) << endl; t << "// * This file is generated by qmake and should not be modified by the" << endl; t << "// * user." << endl; @@ -1274,8 +1329,7 @@ void SymbianMakefileGenerator::writeRegRssFile(QStringList &userItems) t << "#include <" << fixedTarget << ".rsg>" << endl; t << "#include " << endl; t << endl; - //t << "#include " << "\n" << endl; - t << "UID2 " << "KUidAppRegistrationResourceFile" << endl; + t << "UID2 KUidAppRegistrationResourceFile" << endl; t << "UID3 " << uid3 << endl << endl; t << "RESOURCE APP_REGISTRATION_INFO" << endl; t << "\t{" << endl; @@ -1300,7 +1354,7 @@ void SymbianMakefileGenerator::writeRssFile(QString &numberOfIcons, QString &ico generatedFiles << ft.fileName(); QTextStream t(&ft); t << "// ============================================================================" << endl; - t << "// * Generated by qmake (" << qmake_version() << ") (Qt " << QT_VERSION_STR << ") on: "; + t << "// * Generated by qmake (" << qmake_version() << ") (Qt " QT_VERSION_STR ") on: "; t << QDateTime::currentDateTime().toString(Qt::ISODate) << endl; t << "// * This file is generated by qmake and should not be modified by the" << endl; t << "// * user." << endl; @@ -1346,7 +1400,7 @@ void SymbianMakefileGenerator::writeLocFile(QStringList &symbianLangCodes) generatedFiles << ft.fileName(); QTextStream t(&ft); t << "// ============================================================================" << endl; - t << "// * Generated by qmake (" << qmake_version() << ") (Qt " << QT_VERSION_STR << ") on: "; + t << "// * Generated by qmake (" << qmake_version() << ") (Qt " QT_VERSION_STR ") on: "; t << QDateTime::currentDateTime().toString(Qt::ISODate) << endl; t << "// * This file is generated by qmake and should not be modified by the" << endl; t << "// * user." << endl; diff --git a/qmake/generators/symbian/symmake.h b/qmake/generators/symbian/symmake.h index 2e78c46..1a20e64 100644 --- a/qmake/generators/symbian/symmake.h +++ b/qmake/generators/symbian/symmake.h @@ -96,7 +96,14 @@ protected: QString generateUID3(); void initMmpVariables(); - void checkOverridability(QStringList &overridableKeywords, QString &checkString); + void handleMmpRulesOverrides(QString &checkString, + bool &inResourceBlock, + QStringList &restrictedMmpKeywords, + const QStringList &restrictableMmpKeywords, + const QStringList &overridableMmpKeywords); + void appendKeywordIfMatchFound(QStringList &list, + const QStringList &keywordList, + QString &checkString); void writeHeader(QTextStream &t); void writeBldInfContent(QTextStream& t, bool addDeploymentExtension, const QString &iconFile); -- cgit v0.12 From 91921c880ea53a096237435ffac571a193f9c5f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sami=20Meril=C3=A4?= Date: Fri, 4 Dec 2009 15:34:35 +0200 Subject: QS60Style: Overwrites correct stylehint color values QS60Style overwrites correct theme colors with QCommonStyle values in QS60Style::styleHint(). In that method returned value is initialized as -1 and then if the value is still -1 after switch statement for different stylehints, the stylehint is queried from common style. Problem is that it is also getting RGB values set into return value. White color as HEX is FFFFFF and -1 as HEX is FFFFFF. So, if theme color is white for Group Text title, or for Grid lines, color is asked from QCommonStyle instead. As a fix, in 'default' case ask from QCommonStyle. Also, use RGBA instead of RGB values. Reviewed-by: Alessandro Portale --- src/gui/styles/qs60style.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/gui/styles/qs60style.cpp b/src/gui/styles/qs60style.cpp index 5f7ec69..aece73c 100644 --- a/src/gui/styles/qs60style.cpp +++ b/src/gui/styles/qs60style.cpp @@ -2343,10 +2343,10 @@ int QS60Style::styleHint(StyleHint sh, const QStyleOption *opt, const QWidget *w int retValue = -1; switch (sh) { case SH_Table_GridLineColor: - retValue = QS60StylePrivate::s60Color(QS60StyleEnums::CL_QsnLineColors,2,0).rgb(); + retValue = int(QS60StylePrivate::s60Color(QS60StyleEnums::CL_QsnLineColors,2,0).rgba()); break; case SH_GroupBox_TextLabelColor: - retValue = QS60StylePrivate::s60Color(QS60StyleEnums::CL_QsnTextColors,6,0).rgb(); + retValue = int(QS60StylePrivate::s60Color(QS60StyleEnums::CL_QsnTextColors,6,0).rgba()); break; case SH_ScrollBar_ScrollWhenPointerLeavesControl: retValue = true; @@ -2402,10 +2402,9 @@ int QS60Style::styleHint(StyleHint sh, const QStyleOption *opt, const QWidget *w retValue = QFormLayout::WrapLongRows; break; default: + retValue = QCommonStyle::styleHint(sh, opt, widget, hret); break; } - if (retValue == -1) - retValue = QCommonStyle::styleHint(sh, opt, widget, hret); return retValue; } -- cgit v0.12 From 63318f834671552add4fd584e5aae80523b5f007 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sami=20Meril=C3=A4?= Date: Fri, 4 Dec 2009 16:05:34 +0200 Subject: Button and LineEdit/TextEdit theme colors are incorrect QS60Style fetches incorrect color values from theme when using buttons and lineEdits/TextEdits. New values are the same as in native widgets (verified from native widget code). Task-number: QTBUG-6364 Reviewed-by: Alessandro Portale --- src/gui/styles/qs60style.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/gui/styles/qs60style.cpp b/src/gui/styles/qs60style.cpp index aece73c..be4f15a 100644 --- a/src/gui/styles/qs60style.cpp +++ b/src/gui/styles/qs60style.cpp @@ -654,7 +654,7 @@ void QS60StylePrivate::setThemePalette(QPalette *palette) const palette->setColor(QPalette::WindowText, s60Color(QS60StyleEnums::CL_QsnTextColors, 6, 0)); palette->setColor(QPalette::ButtonText, - s60Color(QS60StyleEnums::CL_QsnTextColors, 6, 0)); + s60Color(QS60StyleEnums::CL_QsnTextColors, 20, 0)); palette->setColor(QPalette::Text, s60Color(QS60StyleEnums::CL_QsnTextColors, 6, 0)); palette->setColor(QPalette::ToolTipText, @@ -753,13 +753,15 @@ void QS60StylePrivate::setThemePaletteHash(QPalette *palette) const QApplication::setPalette(widgetPalette, "QTableView"); widgetPalette = *palette; + widgetPalette.setColor(QPalette::Text, + s60Color(QS60StyleEnums::CL_QsnTextColors, 27, 0)); widgetPalette.setColor(QPalette::HighlightedText, s60Color(QS60StyleEnums::CL_QsnTextColors, 24, 0)); QApplication::setPalette(widgetPalette, "QLineEdit"); widgetPalette = *palette; widgetPalette.setColor(QPalette::Text, - s60Color(QS60StyleEnums::CL_QsnTextColors, 34, 0)); + s60Color(QS60StyleEnums::CL_QsnTextColors, 27, 0)); widgetPalette.setColor(QPalette::HighlightedText, s60Color(QS60StyleEnums::CL_QsnTextColors, 24, 0)); QApplication::setPalette(widgetPalette, "QTextEdit"); -- cgit v0.12 From ac83e69ffbabff8a5e674d38f0bc90ff5f188f6e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan-Arve=20S=C3=A6ther?= Date: Fri, 4 Dec 2009 11:24:27 +0100 Subject: Made sure that we didn't reference dangling parallel anchors. We cannot delete the parallel anchors before we do the actual vertex restoration, since the parallel anchors created by vertex simplification will always be connected to some of the AnchorVertexPair found in simplifiedVertices that we iterate over later. Thus, we must delete the parallel anchors created by vertex simplification after we have done the restoration of the vertices. (the parallel anchor will be properly dealt with (i.e. taken out of the graph as we do the restoration)), so not deleting it won't cause it to be revisited later if that is a worry. Reviewed-by: Eduardo M. Fleury --- src/gui/graphicsview/qgraphicsanchorlayout_p.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gui/graphicsview/qgraphicsanchorlayout_p.cpp b/src/gui/graphicsview/qgraphicsanchorlayout_p.cpp index b33e228..03ed63d 100644 --- a/src/gui/graphicsview/qgraphicsanchorlayout_p.cpp +++ b/src/gui/graphicsview/qgraphicsanchorlayout_p.cpp @@ -1317,9 +1317,7 @@ void QGraphicsAnchorLayoutPrivate::restoreVertices(Orientation orientation) for (int i = parallelAnchors.count() - 1; i >= 0; --i) { ParallelAnchorData *parallel = static_cast(parallelAnchors.at(i)); restoreSimplifiedConstraints(parallel); - delete parallel; } - parallelAnchors.clear(); // Then, we will restore the vertices in the inverse order of creation, this way we ensure that // the vertex being restored was not wrapped by another simplification. @@ -1365,6 +1363,8 @@ void QGraphicsAnchorLayoutPrivate::restoreVertices(Orientation orientation) delete pair; } + qDeleteAll(parallelAnchors); + parallelAnchors.clear(); toRestore.clear(); } -- cgit v0.12 From 39392326c8c843a6f46b864c6595a5241a47af10 Mon Sep 17 00:00:00 2001 From: Yoann Lopes Date: Fri, 4 Dec 2009 15:57:18 +0100 Subject: Fixes clipping bug in the embedded dialogs demo. The problem was that when using DeviceCoordinateCache for items in a scene, newly exposed areas were wrongly painted over the Pixmap in the cache, instead of blending into it. Autotest included. Task-number: QTBUG-657 Reviewed-by: Andreas Reviewed-by: bnilsen --- src/gui/graphicsview/qgraphicsscene.cpp | 1 - tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp | 39 ++++++++++++++++++++++++ 2 files changed, 39 insertions(+), 1 deletion(-) diff --git a/src/gui/graphicsview/qgraphicsscene.cpp b/src/gui/graphicsview/qgraphicsscene.cpp index 8777cdc..27ebb79 100644 --- a/src/gui/graphicsview/qgraphicsscene.cpp +++ b/src/gui/graphicsview/qgraphicsscene.cpp @@ -4233,7 +4233,6 @@ static void _q_paintIntoCache(QPixmap *pix, QGraphicsItem *item, const QRegion & if (!subPix.isNull()) { // Blit the subpixmap into the main pixmap. pixmapPainter.begin(pix); - pixmapPainter.setCompositionMode(QPainter::CompositionMode_Source); pixmapPainter.setClipRegion(pixmapExposed); pixmapPainter.drawPixmap(br.topLeft(), subPix); pixmapPainter.end(); diff --git a/tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp b/tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp index 32206db..c5e57f7 100644 --- a/tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp +++ b/tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp @@ -280,6 +280,7 @@ private slots: void task160653_selectionChanged(); void task250680_childClip(); void taskQTBUG_5904_crashWithDeviceCoordinateCache(); + void taskQT657_paintIntoCacheWithTransparentParts(); }; void tst_QGraphicsScene::initTestCase() @@ -4270,5 +4271,43 @@ void tst_QGraphicsScene::taskQTBUG_5904_crashWithDeviceCoordinateCache() // No crash, then it passed! } +void tst_QGraphicsScene::taskQT657_paintIntoCacheWithTransparentParts() +{ + QWidget *w = new QWidget(); + w->setPalette(Qt::blue); + w->setGeometry(0, 0, 50, 50); + + QGraphicsScene *scene = new QGraphicsScene(); + QGraphicsView *view = new QGraphicsView(scene); + + QGraphicsProxyWidget *proxy = scene->addWidget(w); + proxy->setCacheMode(QGraphicsItem::DeviceCoordinateCache); + proxy->rotate(15); + + view->show(); + QTest::qWaitForWindowShown(view); + w->update(10,10,10,10); + QTest::qWait(50); + + QPixmap pix; + QGraphicsItemPrivate* itemp = QGraphicsItemPrivate::get(proxy); + QPixmapCache::Key key = itemp->extraItemCache()->deviceData.value(view->viewport()).key; + QVERIFY(QPixmapCache::find(key, &pix)); + + QTransform t = proxy->sceneTransform(); + // Map from scene coordinates to pixmap coordinates. + // X origin in the pixmap is the most-left point + // of the item's boundingRect in the scene. + qreal adjust = t.mapRect(proxy->boundingRect().toRect()).left(); + QRect rect = t.mapRect(QRect(10, 10, 10, 10)).adjusted(-adjust, 0, -adjust + 1, 1); + QPixmap subpix = pix.copy(rect); + + QImage im = subpix.toImage(); + for(int i = 0; i < im.width(); i++) { + for(int j = 0; j < im.height(); j++) + QCOMPARE(qAlpha(im.pixel(i, j)), 255); + } +} + QTEST_MAIN(tst_QGraphicsScene) #include "tst_qgraphicsscene.moc" -- cgit v0.12 From 2e3ecbb0b401aa29d4bbc2fe5df8cfb9f541a693 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan-Arve=20S=C3=A6ther?= Date: Fri, 4 Dec 2009 16:16:49 +0100 Subject: Make sure that QtGui links with QtCore for the win32-icc mkspec. Fix it by exporting QObjectData. Since this is a compiler bug we will only export it for the compiler that has this problem. (Intel Compiler on Windows) The Intel compiler seems to inline the destructor of QObject (or at least parts of it) even if it is declared virtual. Thus, it seems that the destruction of the QScopedPointer member is inlined into QtGui, and that code will eventually call the destructor of QObjectData, and since QObjectData was not exported from QtCore it would crash. Reviewed-by: Olivier Goffart --- src/corelib/kernel/qobject.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/corelib/kernel/qobject.h b/src/corelib/kernel/qobject.h index 340498f..68475e5 100644 --- a/src/corelib/kernel/qobject.h +++ b/src/corelib/kernel/qobject.h @@ -91,7 +91,11 @@ template inline QList qFindChildren(const QObject *, const QRegEx # endif #endif +#if defined(__INTEL_COMPILER) && defined(Q_OS_WIN) +class Q_CORE_EXPORT QObjectData { +#else class QObjectData { +#endif public: virtual ~QObjectData() = 0; QObject *q_ptr; -- cgit v0.12 From b00b1c660beeb861ed3ce618ee30a3c46c95cfa2 Mon Sep 17 00:00:00 2001 From: Thierry Bastian Date: Fri, 4 Dec 2009 17:34:14 +0100 Subject: Fix toolbar animation when restoring from expanded state Task-number: QTBUG-6529 Reviewed-by: Gabi --- src/gui/widgets/qtoolbar.cpp | 2 +- src/gui/widgets/qtoolbarlayout.cpp | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/gui/widgets/qtoolbar.cpp b/src/gui/widgets/qtoolbar.cpp index 58a3d28..c0ca015 100644 --- a/src/gui/widgets/qtoolbar.cpp +++ b/src/gui/widgets/qtoolbar.cpp @@ -396,10 +396,10 @@ bool QToolBarPrivate::mouseMoveEvent(QMouseEvent *event) void QToolBarPrivate::unplug(const QRect &_r) { Q_Q(QToolBar); - layout->setExpanded(false); QRect r = _r; r.moveTopLeft(q->mapToGlobal(QPoint(0, 0))); setWindowState(true, true, r); + layout->setExpanded(false); } void QToolBarPrivate::plug(const QRect &r) diff --git a/src/gui/widgets/qtoolbarlayout.cpp b/src/gui/widgets/qtoolbarlayout.cpp index 0afe5d8..93429e4 100644 --- a/src/gui/widgets/qtoolbarlayout.cpp +++ b/src/gui/widgets/qtoolbarlayout.cpp @@ -654,6 +654,7 @@ void QToolBarLayout::setExpanded(bool exp) if (!tb) return; if (QMainWindow *win = qobject_cast(tb->parentWidget())) { + animating = !tb->isWindow() && win->isAnimated(); QMainWindowLayout *layout = qobject_cast(win->layout()); if (expanded) { tb->raise(); @@ -664,7 +665,7 @@ void QToolBarLayout::setExpanded(bool exp) layoutActions(rect.size()); } } - layout->layoutState.toolBarAreaLayout.apply(win->isAnimated()); + layout->layoutState.toolBarAreaLayout.apply(animating); } } -- cgit v0.12 From bed10148f651cca2a7376a637267a31ef7c87064 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan-Arve=20S=C3=A6ther?= Date: Fri, 4 Dec 2009 17:54:12 +0100 Subject: Made qobject.h "syncqt compliant". The previous patch to this file made syncqt confused (maybe because of the brackets), and caused it to not generate the QObject header file. This made of course a lot of stuff not compile. With this patch syncqt behaves. Reviewed-by: Olivier Goffart --- src/corelib/kernel/qobject.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/corelib/kernel/qobject.h b/src/corelib/kernel/qobject.h index 68475e5..1a178e2 100644 --- a/src/corelib/kernel/qobject.h +++ b/src/corelib/kernel/qobject.h @@ -91,11 +91,11 @@ template inline QList qFindChildren(const QObject *, const QRegEx # endif #endif +class #if defined(__INTEL_COMPILER) && defined(Q_OS_WIN) -class Q_CORE_EXPORT QObjectData { -#else -class QObjectData { +Q_CORE_EXPORT #endif +QObjectData { public: virtual ~QObjectData() = 0; QObject *q_ptr; -- cgit v0.12 From 60be72310c0f9469b3201b250b257473184ccf2a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Thu, 3 Dec 2009 11:53:31 +0100 Subject: Fixed OpenGL graphicssystem issues for OpenGL ES 2.0 platforms. The format and internal_format parameters to glTexImage2D need to always match on OpenGL ES 2.0. Reviewed-by: Tom Cooksey --- src/opengl/qgl_p.h | 3 ++- src/opengl/qpixmapdata_gl.cpp | 38 ++++++++++++++++++++++++++++++-------- src/opengl/qwindowsurface_gl.cpp | 9 ++++----- 3 files changed, 36 insertions(+), 14 deletions(-) diff --git a/src/opengl/qgl_p.h b/src/opengl/qgl_p.h index ab72c9c..b2407ba 100644 --- a/src/opengl/qgl_p.h +++ b/src/opengl/qgl_p.h @@ -518,7 +518,8 @@ bool qt_gl_preferGL2Engine(); inline GLenum qt_gl_preferredTextureFormat() { - return QSysInfo::ByteOrder == QSysInfo::BigEndian ? GL_RGBA : GL_BGRA; + return (QGLExtensions::glExtensions & QGLExtensions::BGRATextureFormat) && QSysInfo::ByteOrder == QSysInfo::LittleEndian + ? GL_BGRA : GL_RGBA; } inline GLenum qt_gl_preferredTextureTarget() diff --git a/src/opengl/qpixmapdata_gl.cpp b/src/opengl/qpixmapdata_gl.cpp index fb55097..ab17789 100644 --- a/src/opengl/qpixmapdata_gl.cpp +++ b/src/opengl/qpixmapdata_gl.cpp @@ -321,25 +321,47 @@ void QGLPixmapData::ensureCreated() const QGLShareContextScope ctx(qt_gl_share_widget()->context()); m_ctx = ctx; - const GLenum format = qt_gl_preferredTextureFormat(); + const GLenum internal_format = m_hasAlpha ? GL_RGBA : GL_RGB; +#ifdef QT_OPENGL_ES_2 + const GLenum external_format = internal_format; +#else + const GLenum external_format = qt_gl_preferredTextureFormat(); +#endif const GLenum target = GL_TEXTURE_2D; if (!m_texture.id) { glGenTextures(1, &m_texture.id); glBindTexture(target, m_texture.id); - GLenum format = m_hasAlpha ? GL_RGBA : GL_RGB; - glTexImage2D(target, 0, format, w, h, 0, - GL_RGBA, GL_UNSIGNED_BYTE, 0); + glTexImage2D(target, 0, internal_format, w, h, 0, external_format, GL_UNSIGNED_BYTE, 0); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); } if (!m_source.isNull()) { - const QImage tx = ctx->d_func()->convertToGLFormat(m_source, true, format); + if (external_format == GL_RGB) { + QImage tx = m_source.convertToFormat(QImage::Format_RGB32); + + QVector pixelData(w * h * 3); + uchar *p = &pixelData[0]; + QRgb *src = (QRgb *)tx.bits(); + + for (int i = 0; i < w * h; ++i) { + *p++ = qRed(*src); + *p++ = qGreen(*src); + *p++ = qBlue(*src); + ++src; + } - glBindTexture(target, m_texture.id); - glTexSubImage2D(target, 0, 0, 0, w, h, format, - GL_UNSIGNED_BYTE, tx.bits()); + glBindTexture(target, m_texture.id); + glTexSubImage2D(target, 0, 0, 0, w, h, external_format, + GL_UNSIGNED_BYTE, &pixelData[0]); + } else { + const QImage tx = ctx->d_func()->convertToGLFormat(m_source, true, external_format); + + glBindTexture(target, m_texture.id); + glTexSubImage2D(target, 0, 0, 0, w, h, external_format, + GL_UNSIGNED_BYTE, tx.bits()); + } if (useFramebufferObjects()) m_source = QImage(); diff --git a/src/opengl/qwindowsurface_gl.cpp b/src/opengl/qwindowsurface_gl.cpp index e353f5d..7194f9d 100644 --- a/src/opengl/qwindowsurface_gl.cpp +++ b/src/opengl/qwindowsurface_gl.cpp @@ -493,7 +493,6 @@ void QGLWindowSurface::flush(QWidget *widget, const QRegion &rgn, const QPoint & } #endif d_ptr->paintedRegion = QRegion(); - context()->swapBuffers(); } else { glFlush(); @@ -688,11 +687,13 @@ void QGLWindowSurface::updateGeometry() { d_ptr->size = rect.size(); if (d_ptr->ctx) { +#ifndef QT_OPENGL_ES_2 if (d_ptr->destructive_swap_buffers) { glBindTexture(target, d_ptr->tex_id); glTexImage2D(target, 0, GL_RGBA, rect.width(), rect.height(), 0, GL_RGB, GL_UNSIGNED_BYTE, 0); glBindTexture(target, 0); } +#endif return; } @@ -756,11 +757,7 @@ void QGLWindowSurface::updateGeometry() { glMatrixMode(GL_PROJECTION); glLoadIdentity(); -#ifndef QT_OPENGL_ES glOrtho(0, d_ptr->pb->width(), d_ptr->pb->height(), 0, -999999, 999999); -#else - glOrthof(0, d_ptr->pb->width(), d_ptr->pb->height(), 0, -999999, 999999); -#endif d_ptr->pb->d_ptr->qctx->d_func()->internal_context = true; return; @@ -774,6 +771,7 @@ void QGLWindowSurface::updateGeometry() { ctx->makeCurrent(); +#ifndef QT_OPENGL_ES_2 if (d_ptr->destructive_swap_buffers) { glGenTextures(1, &d_ptr->tex_id); glBindTexture(target, d_ptr->tex_id); @@ -783,6 +781,7 @@ void QGLWindowSurface::updateGeometry() { glTexParameterf(target, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glBindTexture(target, 0); } +#endif qDebug() << "QGLWindowSurface: Using plain widget as window surface" << this;; d_ptr->ctx = ctx; -- cgit v0.12 From 8529a8cbb0c6404c758b5efc650186d740b0e09f Mon Sep 17 00:00:00 2001 From: Pierre Rossi Date: Fri, 4 Dec 2009 00:04:09 +0100 Subject: Fixes problem with QMenu when it's populated on the aboutToShow When the menu is populated that late, if the menu is to go off-screen, then it is moved and ends up covering its originating button. Includes some code cleanup thanks to Thierry's tips. Reviewed-by: Gabriel Reviewed-by: Thierry --- src/gui/widgets/qmenu.cpp | 35 +++++++++++++---------------------- src/gui/widgets/qmenu_p.h | 1 + src/gui/widgets/qpushbutton.cpp | 33 ++++++++++++++++++++++++--------- src/gui/widgets/qpushbutton_p.h | 4 ++++ tests/auto/qmenu/tst_qmenu.cpp | 36 +++++++++++++++++++++++++++++++++++- 5 files changed, 77 insertions(+), 32 deletions(-) diff --git a/src/gui/widgets/qmenu.cpp b/src/gui/widgets/qmenu.cpp index 2e27226..ec9683d 100644 --- a/src/gui/widgets/qmenu.cpp +++ b/src/gui/widgets/qmenu.cpp @@ -65,6 +65,8 @@ #include "qmenubar_p.h" #include "qwidgetaction.h" #include "qtoolbutton.h" +#include "qpushbutton.h" +#include #include #include #ifdef QT3_SUPPORT @@ -417,12 +419,7 @@ void QMenuPrivate::hideUpToMenuBar() hideMenu(m, fadeMenus); if (!fadeMenus) // Mac doesn't clear the action until after hidden. m->d_func()->setCurrentAction(0); - } else { -#ifndef QT_NO_TOOLBUTTON - if (qobject_cast(caused) == 0) -#endif - qWarning("QMenu: Internal error"); - caused = 0; + } else { caused = 0; } } #if defined(Q_WS_MAC) @@ -1825,8 +1822,15 @@ void QMenu::popup(const QPoint &p, QAction *atAction) ensurePolished(); // Get the right font emit aboutToShow(); + const bool actionListChanged = d->itemsDirty; d->updateActionRects(); - QPoint pos = p; + QPoint pos; + QPushButton *causedButton = qobject_cast(d->causedPopup.widget); + if (actionListChanged && causedButton) + pos = QPushButtonPrivate::get(causedButton)->adjustedMenuPosition(); + else + pos = p; + QSize size = sizeHint(); QRect screen; #ifndef QT_NO_GRAPHICSVIEW @@ -2302,22 +2306,9 @@ void QMenu::mouseReleaseEvent(QMouseEvent *e) if (action->menu()) action->menu()->d_func()->setFirstActionActive(); else { -#if defined(Q_WS_WIN) && !defined(QT_NO_MENUBAR) +#if defined(Q_WS_WIN) //On Windows only context menus can be activated with the right button - bool isContextMenu = true; - const QWidget *cause = d->causedPopup.widget; - while (cause) { - //if the popup was caused by either QMenuBar or a QToolButton, it is not a context menu - if (qobject_cast(cause) || qobject_cast(cause)) { - isContextMenu = false; - break; - } else if (const QMenu *menu = qobject_cast(cause)) { - cause = menu->d_func()->causedPopup.widget; - } else { - break; - } - } - if (e->button() == Qt::LeftButton || isContextMenu) + if (e->button() == Qt::LeftButton || d->topCausedWidget() == 0) #endif d->activateAction(action, QAction::Trigger); } diff --git a/src/gui/widgets/qmenu_p.h b/src/gui/widgets/qmenu_p.h index 5757885..93017f5 100644 --- a/src/gui/widgets/qmenu_p.h +++ b/src/gui/widgets/qmenu_p.h @@ -182,6 +182,7 @@ public: } void init(); + static QMenuPrivate *get(QMenu *m) { return m->d_func(); } int scrollerHeight() const; //item calculations diff --git a/src/gui/widgets/qpushbutton.cpp b/src/gui/widgets/qpushbutton.cpp index eb34336..849bc43 100644 --- a/src/gui/widgets/qpushbutton.cpp +++ b/src/gui/widgets/qpushbutton.cpp @@ -63,6 +63,7 @@ #include "qaccessible.h" #endif +#include "private/qmenu_p.h" #include "private/qpushbutton_p.h" QT_BEGIN_NAMESPACE @@ -575,12 +576,33 @@ void QPushButtonPrivate::_q_popupPressed() return; menu->setNoReplayFor(q); + + QPoint menuPos = adjustedMenuPosition(); + + QPointer guard(q); + QMenuPrivate::get(menu)->causedPopup.widget = guard; + + //Because of a delay in menu effects, we must keep track of the + //menu visibility to avoid flicker on button release + menuOpen = true; + menu->exec(menuPos); + if (guard) { + menuOpen = false; + q->setDown(false); + } +} + +QPoint QPushButtonPrivate::adjustedMenuPosition() +{ + Q_Q(QPushButton); + bool horizontal = true; #if !defined(QT_NO_TOOLBAR) QToolBar *tb = qobject_cast(parent); if (tb && tb->orientation() == Qt::Vertical) horizontal = false; #endif + QWidgetItem item(q); QRect rect = item.geometry(); rect.setRect(rect.x() - q->x(), rect.y() - q->y(), rect.width(), rect.height()); @@ -603,17 +625,10 @@ void QPushButtonPrivate::_q_popupPressed() else x -= menuSize.width(); } - QPointer guard(q); - //Because of a delay in menu effects, we must keep track of the - //menu visibility to avoid flicker on button release - menuOpen = true; - menu->exec(QPoint(x, y)); - if (guard) { - menuOpen = false; - q->setDown(false); - } + return QPoint(x,y); } + #endif // QT_NO_MENU void QPushButtonPrivate::resetLayoutItemMargins() diff --git a/src/gui/widgets/qpushbutton_p.h b/src/gui/widgets/qpushbutton_p.h index f448027..2510e05 100644 --- a/src/gui/widgets/qpushbutton_p.h +++ b/src/gui/widgets/qpushbutton_p.h @@ -68,6 +68,10 @@ public: defaultButton(false), flat(false), menuOpen(false), lastAutoDefault(false) {} inline void init() { resetLayoutItemMargins(); } + static QPushButtonPrivate* get(QPushButton *b) { return b->d_func(); } +#ifndef QT_NO_MENU + QPoint adjustedMenuPosition(); +#endif void resetLayoutItemMargins(); void _q_popupPressed(); QDialog *dialogParent() const; diff --git a/tests/auto/qmenu/tst_qmenu.cpp b/tests/auto/qmenu/tst_qmenu.cpp index 7cdfe46..6079189 100644 --- a/tests/auto/qmenu/tst_qmenu.cpp +++ b/tests/auto/qmenu/tst_qmenu.cpp @@ -82,7 +82,7 @@ private slots: void keyboardNavigation_data(); void keyboardNavigation(); void focus(); - void overrideMenuAction(); + void overrideMenuAction(); void statusTip(); void widgetActionFocus(); void mouseActivation(); @@ -103,12 +103,14 @@ private slots: void task258920_mouseBorder(); void setFixedWidth(); void deleteActionInTriggered(); + void pushButtonPopulateOnAboutToShow(); protected slots: void onActivated(QAction*); void onHighlighted(QAction*); void onStatusMessageChanged(const QString &); void onStatusTipTimer(); void deleteAction(QAction *a) { delete a; } + void populateMenu(); private: void createActions(); QMenu *menus[2], *lastMenu; @@ -258,6 +260,15 @@ void tst_QMenu::onStatusMessageChanged(const QString &s) statustip=s; } +void tst_QMenu::populateMenu(){ + //just adds 3 dummy actions and a separator. + lastMenu->addAction("Foo"); + lastMenu->addAction("Bar"); + lastMenu->addAction("FooBar"); + lastMenu->addSeparator(); + +} + //actual tests void @@ -896,7 +907,30 @@ void tst_QMenu::deleteActionInTriggered() QVERIFY(!a); } +void tst_QMenu::pushButtonPopulateOnAboutToShow() +{ + QPushButton b("Test PushButton"); + b.setWindowFlags(Qt::FramelessWindowHint); + b.setWindowFlags(Qt::X11BypassWindowManagerHint); + lastMenu = new QMenu; + b.setMenu(lastMenu); + const int scrNumber = QApplication::desktop()->screenNumber(&b); + connect(lastMenu, SIGNAL(aboutToShow()), this, SLOT(populateMenu())); + b.show(); + const QRect screen = QApplication::desktop()->screenGeometry(scrNumber); + b.move(10, screen.bottom()-b.height()-5); + QTest::qWaitForWindowShown(&b); + QTimer::singleShot(300,lastMenu, SLOT(hide())); + QTest::mouseClick(&b, Qt::LeftButton, Qt::NoModifier, b.rect().center()); + QVERIFY(!lastMenu->geometry().intersects(b.geometry())); + + b.move(10, screen.bottom()-lastMenu->height()-5); + QTimer::singleShot(300,lastMenu, SLOT(hide())); + QTest::mouseClick(&b, Qt::LeftButton, Qt::NoModifier, b.rect().center()); + QVERIFY(!lastMenu->geometry().intersects(b.geometry())); + +} QTEST_MAIN(tst_QMenu) -- cgit v0.12 From 92e9fcc25c62870c383c8558d576abc509a8c683 Mon Sep 17 00:00:00 2001 From: Tom Cooksey Date: Fri, 4 Dec 2009 19:42:07 +0100 Subject: Add EGL_BUFFER_SIZE to QEglProperties::reduceConfiguration() Reviewed-by: Trustme --- src/gui/egl/qeglproperties.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/gui/egl/qeglproperties.cpp b/src/gui/egl/qeglproperties.cpp index 2d37edb..4d4410a 100644 --- a/src/gui/egl/qeglproperties.cpp +++ b/src/gui/egl/qeglproperties.cpp @@ -229,6 +229,15 @@ void QEglProperties::setRenderableType(QEgl::API api) // reductions in complexity are possible. bool QEglProperties::reduceConfiguration() { + // EGL chooses configs with the highest color depth over + // those with smaller (but faster) lower color depths. One + // way around this is to set EGL_BUFFER_SIZE to 16, which + // trumps the others. Of course, there may not be a 16-bit + // config avaliable, so it's the first restraint we remove. + if (value(EGL_BUFFER_SIZE) == 16) { + removeValue(EGL_BUFFER_SIZE); + return true; + } if (removeValue(EGL_SAMPLE_BUFFERS)) { removeValue(EGL_SAMPLES); return true; -- cgit v0.12 From 76c415b586991d978d46a888fb40c631513407dc Mon Sep 17 00:00:00 2001 From: Tom Cooksey Date: Fri, 4 Dec 2009 20:48:53 +0100 Subject: Fix WA_TranslucentBackground for QGLWidgets on X11/EGL Also check for existing QEglContext before creating a new one and leaking a context. Reviewed-by: TrustMe --- src/opengl/qgl_x11egl.cpp | 118 ++++++++++++++++++++++++++++------------------ 1 file changed, 73 insertions(+), 45 deletions(-) diff --git a/src/opengl/qgl_x11egl.cpp b/src/opengl/qgl_x11egl.cpp index b51c239..a868e83 100644 --- a/src/opengl/qgl_x11egl.cpp +++ b/src/opengl/qgl_x11egl.cpp @@ -63,6 +63,7 @@ void qt_egl_add_platform_config(QEglProperties& props, QPaintDevice *device) props.setPixelFormat(static_cast(device)->format()); } +// Chooses the EGL config and creates the EGL context bool QGLContext::chooseContext(const QGLContext* shareContext) { Q_D(QGLContext); @@ -73,56 +74,74 @@ bool QGLContext::chooseContext(const QGLContext* shareContext) int devType = device()->devType(); // Get the display and initialize it. - d->eglContext = new QEglContext(); - d->eglContext->setApi(QEgl::OpenGL); - if (!d->eglContext->openDisplay(device())) { - delete d->eglContext; - d->eglContext = 0; - return false; - } + if (d->eglContext == 0) { + d->eglContext = new QEglContext(); + d->eglContext->setApi(QEgl::OpenGL); + if (!d->eglContext->openDisplay(device())) { + delete d->eglContext; + d->eglContext = 0; + return false; + } - // Construct the configuration we need for this surface. - QEglProperties configProps; - qt_egl_set_format(configProps, devType, d->glFormat); - qt_egl_add_platform_config(configProps, device()); - configProps.setRenderableType(QEgl::OpenGL); - - QEgl::PixelFormatMatch matchType = QEgl::BestPixelFormat; - if (device()->depth() == 16) { - configProps.setValue(EGL_RED_SIZE, 5); - configProps.setValue(EGL_GREEN_SIZE, 6); - configProps.setValue(EGL_BLUE_SIZE, 5); - configProps.setValue(EGL_ALPHA_SIZE, 0); - matchType = QEgl::ExactPixelFormat; - } - configProps.setRenderableType(QEgl::OpenGL); + // Construct the configuration we need for this surface. + QEglProperties configProps; + qt_egl_set_format(configProps, devType, d->glFormat); + qt_egl_add_platform_config(configProps, device()); + configProps.setRenderableType(QEgl::OpenGL); + +#if We_have_an_EGL_library_which_bothers_to_check_EGL_BUFFER_SIZE + if (device()->depth() == 16 && configProps.value(EGL_ALPHA_SIZE) <= 0) { + qDebug("Setting EGL_BUFFER_SIZE to 16"); + configProps.setValue(EGL_BUFFER_SIZE, 16); + configProps.setValue(EGL_ALPHA_SIZE, 0); + } - // Search for a matching configuration, reducing the complexity - // each time until we get something that matches. - if (!d->eglContext->chooseConfig(configProps, matchType)) { - delete d->eglContext; - d->eglContext = 0; - return false; - } + if (!d->eglContext->chooseConfig(configProps, QEgl::BestPixelFormat)) { + delete d->eglContext; + d->eglContext = 0; + return false; + } +#else + QEgl::PixelFormatMatch matchType = QEgl::BestPixelFormat; + if ((device()->depth() == 16) && configProps.value(EGL_ALPHA_SIZE) == 0) { + configProps.setValue(EGL_RED_SIZE, 5); + configProps.setValue(EGL_GREEN_SIZE, 6); + configProps.setValue(EGL_BLUE_SIZE, 5); + configProps.setValue(EGL_ALPHA_SIZE, 0); + matchType = QEgl::ExactPixelFormat; + } - // Inform the higher layers about the actual format properties. - qt_egl_update_format(*(d->eglContext), d->glFormat); + // Search for a matching configuration, reducing the complexity + // each time until we get something that matches. + if (!d->eglContext->chooseConfig(configProps, matchType)) { + delete d->eglContext; + d->eglContext = 0; + return false; + } +#endif - // Create a new context for the configuration. - if (!d->eglContext->createContext - (shareContext ? shareContext->d_func()->eglContext : 0)) { - delete d->eglContext; - d->eglContext = 0; - return false; - } - d->sharing = d->eglContext->isSharing(); - if (d->sharing && shareContext) - const_cast(shareContext)->d_func()->sharing = true; +// qDebug("QGLContext::chooseContext() - using EGL config %d:", d->eglContext->config()); +// qDebug() << QEglProperties(d->eglContext->config()).toString(); + + // Create a new context for the configuration. + if (!d->eglContext->createContext + (shareContext ? shareContext->d_func()->eglContext : 0)) { + delete d->eglContext; + d->eglContext = 0; + return false; + } + d->sharing = d->eglContext->isSharing(); + if (d->sharing && shareContext) + const_cast(shareContext)->d_func()->sharing = true; #if defined(EGL_VERSION_1_1) - if (d->glFormat.swapInterval() != -1 && devType == QInternal::Widget) - eglSwapInterval(d->eglContext->display(), d->glFormat.swapInterval()); + if (d->glFormat.swapInterval() != -1 && devType == QInternal::Widget) + eglSwapInterval(d->eglContext->display(), d->glFormat.swapInterval()); #endif + } + + // Inform the higher layers about the actual format properties. + qt_egl_update_format(*(d->eglContext), d->glFormat); return true; } @@ -160,6 +179,9 @@ bool qt_egl_setup_x11_visual(XVisualInfo &vi, EGLDisplay display, EGLConfig conf memset(&vi, 0, sizeof(XVisualInfo)); + EGLint eglConfigColorSize; + eglGetConfigAttrib(display, config, EGL_BUFFER_SIZE, &eglConfigColorSize); + // Check to see if EGL is suggesting an appropriate visual id: EGLint nativeVisualId; eglGetConfigAttrib(display, config, EGL_NATIVE_VISUAL_ID, &nativeVisualId); @@ -189,8 +211,12 @@ bool qt_egl_setup_x11_visual(XVisualInfo &vi, EGLDisplay display, EGLConfig conf } else #endif { -// qDebug("Using opaque X Visual ID (%d) provided by EGL", (int)vi.visualid); - vi = *chosenVisualInfo; + if (eglConfigColorSize == chosenVisualInfo->depth) { +// qDebug("Using opaque X Visual ID (%d) provided by EGL", (int)vi.visualid); + vi = *chosenVisualInfo; + } else + qWarning("Warning: EGL suggested using X visual ID %d (%d bpp) for config %d (%d bpp), but the depths do not match!", + nativeVisualId, chosenVisualInfo->depth, (int)config, eglConfigColorSize); } XFree(chosenVisualInfo); } @@ -300,6 +326,8 @@ void QGLWidget::setContext(QGLContext *context, const QGLContext* shareContext, bool createFailed = false; if (!d->glcx->isValid()) { + // Create the QGLContext here, which in turn chooses the EGL config + // and creates the EGL context: if (!d->glcx->create(shareContext ? shareContext : oldcx)) createFailed = true; } -- cgit v0.12 From 147195bccfdf90924a1525398e9c7b3119c1e278 Mon Sep 17 00:00:00 2001 From: Rhys Weatherley Date: Thu, 3 Dec 2009 10:07:22 +1000 Subject: Compressed texture binding for QtOpenGL: ETC1 and PVRTC The QGLContext::bindTexture(QString) function has been augmented with support for ETC1, PVRTC2, and PVRTC4 compressed textures, in addition to the existing DDS support. The QGLPixmapData class has also been modified to recognize compressed texture formats in fromFile() and fromData(). This change also fixes a bug in bindTexture() that prevented the same compressed texture file from being bound in multiple contexts. There is now a separate file cache for each context group. Task-number: QT-2547 Reviewed-by: Trond --- src/opengl/qgl.cpp | 485 ++++++++++++++++++++++++++++++++---------- src/opengl/qgl_p.h | 16 +- src/opengl/qglextensions_p.h | 17 ++ src/opengl/qpixmapdata_gl.cpp | 57 +++++ src/opengl/qpixmapdata_gl_p.h | 4 + 5 files changed, 461 insertions(+), 118 deletions(-) diff --git a/src/opengl/qgl.cpp b/src/opengl/qgl.cpp index 94b8aa5..b376901 100644 --- a/src/opengl/qgl.cpp +++ b/src/opengl/qgl.cpp @@ -127,18 +127,6 @@ Q_GLOBAL_STATIC(QGLDefaultOverlayFormat, defaultOverlayFormatInstance) QGLExtensions::Extensions QGLExtensions::glExtensions = 0; bool QGLExtensions::nvidiaFboNeedsFinish = false; -#ifndef APIENTRY -# define APIENTRY -#endif -typedef void (APIENTRY *pfn_glCompressedTexImage2DARB) (GLenum, GLint, GLenum, GLsizei, - GLsizei, GLint, GLsizei, const GLvoid *); -static pfn_glCompressedTexImage2DARB qt_glCompressedTexImage2DARB = 0; - - -#ifndef APIENTRY -#define APIENTRY -#endif - Q_GLOBAL_STATIC(QGLSignalProxy, theSignalProxy) QGLSignalProxy *QGLSignalProxy::instance() { @@ -1887,118 +1875,42 @@ void QGLContextPrivate::cleanup() { } -typedef QHash QGLDDSCache; -Q_GLOBAL_STATIC(QGLDDSCache, qgl_dds_cache) - /*! \overload - Reads the DirectDrawSurface (DDS) compressed file \a fileName and - generates a 2D GL texture from it. + Reads the compressed texture file \a fileName and generates a 2D GL + texture from it. - Only the DXT1, DXT3 and DXT5 DDS formats are supported. + This function can load DirectDrawSurface (DDS) textures in the + DXT1, DXT3 and DXT5 DDS formats if the \c GL_ARB_texture_compression + and \c GL_EXT_texture_compression_s3tc extensions are supported. - Note that this will only work if the implementation supports the - \c GL_ARB_texture_compression and \c GL_EXT_texture_compression_s3tc - extensions. + Since 4.6.1, textures in the ETC1 format can be loaded if the + \c GL_OES_compressed_ETC1_RGB8_texture extension is supported + and the ETC1 texture has been encapsulated in the PVR container format. + Also, textures in the PVRTC2 and PVRTC4 formats can be loaded + if the \c GL_IMG_texture_compression_pvrtc extension is supported. \sa deleteTexture() */ GLuint QGLContext::bindTexture(const QString &fileName) { - if (!qt_glCompressedTexImage2DARB) { - qWarning("QGLContext::bindTexture(): The GL implementation does not support texture" - "compression extensions."); - return 0; - } - - QGLDDSCache::const_iterator it = qgl_dds_cache()->constFind(fileName); - if (it != qgl_dds_cache()->constEnd()) { + Q_D(QGLContext); + QGLDDSCache *dds_cache = &(d->group->m_dds_cache); + QGLDDSCache::const_iterator it = dds_cache->constFind(fileName); + if (it != dds_cache->constEnd()) { glBindTexture(GL_TEXTURE_2D, it.value()); return it.value(); } - QFile f(fileName); - f.open(QIODevice::ReadOnly); - - char tag[4]; - f.read(&tag[0], 4); - if (strncmp(tag,"DDS ", 4) != 0) { - qWarning("QGLContext::bindTexture(): not a DDS image file."); - return 0; - } - - DDSFormat ddsHeader; - f.read((char *) &ddsHeader, sizeof(DDSFormat)); - - if (!ddsHeader.dwLinearSize) { - qWarning("QGLContext::bindTexture() DDS image size is not valid."); - return 0; - } - - int factor = 4; - int bufferSize = 0; - int blockSize = 16; - GLenum format; - - switch(ddsHeader.ddsPixelFormat.dwFourCC) { - case FOURCC_DXT1: - format = GL_COMPRESSED_RGBA_S3TC_DXT1_EXT; - factor = 2; - blockSize = 8; - break; - case FOURCC_DXT3: - format = GL_COMPRESSED_RGBA_S3TC_DXT3_EXT; - break; - case FOURCC_DXT5: - format = GL_COMPRESSED_RGBA_S3TC_DXT5_EXT; - break; - default: - qWarning("QGLContext::bindTexture() DDS image format not supported."); + QGLTexture texture(this); + QSize size = texture.bindCompressedTexture(fileName); + if (!size.isValid()) return 0; - } - - if (ddsHeader.dwMipMapCount > 1) - bufferSize = ddsHeader.dwLinearSize * factor; - else - bufferSize = ddsHeader.dwLinearSize; - - GLubyte *pixels = (GLubyte *) malloc(bufferSize*sizeof(GLubyte)); - f.seek(ddsHeader.dwSize + 4); - f.read((char *) pixels, bufferSize); - f.close(); - - GLuint tx_id; - glGenTextures(1, &tx_id); - glBindTexture(GL_TEXTURE_2D, tx_id); - glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); - glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); - - int size; - int offset = 0; - int w = ddsHeader.dwWidth; - int h = ddsHeader.dwHeight; - // load mip-maps - for(int i = 0; i < (int) ddsHeader.dwMipMapCount; ++i) { - if (w == 0) w = 1; - if (h == 0) h = 1; - - size = ((w+3)/4) * ((h+3)/4) * blockSize; - qt_glCompressedTexImage2DARB(GL_TEXTURE_2D, i, format, w, h, 0, - size, pixels + offset); - offset += size; - - // half size for each mip-map level - w = w/2; - h = h/2; - } - - free(pixels); - - qgl_dds_cache()->insert(fileName, tx_id); - return tx_id; + dds_cache->insert(fileName, texture.id); + return texture.id; } static inline QRgb qt_gl_convertToGLFormatHelper(QRgb src_pixel, GLenum texture_format) @@ -2593,17 +2505,20 @@ GLuint QGLContext::bindTexture(const QPixmap &pixmap, QMacCompatGLenum target, Q */ void QGLContext::deleteTexture(GLuint id) { + Q_D(QGLContext); + if (QGLTextureCache::instance()->remove(this, id)) return; // check the DDS cache if the texture wasn't found in the pixmap/image // cache - QList ddsKeys = qgl_dds_cache()->keys(); + QGLDDSCache *dds_cache = &(d->group->m_dds_cache); + QList ddsKeys = dds_cache->keys(); for (int i = 0; i < ddsKeys.size(); ++i) { - GLuint texture = qgl_dds_cache()->value(ddsKeys.at(i)); + GLuint texture = dds_cache->value(ddsKeys.at(i)); if (id == texture) { glDeleteTextures(1, &texture); - qgl_dds_cache()->remove(ddsKeys.at(i)); + dds_cache->remove(ddsKeys.at(i)); return; } } @@ -4907,8 +4822,14 @@ void QGLExtensions::init_extensions() glExtensions |= SampleBuffers; if (extensions.contains("GL_SGIS_generate_mipmap")) glExtensions |= GenerateMipmap; - if (extensions.contains("GL_EXT_texture_compression_s3tc")) + if (extensions.contains("GL_ARB_texture_compression")) glExtensions |= TextureCompression; + if (extensions.contains("GL_EXT_texture_compression_s3tc")) + glExtensions |= DDSTextureCompression; + if (extensions.contains("GL_OES_compressed_ETC1_RGB8_texture")) + glExtensions |= ETC1TextureCompression; + if (extensions.contains("GL_IMG_texture_compression_pvrtc")) + glExtensions |= PVRTCTextureCompression; if (extensions.contains("GL_ARB_fragment_program")) glExtensions |= FragmentProgram; if (extensions.contains("GL_ARB_texture_mirrored_repeat")) @@ -4951,12 +4872,6 @@ void QGLExtensions::init_extensions() if (extensions.contains("GL_EXT_bgra")) glExtensions |= BGRATextureFormat; - - - QGLContext cx(QGLFormat::defaultFormat()); - if (glExtensions & TextureCompression) { - qt_glCompressedTexImage2DARB = (pfn_glCompressedTexImage2DARB) cx.getProcAddress(QLatin1String("glCompressedTexImage2DARB")); - } } /* @@ -5112,4 +5027,340 @@ void QGLSharedResourceGuard::setContext(const QGLContext *context) } } +QSize QGLTexture::bindCompressedTexture + (const QString& fileName, const char *format) +{ + QFile file(fileName); + if (!file.open(QIODevice::ReadOnly)) + return QSize(); + QByteArray contents = file.readAll(); + file.close(); + return bindCompressedTexture + (contents.constData(), contents.size(), format); +} + +// PVR header format for container files that store textures compressed +// with the ETC1, PVRTC2, and PVRTC4 encodings. Format information from the +// PowerVR SDK at http://www.imgtec.com/powervr/insider/powervr-sdk.asp +// "PVRTexTool Reference Manual, version 1.11f". +struct PvrHeader +{ + quint32 headerSize; + quint32 height; + quint32 width; + quint32 mipMapCount; + quint32 flags; + quint32 dataSize; + quint32 bitsPerPixel; + quint32 redMask; + quint32 greenMask; + quint32 blueMask; + quint32 alphaMask; + quint32 magic; + quint32 surfaceCount; +}; + +#define PVR_MAGIC 0x21525650 // "PVR!" in little-endian + +#define PVR_FORMAT_MASK 0x000000FF +#define PVR_FORMAT_PVRTC2 0x00000018 +#define PVR_FORMAT_PVRTC4 0x00000019 +#define PVR_FORMAT_ETC1 0x00000036 + +#define PVR_HAS_MIPMAPS 0x00000100 +#define PVR_TWIDDLED 0x00000200 +#define PVR_NORMAL_MAP 0x00000400 +#define PVR_BORDER_ADDED 0x00000800 +#define PVR_CUBE_MAP 0x00001000 +#define PVR_FALSE_COLOR_MIPMAPS 0x00002000 +#define PVR_VOLUME_TEXTURE 0x00004000 +#define PVR_ALPHA_IN_TEXTURE 0x00008000 +#define PVR_VERTICAL_FLIP 0x00010000 + +#ifndef GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG +#define GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG 0x8C00 +#define GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG 0x8C01 +#define GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG 0x8C02 +#define GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG 0x8C03 +#endif + +#ifndef GL_ETC1_RGB8_OES +#define GL_ETC1_RGB8_OES 0x8D64 +#endif + +bool QGLTexture::canBindCompressedTexture + (const char *buf, int len, const char *format, bool *hasAlpha) +{ + if (QSysInfo::ByteOrder != QSysInfo::LittleEndian) { + // Compressed texture loading only supported on little-endian + // systems such as x86 and ARM at the moment. + return false; + } + if (!format) { + // Auto-detect the format from the header. + if (len >= 4 && !qstrncmp(buf, "DDS ", 4)) { + *hasAlpha = true; + return true; + } else if (len >= 52 && !qstrncmp(buf + 44, "PVR!", 4)) { + const PvrHeader *pvrHeader = + reinterpret_cast(buf); + *hasAlpha = (pvrHeader->alphaMask != 0); + return true; + } + } else { + // Validate the format against the header. + if (!qstricmp(format, "DDS")) { + if (len >= 4 && !qstrncmp(buf, "DDS ", 4)) { + *hasAlpha = true; + return true; + } + } else if (!qstricmp(format, "PVR") || !qstricmp(format, "ETC1")) { + if (len >= 52 && !qstrncmp(buf + 44, "PVR!", 4)) { + const PvrHeader *pvrHeader = + reinterpret_cast(buf); + *hasAlpha = (pvrHeader->alphaMask != 0); + return true; + } + } + } + return false; +} + +#define ctx QGLContext::currentContext() + +QSize QGLTexture::bindCompressedTexture + (const char *buf, int len, const char *format) +{ + if (QSysInfo::ByteOrder != QSysInfo::LittleEndian) { + // Compressed texture loading only supported on little-endian + // systems such as x86 and ARM at the moment. + return QSize(); + } +#if !defined(QT_OPENGL_ES) + if (!glCompressedTexImage2D) { + if (!(QGLExtensions::glExtensions & QGLExtensions::TextureCompression)) { + qWarning("QGLContext::bindTexture(): The GL implementation does " + "not support texture compression extensions."); + return QSize(); + } + glCompressedTexImage2D = (_glCompressedTexImage2DARB) ctx->getProcAddress(QLatin1String("glCompressedTexImage2DARB")); + if (!glCompressedTexImage2D) { + qWarning("QGLContext::bindTexture(): could not resolve " + "glCompressedTexImage2DARB."); + return QSize(); + } + } +#endif + if (!format) { + // Auto-detect the format from the header. + if (len >= 4 && !qstrncmp(buf, "DDS ", 4)) + return bindCompressedTextureDDS(buf, len); + else if (len >= 52 && !qstrncmp(buf + 44, "PVR!", 4)) + return bindCompressedTexturePVR(buf, len); + } else { + // Validate the format against the header. + if (!qstricmp(format, "DDS")) { + if (len >= 4 && !qstrncmp(buf, "DDS ", 4)) + return bindCompressedTextureDDS(buf, len); + } else if (!qstricmp(format, "PVR") || !qstricmp(format, "ETC1")) { + if (len >= 52 && !qstrncmp(buf + 44, "PVR!", 4)) + return bindCompressedTexturePVR(buf, len); + } + } + return QSize(); +} + +QSize QGLTexture::bindCompressedTextureDDS(const char *buf, int len) +{ + // We only support 2D texture loading at present. + if (target != GL_TEXTURE_2D) + return QSize(); + + // Bail out if the necessary extension is not present. + if (!(QGLExtensions::glExtensions & QGLExtensions::DDSTextureCompression)) { + qWarning("QGLContext::bindTexture(): DDS texture compression is not supported."); + return QSize(); + } + + const DDSFormat *ddsHeader = reinterpret_cast(buf + 4); + if (!ddsHeader->dwLinearSize) { + qWarning("QGLContext::bindTexture(): DDS image size is not valid."); + return QSize(); + } + + int blockSize = 16; + GLenum format; + + switch(ddsHeader->ddsPixelFormat.dwFourCC) { + case FOURCC_DXT1: + format = GL_COMPRESSED_RGBA_S3TC_DXT1_EXT; + blockSize = 8; + break; + case FOURCC_DXT3: + format = GL_COMPRESSED_RGBA_S3TC_DXT3_EXT; + break; + case FOURCC_DXT5: + format = GL_COMPRESSED_RGBA_S3TC_DXT5_EXT; + break; + default: + qWarning("QGLContext::bindTexture(): DDS image format not supported."); + return QSize(); + } + + const GLubyte *pixels = + reinterpret_cast(buf + ddsHeader->dwSize + 4); + + glGenTextures(1, &id); + glBindTexture(GL_TEXTURE_2D, id); + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); + + int size; + int offset = 0; + int available = len - int(ddsHeader->dwSize + 4); + int w = ddsHeader->dwWidth; + int h = ddsHeader->dwHeight; + + // load mip-maps + for(int i = 0; i < (int) ddsHeader->dwMipMapCount; ++i) { + if (w == 0) w = 1; + if (h == 0) h = 1; + + size = ((w+3)/4) * ((h+3)/4) * blockSize; + if (size > available) + break; + glCompressedTexImage2D(GL_TEXTURE_2D, i, format, w, h, 0, + size, pixels + offset); + offset += size; + available -= size; + + // half size for each mip-map level + w = w/2; + h = h/2; + } + + // DDS images are not inverted. + options &= ~QGLContext::InvertedYBindOption; + + return QSize(ddsHeader->dwWidth, ddsHeader->dwHeight); +} + +QSize QGLTexture::bindCompressedTexturePVR(const char *buf, int len) +{ + // We only support 2D texture loading at present. Cube maps later. + if (target != GL_TEXTURE_2D) + return QSize(); + + // Determine which texture format we will be loading. + const PvrHeader *pvrHeader = reinterpret_cast(buf); + GLenum textureFormat; + quint32 minWidth, minHeight; + switch (pvrHeader->flags & PVR_FORMAT_MASK) { + case PVR_FORMAT_PVRTC2: + if (pvrHeader->alphaMask) + textureFormat = GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG; + else + textureFormat = GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG; + minWidth = 16; + minHeight = 8; + break; + + case PVR_FORMAT_PVRTC4: + if (pvrHeader->alphaMask) + textureFormat = GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG; + else + textureFormat = GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG; + minWidth = 8; + minHeight = 8; + break; + + case PVR_FORMAT_ETC1: + textureFormat = GL_ETC1_RGB8_OES; + minWidth = 4; + minHeight = 4; + break; + + default: + qWarning("QGLContext::bindTexture(): PVR image format 0x%x not supported.", int(pvrHeader->flags & PVR_FORMAT_MASK)); + return QSize(); + } + + // Bail out if the necessary extension is not present. + if (textureFormat == GL_ETC1_RGB8_OES) { + if (!(QGLExtensions::glExtensions & + QGLExtensions::ETC1TextureCompression)) { + qWarning("QGLContext::bindTexture(): ETC1 texture compression is not supported."); + return QSize(); + } + } else { + if (!(QGLExtensions::glExtensions & + QGLExtensions::PVRTCTextureCompression)) { + qWarning("QGLContext::bindTexture(): PVRTC texture compression is not supported."); + return QSize(); + } + } + + // Boundary check on the buffer size. + quint32 bufferSize = pvrHeader->headerSize + pvrHeader->dataSize; + if (bufferSize > quint32(len)) { + qWarning("QGLContext::bindTexture(): PVR image size is not valid."); + return QSize(); + } + + // Create the texture. + glPixelStorei(GL_UNPACK_ALIGNMENT, 1); + glGenTextures(1, &id); + glBindTexture(GL_TEXTURE_2D, id); + if (pvrHeader->mipMapCount) { + if ((options & QGLContext::LinearFilteringBindOption) != 0) { + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR); + } else { + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST_MIPMAP_NEAREST); + } + } else if ((options & QGLContext::LinearFilteringBindOption) != 0) { + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); + } else { + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); + } + + // Load the compressed mipmap levels. + const GLubyte *buffer = + reinterpret_cast(buf + pvrHeader->headerSize); + bufferSize = pvrHeader->dataSize; + quint32 level = 0; + quint32 width = pvrHeader->width; + quint32 height = pvrHeader->height; + while (bufferSize > 0 && level < pvrHeader->mipMapCount) { + quint32 size = + (qMax(width, minWidth) * qMax(height, minHeight) * + pvrHeader->bitsPerPixel) / 8; + if (size > bufferSize) + break; + glCompressedTexImage2D(GL_TEXTURE_2D, GLint(level), textureFormat, + GLsizei(width), GLsizei(height), 0, + GLsizei(size), buffer); + width /= 2; + height /= 2; + buffer += size; + ++level; + } + + // Restore the default pixel alignment for later texture uploads. + glPixelStorei(GL_UNPACK_ALIGNMENT, 4); + + // Set the invert flag for the texture. + if ((pvrHeader->flags & PVR_VERTICAL_FLIP) != 0) + options |= QGLContext::InvertedYBindOption; + else + options &= ~QGLContext::InvertedYBindOption; + + return QSize(pvrHeader->width, pvrHeader->height); +} + +#undef ctx + QT_END_NAMESPACE diff --git a/src/opengl/qgl_p.h b/src/opengl/qgl_p.h index b2407ba..0f785a5 100644 --- a/src/opengl/qgl_p.h +++ b/src/opengl/qgl_p.h @@ -222,6 +222,8 @@ public: class QGLContextResource; class QGLSharedResourceGuard; +typedef QHash QGLDDSCache; + // QGLContextPrivate has the responsibility of creating context groups. // QGLContextPrivate and QGLShareRegister will both maintain the reference counter and destroy // context groups when needed. @@ -246,6 +248,7 @@ private: QHash m_resources; QGLSharedResourceGuard *m_guards; // double-linked list of active guards. QAtomicInt m_refs; + QGLDDSCache m_dds_cache; void cleanupResources(const QGLContext *ctx); @@ -377,7 +380,10 @@ public: PixelBufferObject = 0x00000800, FramebufferBlit = 0x00001000, NPOTTextures = 0x00002000, - BGRATextureFormat = 0x00004000 + BGRATextureFormat = 0x00004000, + DDSTextureCompression = 0x00008000, + ETC1TextureCompression = 0x00010000, + PVRTCTextureCompression = 0x00020000 }; Q_DECLARE_FLAGS(Extensions, Extension) @@ -482,6 +488,14 @@ public: QPixmapData* boundPixmap; #endif + bool canBindCompressedTexture + (const char *buf, int len, const char *format, bool *hasAlpha); + QSize bindCompressedTexture + (const QString& fileName, const char *format = 0); + QSize bindCompressedTexture + (const char *buf, int len, const char *format = 0); + QSize bindCompressedTextureDDS(const char *buf, int len); + QSize bindCompressedTexturePVR(const char *buf, int len); }; class QGLTextureCache { diff --git a/src/opengl/qglextensions_p.h b/src/opengl/qglextensions_p.h index 3510765..62e216c 100644 --- a/src/opengl/qglextensions_p.h +++ b/src/opengl/qglextensions_p.h @@ -184,6 +184,10 @@ typedef void (APIENTRY *_glBlitFramebufferEXT) (int srcX0, int srcY0, int srcX1, typedef void (APIENTRY *_glRenderbufferStorageMultisampleEXT) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); +// ARB_texture_compression +typedef void (APIENTRY *_glCompressedTexImage2DARB) (GLenum, GLint, GLenum, GLsizei, + GLsizei, GLint, GLsizei, const GLvoid *); + QT_BEGIN_NAMESPACE struct QGLExtensionFuncs @@ -289,6 +293,11 @@ struct QGLExtensionFuncs #endif qt_glMapBufferARB = 0; qt_glUnmapBufferARB = 0; + +#if !defined(QT_OPENGL_ES) + // Texture compression + qt_glCompressedTexImage2DARB = 0; +#endif } @@ -397,6 +406,10 @@ struct QGLExtensionFuncs _glMapBufferARB qt_glMapBufferARB; _glUnmapBufferARB qt_glUnmapBufferARB; +#if !defined(QT_OPENGL_ES) + // Texture compression + _glCompressedTexImage2DARB qt_glCompressedTexImage2DARB; +#endif }; @@ -732,6 +745,10 @@ struct QGLExtensionFuncs #define glClearDepth glClearDepthf #endif +#if !defined(QT_OPENGL_ES) +#define glCompressedTexImage2D QGLContextPrivate::extensionFuncs(ctx).qt_glCompressedTexImage2DARB +#endif + extern bool qt_resolve_framebufferobject_extensions(QGLContext *ctx); bool qt_resolve_buffer_extensions(QGLContext *ctx); diff --git a/src/opengl/qpixmapdata_gl.cpp b/src/opengl/qpixmapdata_gl.cpp index ab17789..0299cea 100644 --- a/src/opengl/qpixmapdata_gl.cpp +++ b/src/opengl/qpixmapdata_gl.cpp @@ -53,6 +53,8 @@ #include #include +#include +#include QT_BEGIN_NAMESPACE @@ -407,6 +409,61 @@ void QGLPixmapData::fromImage(const QImage &image, } } +bool QGLPixmapData::fromFile(const QString &filename, const char *format, + Qt::ImageConversionFlags flags) +{ + if (pixelType() == QPixmapData::BitmapType) + return QPixmapData::fromFile(filename, format, flags); + QFile file(filename); + if (!file.open(QIODevice::ReadOnly)) + return false; + QByteArray data = file.peek(64); + bool alpha; + if (m_texture.canBindCompressedTexture + (data.constData(), data.size(), format, &alpha)) { + resize(0, 0); + data = file.readAll(); + file.close(); + QSize size = m_texture.bindCompressedTexture + (data.constData(), data.size(), format); + if (!size.isEmpty()) { + w = size.width(); + h = size.height(); + is_null = false; + d = 32; + m_hasAlpha = alpha; + m_source = QImage(); + m_dirty = isValid(); + return true; + } + return false; + } + fromImage(QImageReader(&file, format).read(), flags); + return !isNull(); +} + +bool QGLPixmapData::fromData(const uchar *buffer, uint len, const char *format, + Qt::ImageConversionFlags flags) +{ + bool alpha; + const char *buf = reinterpret_cast(buffer); + if (m_texture.canBindCompressedTexture(buf, int(len), format, &alpha)) { + resize(0, 0); + QSize size = m_texture.bindCompressedTexture(buf, int(len), format); + if (!size.isEmpty()) { + w = size.width(); + h = size.height(); + is_null = false; + d = 32; + m_hasAlpha = alpha; + m_source = QImage(); + m_dirty = isValid(); + return true; + } + } + return QPixmapData::fromData(buffer, len, format, flags); +} + bool QGLPixmapData::scroll(int dx, int dy, const QRect &rect) { Q_UNUSED(dx); diff --git a/src/opengl/qpixmapdata_gl_p.h b/src/opengl/qpixmapdata_gl_p.h index 8a13e03..007c52a 100644 --- a/src/opengl/qpixmapdata_gl_p.h +++ b/src/opengl/qpixmapdata_gl_p.h @@ -106,6 +106,10 @@ public: // Re-implemented from QPixmapData: void resize(int width, int height); void fromImage(const QImage &image, Qt::ImageConversionFlags flags); + bool fromFile(const QString &filename, const char *format, + Qt::ImageConversionFlags flags); + bool fromData(const uchar *buffer, uint len, const char *format, + Qt::ImageConversionFlags flags); void copy(const QPixmapData *data, const QRect &rect); bool scroll(int dx, int dy, const QRect &rect); void fill(const QColor &color); -- cgit v0.12 From 28206b2ec077396bc1fafffa4d85cab505f4409a Mon Sep 17 00:00:00 2001 From: Rhys Weatherley Date: Mon, 7 Dec 2009 08:13:47 +1000 Subject: Change file update for compressed texture support. --- dist/changes-4.6.1 | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/dist/changes-4.6.1 b/dist/changes-4.6.1 index 6896358..5efa0e2 100644 --- a/dist/changes-4.6.1 +++ b/dist/changes-4.6.1 @@ -46,8 +46,11 @@ QtCore QtGui ----- - - foo - * bar + - QPixmap + * load() and loadFromData() can now support compressed GL textures + in the DDS, ETC1, PVRTC2, and PVRTC4 formats if the OpenGL graphics + system is active and the appropriate extensions are present in the + GL implementation. QtDBus ------ @@ -64,8 +67,10 @@ QtNetwork QtOpenGL -------- - - foo - * bar + - QGLContext + * bindTexture(QString) now supports DDS, ETC1, PVRTC2, and PVRTC4 + compressed textures if the appropriate extensions are present + in the GL implementation. QtScript -------- -- cgit v0.12 From 8f27913d0558c96a781b81834396374318b70fd6 Mon Sep 17 00:00:00 2001 From: Rhys Weatherley Date: Mon, 7 Dec 2009 08:32:53 +1000 Subject: Automatically destroy VG pixmaps when the last window surface goes away Under S60, Qt will destroy the window surfaces of an application that goes into the background, which frees up EGL surface objects. But the VGImage's for pixmaps, and the EGLContext, were still using GPU memory. This change keeps track of the number of widgets / window surfaces that are in use and then calls hibernate() on all QVGPixmapData objects when it goes to zero. Once all the VGImage's are destroyed, the EGLContext should also be destroyed. Task-number: QT-2555 Reviewed-by: Sarah Smith --- src/openvg/qpixmapdata_vg.cpp | 33 ++++++++-- src/openvg/qpixmapdata_vg_p.h | 31 ++++++++- src/openvg/qvg_p.h | 10 ++- src/openvg/qwindowsurface_vgegl.cpp | 124 ++++++++++++++++++++++++++++++------ 4 files changed, 169 insertions(+), 29 deletions(-) diff --git a/src/openvg/qpixmapdata_vg.cpp b/src/openvg/qpixmapdata_vg.cpp index 19c90ed..5d5fcbf 100644 --- a/src/openvg/qpixmapdata_vg.cpp +++ b/src/openvg/qpixmapdata_vg.cpp @@ -65,12 +65,21 @@ QVGPixmapData::QVGPixmapData(PixelType type) recreate = true; #if !defined(QT_NO_EGL) context = 0; + qt_vg_register_pixmap(this); #endif setSerialNumber(++qt_vg_pixmap_serial); } QVGPixmapData::~QVGPixmapData() { + destroyImageAndContext(); +#if !defined(QT_NO_EGL) + qt_vg_unregister_pixmap(this); +#endif +} + +void QVGPixmapData::destroyImageAndContext() +{ if (vgImage != VG_INVALID_HANDLE) { // We need to have a context current to destroy the image. #if !defined(QT_NO_EGL) @@ -93,11 +102,16 @@ QVGPixmapData::~QVGPixmapData() if (vgImageOpacity != VG_INVALID_HANDLE) vgDestroyImage(vgImageOpacity); #endif + vgImage = VG_INVALID_HANDLE; + vgImageOpacity = VG_INVALID_HANDLE; } #if !defined(QT_NO_EGL) - if (context) - qt_vg_destroy_context(context); + if (context) { + qt_vg_destroy_context(context, QInternal::Pixmap); + context = 0; + } #endif + recreate = true; } QPixmapData *QVGPixmapData::createCompatiblePixmapData() const @@ -217,7 +231,7 @@ VGImage QVGPixmapData::toVGImage() #if !defined(QT_NO_EGL) // Increase the reference count on the shared context. if (!context) - context = qt_vg_create_context(0); + context = qt_vg_create_context(0, QInternal::Pixmap); #endif if (recreate && prevSize != QSize(w, h)) { @@ -286,6 +300,17 @@ VGImage QVGPixmapData::toVGImage(qreal opacity) #endif } +void QVGPixmapData::hibernate() +{ + // If the image was imported (e.g, from an SgImage under Symbian), + // then we cannot copy it back to main memory for storage. + if (vgImage != VG_INVALID_HANDLE && source.isNull()) + return; + + forceToImage(); + destroyImageAndContext(); +} + extern int qt_defaultDpiX(); extern int qt_defaultDpiY(); @@ -376,7 +401,7 @@ void QVGPixmapData::fromNativeType(void* pixmap, NativeType type) // when "0" used as argument then // default display, context are used if (!context) - context = qt_vg_create_context(0); + context = qt_vg_create_context(0, QInternal::Pixmap); if (vgImage != VG_INVALID_HANDLE) { vgDestroyImage(vgImage); diff --git a/src/openvg/qpixmapdata_vg_p.h b/src/openvg/qpixmapdata_vg_p.h index fe19f35..c0bb098 100644 --- a/src/openvg/qpixmapdata_vg_p.h +++ b/src/openvg/qpixmapdata_vg_p.h @@ -55,8 +55,6 @@ #include #include -#if !defined(QT_NO_EGL) -#endif #if defined(Q_OS_SYMBIAN) class RSGImage; @@ -66,6 +64,15 @@ QT_BEGIN_NAMESPACE class QEglContext; +#if !defined(QT_NO_EGL) +class QVGPixmapData; +class QVGSharedContext; + +void qt_vg_register_pixmap(QVGPixmapData *pd); +void qt_vg_unregister_pixmap(QVGPixmapData *pd); +void qt_vg_hibernate_pixmaps(QVGSharedContext *context); +#endif + class Q_OPENVG_EXPORT QVGPixmapData : public QPixmapData { public: @@ -94,6 +101,14 @@ public: // Return the VGImage form for a specific opacity setting. virtual VGImage toVGImage(qreal opacity); + // Release the VG resources associated with this pixmap and copy + // the pixmap's contents out of the GPU back into main memory. + // The VG resource will be automatically recreated the next time + // toVGImage() is called. Does nothing if the pixmap cannot be + // hibernated for some reason (e.g. VGImage is shared with another + // process via a SgImage). + virtual void hibernate(); + QSize size() const { return QSize(w, h); } #if defined(Q_OS_SYMBIAN) @@ -108,6 +123,16 @@ protected: void cleanup(); #endif +#if !defined(QT_NO_EGL) +private: + QVGPixmapData *next; + QVGPixmapData *prev; + + friend void qt_vg_register_pixmap(QVGPixmapData *pd); + friend void qt_vg_unregister_pixmap(QVGPixmapData *pd); + friend void qt_vg_hibernate_pixmaps(QVGSharedContext *context); +#endif + protected: QSize prevSize; VGImage vgImage; @@ -121,6 +146,8 @@ protected: void forceToImage(); QImage::Format sourceFormat() const; + + void destroyImageAndContext(); }; QT_END_NAMESPACE diff --git a/src/openvg/qvg_p.h b/src/openvg/qvg_p.h index 04e2bab..3577013 100644 --- a/src/openvg/qvg_p.h +++ b/src/openvg/qvg_p.h @@ -71,11 +71,17 @@ class QEglContext; // Create an EGL context, but don't bind it to a surface. If single-context // mode is enabled, this will return the previously-created context. -Q_OPENVG_EXPORT QEglContext *qt_vg_create_context(QPaintDevice *device); +// "devType" indicates the type of device using the context, usually +// QInternal::Widget or QInternal::Pixmap. +Q_OPENVG_EXPORT QEglContext *qt_vg_create_context + (QPaintDevice *device, int devType); // Destroy an EGL context that was created by qt_vg_create_context(). // If single-context mode is enabled, this will decrease the reference count. -Q_OPENVG_EXPORT void qt_vg_destroy_context(QEglContext *context); +// "devType" indicates the type of device destroying the context, usually +// QInternal::Widget or QInternal::Pixmap. +Q_OPENVG_EXPORT void qt_vg_destroy_context + (QEglContext *context, int devType); // Return the shared pbuffer surface that can be made current to // destroy VGImage objects when there is no other surface available. diff --git a/src/openvg/qwindowsurface_vgegl.cpp b/src/openvg/qwindowsurface_vgegl.cpp index 62871cf..1571083 100644 --- a/src/openvg/qwindowsurface_vgegl.cpp +++ b/src/openvg/qwindowsurface_vgegl.cpp @@ -111,15 +111,19 @@ public: QEglContext *context; int refCount; + int widgetRefCount; QVGPaintEngine *engine; EGLSurface surface; + QVGPixmapData *firstPixmap; }; QVGSharedContext::QVGSharedContext() : context(0) , refCount(0) + , widgetRefCount(0) , engine(0) , surface(EGL_NO_SURFACE) + , firstPixmap(0) { } @@ -154,6 +158,28 @@ void qt_vg_destroy_paint_engine(QVGPaintEngine *engine) Q_UNUSED(engine); } +void qt_vg_register_pixmap(QVGPixmapData *pd) +{ + QVGSharedContext *shared = sharedContext(); + pd->next = shared->firstPixmap; + pd->prev = 0; + if (shared->firstPixmap) + shared->firstPixmap->prev = pd; + shared->firstPixmap = pd; +} + +void qt_vg_unregister_pixmap(QVGPixmapData *pd) +{ + if (pd->next) + pd->next->prev = pd->prev; + if (pd->prev) { + pd->prev->next = pd->next; + } else { + QVGSharedContext *shared = sharedContext(); + shared->firstPixmap = pd->next; + } +} + #else QVGPaintEngine *qt_vg_create_paint_engine(void) @@ -166,6 +192,16 @@ void qt_vg_destroy_paint_engine(QVGPaintEngine *engine) delete engine; } +void qt_vg_register_pixmap(QVGPixmapData *pd) +{ + Q_UNUSED(pd); +} + +void qt_vg_unregister_pixmap(QVGPixmapData *pd) +{ + Q_UNUSED(pd); +} + #endif #ifdef EGL_VG_ALPHA_FORMAT_PRE_BIT @@ -278,9 +314,11 @@ static QEglContext *createContext(QPaintDevice *device) #if !defined(QVG_NO_SINGLE_CONTEXT) -QEglContext *qt_vg_create_context(QPaintDevice *device) +QEglContext *qt_vg_create_context(QPaintDevice *device, int devType) { QVGSharedContext *shared = sharedContext(); + if (devType == QInternal::Widget) + ++(shared->widgetRefCount); if (shared->context) { ++(shared->refCount); return shared->context; @@ -291,23 +329,65 @@ QEglContext *qt_vg_create_context(QPaintDevice *device) } } -void qt_vg_destroy_context(QEglContext *context) +static void qt_vg_destroy_shared_context(QVGSharedContext *shared) +{ + shared->context->makeCurrent(qt_vg_shared_surface()); + delete shared->engine; + shared->engine = 0; + shared->context->doneCurrent(); + if (shared->surface != EGL_NO_SURFACE) { + eglDestroySurface(shared->context->display(), shared->surface); + shared->surface = EGL_NO_SURFACE; + } + delete shared->context; + shared->context = 0; +} + +void qt_vg_hibernate_pixmaps(QVGSharedContext *shared) +{ + // Artificially increase the reference count to prevent the + // context from being destroyed until after we have finished + // the hibernation process. + ++(shared->refCount); + + // We need a context current to hibernate the VGImage objects. + shared->context->makeCurrent(qt_vg_shared_surface()); + + // Scan all QVGPixmapData objects in the system and hibernate them. + QVGPixmapData *pd = shared->firstPixmap; + while (pd != 0) { + pd->hibernate(); + pd = pd->next; + } + + // Don't need the current context any more. + shared->context->lazyDoneCurrent(); + + // Decrease the reference count and destroy the context if necessary. + if (--(shared->refCount) <= 0) + qt_vg_destroy_shared_context(shared); +} + +void qt_vg_destroy_context(QEglContext *context, int devType) { QVGSharedContext *shared = sharedContext(); if (shared->context != context) { // This is not the shared context. Shouldn't happen! delete context; - } else if (--(shared->refCount) <= 0) { - shared->context->makeCurrent(qt_vg_shared_surface()); - delete shared->engine; - shared->engine = 0; - shared->context->doneCurrent(); - if (shared->surface != EGL_NO_SURFACE) { - eglDestroySurface(shared->context->display(), shared->surface); - shared->surface = EGL_NO_SURFACE; - } - delete shared->context; - shared->context = 0; + return; + } + if (devType == QInternal::Widget) + --(shared->widgetRefCount); + if (--(shared->refCount) <= 0) { + qt_vg_destroy_shared_context(shared); + } else if (shared->widgetRefCount <= 0 && devType == QInternal::Widget) { + // All of the widget window surfaces have been destroyed + // but we still have VG pixmaps active. Ask them to hibernate + // to free up GPU resources until a widget is shown again. + // This may eventually cause the EGLContext to be destroyed + // because nothing in the system needs a context, which will + // free up even more GPU resources. + qt_vg_hibernate_pixmaps(shared); } } @@ -338,13 +418,15 @@ EGLSurface qt_vg_shared_surface(void) #else -QEglContext *qt_vg_create_context(QPaintDevice *device) +QEglContext *qt_vg_create_context(QPaintDevice *device, int devType) { + Q_UNUSED(devType); return createContext(device); } -void qt_vg_destroy_context(QEglContext *context) +void qt_vg_destroy_context(QEglContext *context, int devType) { + Q_UNUSED(devType); delete context; } @@ -434,7 +516,7 @@ QVGEGLWindowSurfaceVGImage::~QVGEGLWindowSurfaceVGImage() } if (windowSurface != EGL_NO_SURFACE) context->destroySurface(windowSurface); - qt_vg_destroy_context(context); + qt_vg_destroy_context(context, QInternal::Widget); } } @@ -453,7 +535,7 @@ QEglContext *QVGEGLWindowSurfaceVGImage::ensureContext(QWidget *widget) if (!context) { // Create a new EGL context. We create the surface in beginPaint(). size = newSize; - context = qt_vg_create_context(widget); + context = qt_vg_create_context(widget, QInternal::Widget); if (!context) return 0; isPaintingActive = false; @@ -548,7 +630,7 @@ QVGEGLWindowSurfaceDirect::~QVGEGLWindowSurfaceDirect() if (context) { if (windowSurface != EGL_NO_SURFACE) context->destroySurface(windowSurface); - qt_vg_destroy_context(context); + qt_vg_destroy_context(context, QInternal::Widget); } } @@ -587,7 +669,7 @@ QEglContext *QVGEGLWindowSurfaceDirect::ensureContext(QWidget *widget) qt_vg_destroy_paint_engine(engine); engine = 0; context->destroySurface(windowSurface); - qt_vg_destroy_context(context); + qt_vg_destroy_context(context, QInternal::Widget); context = 0; windowSurface = EGL_NO_SURFACE; } @@ -596,7 +678,7 @@ QEglContext *QVGEGLWindowSurfaceDirect::ensureContext(QWidget *widget) if (!context) { // Create a new EGL context and bind it to the widget surface. size = newSize; - context = qt_vg_create_context(widget); + context = qt_vg_create_context(widget, QInternal::Widget); if (!context) return 0; // We want a direct to window rendering surface if possible. @@ -613,7 +695,7 @@ QEglContext *QVGEGLWindowSurfaceDirect::ensureContext(QWidget *widget) #endif EGLSurface surface = context->createSurface(widget, &surfaceProps); if (surface == EGL_NO_SURFACE) { - qt_vg_destroy_context(context); + qt_vg_destroy_context(context, QInternal::Widget); context = 0; return 0; } -- cgit v0.12 From 8fea31ca0ab98ef6fed7bb2d87d97f4f425b2078 Mon Sep 17 00:00:00 2001 From: Rhys Weatherley Date: Mon, 7 Dec 2009 10:07:13 +1000 Subject: Detect GL2 paint engine based on fragment shaders, not programs The auto-detect logic was looking for fragment programs to check for OpenGL2 support. It should have been looking for fragment shaders. Task-number: QTBUG-5638 Reviewed-by: Sarah Smith --- src/opengl/qgl.cpp | 7 +++++-- src/opengl/qgl_p.h | 3 ++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/opengl/qgl.cpp b/src/opengl/qgl.cpp index b376901..1ff102f 100644 --- a/src/opengl/qgl.cpp +++ b/src/opengl/qgl.cpp @@ -173,12 +173,12 @@ public: #else // We can't do this in the constructor for this object because it // needs to be called *before* the QApplication constructor. - // Also check for the FragmentProgram extension in conjunction with + // Also check for the FragmentShader extension in conjunction with // the 2.0 version flag, to cover the case where we export the display // from an old GL 1.1 server to a GL 2.x client. In that case we can't // use GL 2.0. if ((QGLFormat::openGLVersionFlags() & QGLFormat::OpenGL_Version_2_0) - && (QGLExtensions::glExtensions & QGLExtensions::FragmentProgram) + && (QGLExtensions::glExtensions & QGLExtensions::FragmentShader) && qgetenv("QT_GL_USE_OPENGL1ENGINE").isEmpty()) engineType = QPaintEngine::OpenGL2; else @@ -4832,6 +4832,8 @@ void QGLExtensions::init_extensions() glExtensions |= PVRTCTextureCompression; if (extensions.contains("GL_ARB_fragment_program")) glExtensions |= FragmentProgram; + if (extensions.contains("GL_ARB_fragment_shader")) + glExtensions |= FragmentShader; if (extensions.contains("GL_ARB_texture_mirrored_repeat")) glExtensions |= MirroredRepeat; if (extensions.contains("GL_EXT_framebuffer_object")) @@ -4849,6 +4851,7 @@ void QGLExtensions::init_extensions() #if defined(QT_OPENGL_ES_2) glExtensions |= FramebufferObject; glExtensions |= GenerateMipmap; + glExtensions |= FragmentShader; #endif #if defined(QT_OPENGL_ES_1) || defined(QT_OPENGL_ES_1_CL) if (extensions.contains("GL_OES_framebuffer_object")) diff --git a/src/opengl/qgl_p.h b/src/opengl/qgl_p.h index 0f785a5..179d69a 100644 --- a/src/opengl/qgl_p.h +++ b/src/opengl/qgl_p.h @@ -383,7 +383,8 @@ public: BGRATextureFormat = 0x00004000, DDSTextureCompression = 0x00008000, ETC1TextureCompression = 0x00010000, - PVRTCTextureCompression = 0x00020000 + PVRTCTextureCompression = 0x00020000, + FragmentShader = 0x00040000 }; Q_DECLARE_FLAGS(Extensions, Extension) -- cgit v0.12 From 91b4a40bd3cc9d004baddd9c19ced07ed37afef2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sami=20Meril=C3=A4?= Date: Mon, 7 Dec 2009 11:44:03 +0200 Subject: Remove compilation warning from S60pixelMetrics on ARM Compiling s60pixelMetrics utility for ARMV5 urel gives two warnings: a) unused variable - Solution: removed b) transfer of control bypasses initialization (missing brackets within a switch-case) - Solution: brackets added. Reviewed-by: TrustMe --- util/s60pixelmetrics/pixel_metrics.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/util/s60pixelmetrics/pixel_metrics.cpp b/util/s60pixelmetrics/pixel_metrics.cpp index 9507c67..9ba6c8b 100644 --- a/util/s60pixelmetrics/pixel_metrics.cpp +++ b/util/s60pixelmetrics/pixel_metrics.cpp @@ -812,13 +812,12 @@ TInt PixelMetrics::PixelMetricValue(QStyle::PixelMetric metric) value = PixelMetricMenuValue(metric, mainPaneRect); break; case QStyle::PM_ButtonIconSize: + { //lets use voice recorder icons as a base //Unfortunately S60 graphics don't separate button bevel graphics from the actual icon. //Se we have no means to query the margin from bevel border to "central icon" border. //So, we need to make a estimate... - const TInt varietyForButtons = !landscape ? 0 : 1; - TAknLayoutRect vRMainRect; vRMainRect.LayoutRect( mainPaneRect, AknLayoutScalable_Apps::main_vorec_pane() ); @@ -833,7 +832,7 @@ TInt PixelMetrics::PixelMetricValue(QStyle::PixelMetric metric) // 0.32 is the estimate how much the icon occupies of the button bevel area value = vRButtonCellGraphicsRect.Rect().Width() * 0.32; - + } break; case QStyle::PM_SmallIconSize: { -- cgit v0.12 From cfd98763a1d051238382b77975567da0c0562ade Mon Sep 17 00:00:00 2001 From: Paul Olav Tvete Date: Mon, 7 Dec 2009 10:58:58 +0100 Subject: Fix programming error in autotest commit 8529a8cbb setWindowFlags() resets the flags, so the previous version only worked on X11. --- tests/auto/qmenu/tst_qmenu.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tests/auto/qmenu/tst_qmenu.cpp b/tests/auto/qmenu/tst_qmenu.cpp index 6079189..af10ad1 100644 --- a/tests/auto/qmenu/tst_qmenu.cpp +++ b/tests/auto/qmenu/tst_qmenu.cpp @@ -910,8 +910,7 @@ void tst_QMenu::deleteActionInTriggered() void tst_QMenu::pushButtonPopulateOnAboutToShow() { QPushButton b("Test PushButton"); - b.setWindowFlags(Qt::FramelessWindowHint); - b.setWindowFlags(Qt::X11BypassWindowManagerHint); + b.setWindowFlags(Qt::FramelessWindowHint | Qt::X11BypassWindowManagerHint); lastMenu = new QMenu; b.setMenu(lastMenu); const int scrNumber = QApplication::desktop()->screenNumber(&b); -- cgit v0.12 From 245c9cc07ff1581dd126f213985c3557b2667aca Mon Sep 17 00:00:00 2001 From: Janne Anttila Date: Mon, 7 Dec 2009 14:05:01 +0200 Subject: Added dimming support for disabled softkeys in Symbian. If QAction::setEnabled(false) is called, the CBA buttons are dimmed to have visual indication about disabled state. Since enabled/disabled state of buttons in QDialogButtonBox is controlled via QPushButton::setEnabled API, and because button box content in Symbian is mapped to sofkkeys we also need to have proxy for button enabled state to forward the information for underlying QAction. Reviewed-by: Sami Merila --- src/gui/kernel/qsoftkeymanager.cpp | 5 ++++- src/gui/widgets/qdialogbuttonbox.cpp | 28 +++++++++++++++++++++++++++- 2 files changed, 31 insertions(+), 2 deletions(-) diff --git a/src/gui/kernel/qsoftkeymanager.cpp b/src/gui/kernel/qsoftkeymanager.cpp index 30c67f4..464a250 100644 --- a/src/gui/kernel/qsoftkeymanager.cpp +++ b/src/gui/kernel/qsoftkeymanager.cpp @@ -254,7 +254,10 @@ void QSoftKeyManagerPrivate::updateSoftKeys_sys(const QList &softkeys) const int underlineShortCut = QApplication::style()->styleHint(QStyle::SH_UnderlineShortcut); QString iconText = softKeyAction->iconText(); TPtrC text = qt_QString2TPtrC( underlineShortCut ? softKeyAction->text() : iconText); - QT_TRAP_THROWING(nativeContainer->SetCommandL(position, command, text)); + QT_TRAP_THROWING( + nativeContainer->SetCommandL(position, command, text); + nativeContainer->DimCommand(command, !softKeyAction->isEnabled()); + ); } } diff --git a/src/gui/widgets/qdialogbuttonbox.cpp b/src/gui/widgets/qdialogbuttonbox.cpp index 0e859f1..56cf545 100644 --- a/src/gui/widgets/qdialogbuttonbox.cpp +++ b/src/gui/widgets/qdialogbuttonbox.cpp @@ -259,6 +259,30 @@ static const int layouts[2][5][14] = } }; +class QDialogButtonEnabledProxy : public QObject +{ +public: + QDialogButtonEnabledProxy(QObject *parent, QWidget *src, QAction *trg) : QObject(parent), source(src), target(trg) + { + source->installEventFilter(this); + } + ~QDialogButtonEnabledProxy() + { + source->removeEventFilter(this); + } + bool eventFilter(QObject *object, QEvent *event) + { + if (object == source && event->type() == QEvent::EnabledChange) { + target->setEnabled(source->isEnabled()); + } + return false; + }; +private: + QWidget *source; + QAction *target; +}; + + class QDialogButtonBoxPrivate : public QWidgetPrivate { Q_DECLARE_PUBLIC(QDialogButtonBox) @@ -548,7 +572,9 @@ void QDialogButtonBoxPrivate::addButton(QAbstractButton *button, QDialogButtonBo QObject::connect(button, SIGNAL(destroyed()), q, SLOT(_q_handleButtonDestroyed())); buttonLists[role].append(button); #ifdef QT_SOFTKEYS_ENABLED - softKeyActions.insert(button, createSoftKey(button, role)); + QAction *action = createSoftKey(button, role); + softKeyActions.insert(button, action); + new QDialogButtonEnabledProxy(action, button, action); #endif if (doLayout) layoutButtons(); -- cgit v0.12 From 41754fdb11a4d78b7b756b82d4ead235b6618687 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sami=20Meril=C3=A4?= Date: Mon, 7 Dec 2009 14:59:07 +0200 Subject: FEP returns the wrong foreground color in GetFormatOfFepInlineText When using T9, FEP is always using black text color. This is due to that we use default parameters for TFontPresentation. If we change the text color according to style, before calling GetFormatOfFepInlineText, it uses color value from style. Task-number: QTBUG-4072 Reviewed-by: axis --- src/gui/inputmethod/qcoefepinputcontext_s60.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/gui/inputmethod/qcoefepinputcontext_s60.cpp b/src/gui/inputmethod/qcoefepinputcontext_s60.cpp index bdff5e7..a295d66 100644 --- a/src/gui/inputmethod/qcoefepinputcontext_s60.cpp +++ b/src/gui/inputmethod/qcoefepinputcontext_s60.cpp @@ -437,6 +437,10 @@ void QCoeFepInputContext::applyHints(Qt::InputMethodHints hints) void QCoeFepInputContext::applyFormat(QList *attributes) { TCharFormat cFormat; + QColor styleTextColor = QApplication::palette("QLineEdit").text().color(); + TLogicalRgb tontColor(TRgb(styleTextColor.red(), styleTextColor.green(), styleTextColor.blue(), styleTextColor.alpha())); + cFormat.iFontPresentation.iTextColor = tontColor; + TInt numChars = 0; TInt charPos = 0; int oldSize = attributes->size(); -- cgit v0.12 From 7ad244cad155f32f22e82e1458eb1c42f759a620 Mon Sep 17 00:00:00 2001 From: Thierry Bastian Date: Mon, 7 Dec 2009 14:01:54 +0100 Subject: Fix the toolbars docking The gap could be inserted even if the toolbar is very far away. This is due to the fact that we were only considering the distance as 1-directional. Now we also check that mouse position is inside the main window. Reviewed-by: gabi --- src/gui/widgets/qtoolbararealayout.cpp | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/gui/widgets/qtoolbararealayout.cpp b/src/gui/widgets/qtoolbararealayout.cpp index c329305..b83026b 100644 --- a/src/gui/widgets/qtoolbararealayout.cpp +++ b/src/gui/widgets/qtoolbararealayout.cpp @@ -598,16 +598,21 @@ int QToolBarAreaLayoutInfo::distance(const QPoint &pos) const { switch (dockPos) { case QInternal::LeftDock: - return pos.x() - rect.right(); + if (pos.y() < rect.bottom()) + return pos.x() - rect.right(); case QInternal::RightDock: - return rect.left() - pos.x(); + if (pos.y() < rect.bottom()) + return rect.left() - pos.x(); case QInternal::TopDock: - return pos.y() - rect.bottom(); + if (pos.x() < rect.right()) + return pos.y() - rect.bottom(); case QInternal::BottomDock: - return rect.top() - pos.y(); + if (pos.x() < rect.right()) + return rect.top() - pos.y(); default: - return -1; + break; } + return -1; } /****************************************************************************** -- cgit v0.12 From fb78a402b512b017c850e7410745c4d20da04a7c Mon Sep 17 00:00:00 2001 From: Yoann Lopes Date: Mon, 7 Dec 2009 15:04:42 +0100 Subject: Fixed memory leaks when removing a QGraphicsEffect from a QGraphicsItem or QWidget with setGraphicsEffect(0). The effect was not deleted in that case, problem solved for both QGraphicsItem and QWidget. Autotest included. Task-number: QTBUG-5917 Reviewed-by: bnilsen --- src/gui/graphicsview/qgraphicsitem.cpp | 19 +++---------------- src/gui/graphicsview/qgraphicsitem_p.h | 5 ++++- src/gui/kernel/qwidget.cpp | 14 ++++---------- src/gui/kernel/qwidget.h | 1 + src/gui/kernel/qwidget_p.h | 2 +- tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp | 16 ++++++++++++++++ tests/auto/qwidget/tst_qwidget.cpp | 16 ++++++++++++++++ 7 files changed, 45 insertions(+), 28 deletions(-) diff --git a/src/gui/graphicsview/qgraphicsitem.cpp b/src/gui/graphicsview/qgraphicsitem.cpp index f93ffdf..9e8d587 100644 --- a/src/gui/graphicsview/qgraphicsitem.cpp +++ b/src/gui/graphicsview/qgraphicsitem.cpp @@ -2563,32 +2563,19 @@ void QGraphicsItem::setGraphicsEffect(QGraphicsEffect *effect) if (d_ptr->graphicsEffect == effect) return; - if (d_ptr->graphicsEffect && effect) { + if (d_ptr->graphicsEffect) { delete d_ptr->graphicsEffect; d_ptr->graphicsEffect = 0; } - if (!effect) { - // Unset current effect. - QGraphicsEffectPrivate *oldEffectPrivate = d_ptr->graphicsEffect->d_func(); - d_ptr->graphicsEffect = 0; - if (oldEffectPrivate) { - oldEffectPrivate->setGraphicsEffectSource(0); // deletes the current source. - if (d_ptr->scene) { // Update the views directly. - d_ptr->scene->d_func()->markDirty(this, QRectF(), /*invalidateChildren=*/false, - /*force=*/false, /*ignoreOpacity=*/false, - /*removeItemFromScene=*/true); - } - } - } else { + if (effect) { // Set new effect. QGraphicsEffectSourcePrivate *sourced = new QGraphicsItemEffectSourcePrivate(this); QGraphicsEffectSource *source = new QGraphicsEffectSource(*sourced); d_ptr->graphicsEffect = effect; effect->d_func()->setGraphicsEffectSource(source); + prepareGeometryChange(); } - - prepareGeometryChange(); } #endif //QT_NO_GRAPHICSEFFECT diff --git a/src/gui/graphicsview/qgraphicsitem_p.h b/src/gui/graphicsview/qgraphicsitem_p.h index d6ffb1a..8f9fe54 100644 --- a/src/gui/graphicsview/qgraphicsitem_p.h +++ b/src/gui/graphicsview/qgraphicsitem_p.h @@ -562,7 +562,10 @@ public: {} inline void detach() - { item->setGraphicsEffect(0); } + { + item->d_ptr->graphicsEffect = 0; + item->prepareGeometryChange(); + } inline const QGraphicsItem *graphicsItem() const { return item; } diff --git a/src/gui/kernel/qwidget.cpp b/src/gui/kernel/qwidget.cpp index d19c574..00c7dc0 100644 --- a/src/gui/kernel/qwidget.cpp +++ b/src/gui/kernel/qwidget.cpp @@ -5059,28 +5059,22 @@ void QWidget::setGraphicsEffect(QGraphicsEffect *effect) if (d->graphicsEffect == effect) return; - if (d->graphicsEffect && effect) { + if (d->graphicsEffect) { + d->invalidateBuffer(rect()); delete d->graphicsEffect; d->graphicsEffect = 0; } - if (!effect) { - // Unset current effect. - QGraphicsEffectPrivate *oldEffectPrivate = d->graphicsEffect->d_func(); - d->graphicsEffect = 0; - if (oldEffectPrivate) { - oldEffectPrivate->setGraphicsEffectSource(0); // deletes the current source. - } - } else { + if (effect) { // Set new effect. QGraphicsEffectSourcePrivate *sourced = new QWidgetEffectSourcePrivate(this); QGraphicsEffectSource *source = new QGraphicsEffectSource(*sourced); d->graphicsEffect = effect; effect->d_func()->setGraphicsEffectSource(source); + update(); } d->updateIsOpaque(); - update(); } #endif //QT_NO_GRAPHICSEFFECT diff --git a/src/gui/kernel/qwidget.h b/src/gui/kernel/qwidget.h index 5ba1d23..0824db3 100644 --- a/src/gui/kernel/qwidget.h +++ b/src/gui/kernel/qwidget.h @@ -744,6 +744,7 @@ private: friend struct QWidgetExceptionCleaner; friend class QGestureManager; friend class QWinNativePanGestureRecognizer; + friend class QWidgetEffectSourcePrivate; #ifdef Q_WS_MAC friend class QCoreGraphicsPaintEnginePrivate; diff --git a/src/gui/kernel/qwidget_p.h b/src/gui/kernel/qwidget_p.h index 04cf4bb..5d73951 100644 --- a/src/gui/kernel/qwidget_p.h +++ b/src/gui/kernel/qwidget_p.h @@ -823,7 +823,7 @@ public: {} inline void detach() - { m_widget->setGraphicsEffect(0); } + { m_widget->d_func()->graphicsEffect = 0; } inline const QGraphicsItem *graphicsItem() const { return 0; } diff --git a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp index 565a3e7..6266933 100644 --- a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp +++ b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp @@ -7962,6 +7962,22 @@ void tst_QGraphicsItem::setGraphicsEffect() delete item; QVERIFY(!blurEffect); delete anotherItem; + + // Ensure the effect is uninstalled when deleting it + item = new QGraphicsRectItem(0, 0, 10, 10); + blurEffect = new QGraphicsBlurEffect; + item->setGraphicsEffect(blurEffect); + delete blurEffect; + QVERIFY(!item->graphicsEffect()); + + // Ensure the existing effect is uninstalled and deleted when setting a null effect + blurEffect = new QGraphicsBlurEffect; + item->setGraphicsEffect(blurEffect); + item->setGraphicsEffect(0); + QVERIFY(!item->graphicsEffect()); + QVERIFY(!blurEffect); + + delete item; } void tst_QGraphicsItem::panel() diff --git a/tests/auto/qwidget/tst_qwidget.cpp b/tests/auto/qwidget/tst_qwidget.cpp index 9960f47..3e14b56 100644 --- a/tests/auto/qwidget/tst_qwidget.cpp +++ b/tests/auto/qwidget/tst_qwidget.cpp @@ -9549,6 +9549,22 @@ void tst_QWidget::setGraphicsEffect() delete widget; QVERIFY(!blurEffect); delete anotherWidget; + + // Ensure the effect is uninstalled when deleting it + widget = new QWidget; + blurEffect = new QGraphicsBlurEffect; + widget->setGraphicsEffect(blurEffect); + delete blurEffect; + QVERIFY(!widget->graphicsEffect()); + + // Ensure the existing effect is uninstalled and deleted when setting a null effect + blurEffect = new QGraphicsBlurEffect; + widget->setGraphicsEffect(blurEffect); + widget->setGraphicsEffect(0); + QVERIFY(!widget->graphicsEffect()); + QVERIFY(!blurEffect); + + delete widget; } void tst_QWidget::activateWindow() -- cgit v0.12 From bd83b34da7049f7743c69b5efe019745801d6c34 Mon Sep 17 00:00:00 2001 From: Prasanth Ullattil Date: Mon, 7 Dec 2009 15:07:01 +0100 Subject: Cannot drag scrollbars in a QPlainTextEdit on Cocoa. The QPlainTextEdit can change the scroll ranges while dragging the scrollbar. This will eventualy call QWidget::raise(), on Cocoa it was done by removing the NSView and adding it back. This causes problems like resetting internal state while a mouseDragged was active on the view. The fix we will now sort the views based on their Qt-z-order. lower() & stackUnder() also fixed like this. Reviewed-by: Denis --- src/gui/kernel/qwidget_mac.mm | 112 +++++++++++++++++------------------------- 1 file changed, 46 insertions(+), 66 deletions(-) diff --git a/src/gui/kernel/qwidget_mac.mm b/src/gui/kernel/qwidget_mac.mm index 1907cca..7dc4d85 100644 --- a/src/gui/kernel/qwidget_mac.mm +++ b/src/gui/kernel/qwidget_mac.mm @@ -3654,6 +3654,16 @@ void QWidgetPrivate::setFocus_sys() } } +NSComparisonResult compareViews2Raise(id view1, id view2, void *context) +{ + id topView = reinterpret_cast(context); + if (view1 == topView) + return NSOrderedDescending; + if (view2 == topView) + return NSOrderedAscending; + return NSOrderedSame; +} + void QWidgetPrivate::raise_sys() { Q_Q(QWidget); @@ -3661,7 +3671,6 @@ void QWidgetPrivate::raise_sys() return; #if QT_MAC_USE_COCOA - QMacCocoaAutoReleasePool pool; if (isRealWindow()) { // Calling orderFront shows the window on Cocoa too. if (!q->testAttribute(Qt::WA_DontShowOnScreen) && q->isVisible()) { @@ -3673,16 +3682,9 @@ void QWidgetPrivate::raise_sys() SetFrontProcessWithOptions(&psn, kSetFrontProcessFrontWindowOnly); } } else { - // Cocoa doesn't really have an idea of Z-ordering, but you can - // fake it by changing the order of it. But beware, removing an - // NSView will also remove it as the first responder. So we re-set - // the first responder just in case: NSView *view = qt_mac_nativeview_for(q); NSView *parentView = [view superview]; - NSResponder *firstResponder = [[view window] firstResponder]; - [view removeFromSuperview]; - [parentView addSubview:view]; - [[view window] makeFirstResponder:firstResponder]; + [parentView sortSubviewsUsingFunction:compareViews2Raise context:reinterpret_cast(view)]; } #else if(q->isWindow()) { @@ -3700,47 +3702,29 @@ void QWidgetPrivate::raise_sys() #endif } +NSComparisonResult compareViews2Lower(id view1, id view2, void *context) +{ + id topView = reinterpret_cast(context); + if (view1 == topView) + return NSOrderedAscending; + if (view2 == topView) + return NSOrderedDescending; + return NSOrderedSame; +} + void QWidgetPrivate::lower_sys() { Q_Q(QWidget); if((q->windowType() == Qt::Desktop)) return; #ifdef QT_MAC_USE_COCOA - QMacCocoaAutoReleasePool pool; if (isRealWindow()) { OSWindowRef window = qt_mac_window_for(q); [window orderBack:window]; } else { - // Cocoa doesn't really have an idea of Z-ordering, but you can - // fake it by changing the order of it. In this case - // we put the item at the beginning of the list, but that means - // we must re-insert everything since we cannot modify the list directly. - NSView *myview = qt_mac_nativeview_for(q); - NSView *parentView = [myview superview]; - NSArray *tmpViews = [parentView subviews]; - NSMutableArray *subviews = [[NSMutableArray alloc] initWithCapacity:[tmpViews count]]; - [subviews addObjectsFromArray:tmpViews]; - NSResponder *firstResponder = [[myview window] firstResponder]; - // Implicit assumption that myViewIndex is included in subviews, that's why I'm not checking - // myViewIndex. - NSUInteger index = 0; - NSUInteger myViewIndex = 0; - bool foundMyView = false; - for (NSView *subview in subviews) { - [subview removeFromSuperview]; - if (subview == myview) { - foundMyView = true; - myViewIndex = index; - } - ++index; - } - [parentView addSubview:myview]; - if (foundMyView) - [subviews removeObjectAtIndex:myViewIndex]; - for (NSView *subview in subviews) - [parentView addSubview:subview]; - [subviews release]; - [[myview window] makeFirstResponder:firstResponder]; + NSView *view = qt_mac_nativeview_for(q); + NSView *parentView = [view superview]; + [parentView sortSubviewsUsingFunction:compareViews2Lower context:reinterpret_cast(view)]; } #else if(q->isWindow()) { @@ -3753,6 +3737,16 @@ void QWidgetPrivate::lower_sys() #endif } +NSComparisonResult compareViews2StackUnder(id view1, id view2, void *context) +{ + const QHash &viewOrder = *reinterpret_cast *>(context); + if (viewOrder[view1] < viewOrder[view2]) + return NSOrderedAscending; + if (viewOrder[view1] > viewOrder[view2]) + return NSOrderedDescending; + return NSOrderedSame; +} + void QWidgetPrivate::stackUnder_sys(QWidget *w) { // stackUnder @@ -3761,37 +3755,23 @@ void QWidgetPrivate::stackUnder_sys(QWidget *w) return; #ifdef QT_MAC_USE_COCOA // Do the same trick as lower_sys() and put this widget before the widget passed in. - QMacCocoaAutoReleasePool pool; - NSView *myview = qt_mac_nativeview_for(q); + NSView *myView = qt_mac_nativeview_for(q); NSView *wView = qt_mac_nativeview_for(w); - NSView *parentView = [myview superview]; - NSArray *tmpViews = [parentView subviews]; - NSMutableArray *subviews = [[NSMutableArray alloc] initWithCapacity:[tmpViews count]]; - [subviews addObjectsFromArray:tmpViews]; - // Implicit assumption that myViewIndex and wViewIndex is included in subviews, - // that's why I'm not checking myViewIndex. - NSUInteger index = 0; - NSUInteger myViewIndex = 0; - NSUInteger wViewIndex = 0; - for (NSView *subview in subviews) { - [subview removeFromSuperview]; - if (subview == myview) - myViewIndex = index; - else if (subview == wView) - wViewIndex = index; - ++index; - } - index = 0; + QHash viewOrder; + NSView *parentView = [myView superview]; + NSArray *subviews = [parentView subviews]; + NSUInteger index = 1; + // make a hash of view->zorderindex and make sure z-value is always odd, + // so that when we modify the order we create a new (even) z-value which + // will not interfere with others. for (NSView *subview in subviews) { - if (index == myViewIndex) - continue; - if (index == wViewIndex) - [parentView addSubview:myview]; - [parentView addSubview:subview]; + viewOrder.insert(subview, index * 2); ++index; } - [subviews release]; + viewOrder[myView] = viewOrder[wView] - 1; + + [parentView sortSubviewsUsingFunction:compareViews2StackUnder context:reinterpret_cast(&viewOrder)]; #else QWidget *p = q->parentWidget(); if(!p || p != w->parentWidget()) -- cgit v0.12 From 9a45e1853374c735dc08bf2e23b9d820900b1ccb Mon Sep 17 00:00:00 2001 From: Gabriel de Dietrich Date: Mon, 7 Dec 2009 13:40:14 +0100 Subject: Assert in designer while drag & dropping items from a QListWidget Did not honour returned value from beginMoveRows(). Auto-test included. Reviewed-by: leo Task-number: QTBUG-6532 --- src/gui/itemviews/qlistwidget.cpp | 3 ++- tests/auto/qlistwidget/tst_qlistwidget.cpp | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/gui/itemviews/qlistwidget.cpp b/src/gui/itemviews/qlistwidget.cpp index 5dd1d76..929d688 100644 --- a/src/gui/itemviews/qlistwidget.cpp +++ b/src/gui/itemviews/qlistwidget.cpp @@ -176,7 +176,8 @@ void QListModel::move(int srcRow, int dstRow) || dstRow < 0 || dstRow >= items.count()) return; - beginMoveRows(QModelIndex(), srcRow, srcRow, QModelIndex(), dstRow); + if (!beginMoveRows(QModelIndex(), srcRow, srcRow, QModelIndex(), dstRow)) + return; if (srcRow < dstRow) --dstRow; items.move(srcRow, dstRow); diff --git a/tests/auto/qlistwidget/tst_qlistwidget.cpp b/tests/auto/qlistwidget/tst_qlistwidget.cpp index cb8f1e9..863c308 100644 --- a/tests/auto/qlistwidget/tst_qlistwidget.cpp +++ b/tests/auto/qlistwidget/tst_qlistwidget.cpp @@ -867,6 +867,7 @@ void tst_QListWidget::moveItemsPriv_data() QTest::newRow("Same place") << 5 << 2 << 2 << false; QTest::newRow("Up") << 5 << 4 << 2 << true; QTest::newRow("Down") << 5 << 2 << 4 << true; + QTest::newRow("QTBUG-6532 assert") << 5 << 0 << 1 << false; } void tst_QListWidget::moveItemsPriv() -- cgit v0.12 From 49a56b22b572b1167098e5f96a84e30cdc64f38c Mon Sep 17 00:00:00 2001 From: Denis Dzyubenko Date: Fri, 4 Dec 2009 15:49:34 +0100 Subject: Fixed calculating CRC32 on 64bit platforms When compiling on a 64bit machine we should make sure that we won't overflow the 32bit CRC value because of casting signed int to unsigned long. Reviewed-by: Thiago --- config.tests/mac/crc/main.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/config.tests/mac/crc/main.cpp b/config.tests/mac/crc/main.cpp index 894f88b..700a4cd 100644 --- a/config.tests/mac/crc/main.cpp +++ b/config.tests/mac/crc/main.cpp @@ -71,7 +71,7 @@ private: for(int iCodes = 0; iCodes <= 0xFF; iCodes++) { ulTable[iCodes] = Reflect(iCodes, 8) << 24; for(int iPos = 0; iPos < 8; iPos++) { - ulTable[iCodes] = (ulTable[iCodes] << 1) + ulTable[iCodes] = ((ulTable[iCodes] << 1) & 0xffffffff) ^ ((ulTable[iCodes] & (1 << 31)) ? ulPolynomial : 0); } @@ -84,7 +84,7 @@ private: // Swap bit 0 for bit 7, bit 1 For bit 6, etc.... for(int iPos = 1; iPos < (cChar + 1); iPos++) { if(ulReflect & 1) { - ulValue |= (1 << (cChar - iPos)); + ulValue |= (1ul << (cChar - iPos)); } ulReflect >>= 1; } -- cgit v0.12 From 2e6e0e2e2f06391095f05d5bbe21aecc839cc99b Mon Sep 17 00:00:00 2001 From: Denis Dzyubenko Date: Mon, 7 Dec 2009 14:50:48 +0100 Subject: Added a manual test for testing a z-order of overlapping widgets. The test uses QWidget::raise, lower and stackUnder functions. Reviewed-by: trustme --- tests/manual/qwidget_zorder/main.cpp | 77 ++++++++++++++++++++++++++ tests/manual/qwidget_zorder/qwidget_zorder.pro | 6 ++ 2 files changed, 83 insertions(+) create mode 100644 tests/manual/qwidget_zorder/main.cpp create mode 100644 tests/manual/qwidget_zorder/qwidget_zorder.pro diff --git a/tests/manual/qwidget_zorder/main.cpp b/tests/manual/qwidget_zorder/main.cpp new file mode 100644 index 0000000..395d430 --- /dev/null +++ b/tests/manual/qwidget_zorder/main.cpp @@ -0,0 +1,77 @@ +#include + +class Widget : public QWidget +{ + Q_OBJECT +public: + Widget() + { + QWidget *stackWidget = new QWidget; + stackWidget->setFixedSize(400, 300); + button = new QPushButton("pushbutton", stackWidget); + plainTextEdit = new QPlainTextEdit(stackWidget); + plainTextEdit->setWordWrapMode(QTextOption::NoWrap); + QString s = "foo bar bar foo foo bar bar foo"; + for (int i = 0; i < 10; ++i) { + plainTextEdit->appendPlainText(s); + s.remove(1, 2); + } + calendar = new QCalendarWidget(stackWidget); + button->move(10, 10); + button->resize(100, 100); + plainTextEdit->move(30, 70); + plainTextEdit->resize(100, 100); + calendar->move(80, 40); + + QWidget *buttonOps = new QWidget; + QVBoxLayout *l = new QVBoxLayout(buttonOps); + QPushButton *lower = new QPushButton("button: lower"); + connect(lower, SIGNAL(clicked()), button, SLOT(lower())); + l->addWidget(lower); + QPushButton *raise = new QPushButton("button: raise"); + connect(raise, SIGNAL(clicked()), button, SLOT(raise())); + l->addWidget(raise); + + lower = new QPushButton("calendar: lower"); + connect(lower, SIGNAL(clicked()), calendar, SLOT(lower())); + l->addWidget(lower); + raise = new QPushButton("calendar: raise"); + connect(raise, SIGNAL(clicked()), calendar, SLOT(raise())); + l->addWidget(raise); + QPushButton *stackUnder = new QPushButton("calendar: stack under textedit"); + connect(stackUnder, SIGNAL(clicked()), this, SLOT(stackCalendarUnderTextEdit())); + l->addWidget(stackUnder); + + lower = new QPushButton("lower textedit"); + connect(lower, SIGNAL(clicked()), plainTextEdit, SLOT(lower())); + l->addWidget(lower); + raise = new QPushButton("raise textedit"); + connect(raise, SIGNAL(clicked()), plainTextEdit, SLOT(raise())); + l->addWidget(raise); + + QHBoxLayout *mainLayout = new QHBoxLayout(this); + mainLayout->addWidget(buttonOps); + mainLayout->addWidget(stackWidget); + } + +private Q_SLOTS: + void stackCalendarUnderTextEdit() + { + calendar->stackUnder(plainTextEdit); + } + +private: + QPushButton *button; + QPlainTextEdit *plainTextEdit; + QCalendarWidget *calendar; +}; + +int main(int argc, char **argv) +{ + QApplication app(argc, argv); + Widget w; + w.show(); + return app.exec(); +} + +#include "main.moc" diff --git a/tests/manual/qwidget_zorder/qwidget_zorder.pro b/tests/manual/qwidget_zorder/qwidget_zorder.pro new file mode 100644 index 0000000..5526f91 --- /dev/null +++ b/tests/manual/qwidget_zorder/qwidget_zorder.pro @@ -0,0 +1,6 @@ +TEMPLATE = app +DEPENDPATH += . +INCLUDEPATH += . + +# Input +SOURCES += main.cpp -- cgit v0.12 From 16e324adfad0775e37c9fe2800d5fa8b89a80a64 Mon Sep 17 00:00:00 2001 From: Joerg Bornemann Date: Mon, 7 Dec 2009 16:15:16 +0100 Subject: fix -nomake tools configure option for Windows CE / Symbian lrelease must not be added to the subdirs project projects.pro when building Qt for Windows CE or Symbian. Reviewed-by: ossi --- projects.pro | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/projects.pro b/projects.pro index 497acd0..d405a5b 100644 --- a/projects.pro +++ b/projects.pro @@ -48,7 +48,7 @@ for(PROJECT, $$list($$lower($$unique(QT_BUILD_PARTS)))) { contains(QT_BUILD_PARTS, tools) { include(translations/translations.pri) # ts targets } else { - SUBDIRS += tools/linguist/lrelease + !wince*:!symbian:SUBDIRS += tools/linguist/lrelease } SUBDIRS += translations # qm build step } else:isEqual(PROJECT, qmake) { -- cgit v0.12 From ac90a37e5bec3c5b6cdc01a836f8e562395a3863 Mon Sep 17 00:00:00 2001 From: Thierry Bastian Date: Mon, 7 Dec 2009 16:48:04 +0100 Subject: Compilation fix --- src/gui/widgets/qdialogbuttonbox.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/gui/widgets/qdialogbuttonbox.cpp b/src/gui/widgets/qdialogbuttonbox.cpp index 56cf545..47ddc52 100644 --- a/src/gui/widgets/qdialogbuttonbox.cpp +++ b/src/gui/widgets/qdialogbuttonbox.cpp @@ -46,6 +46,7 @@ #include #include #include +#include #include "qdialogbuttonbox.h" -- cgit v0.12 From b413c6a59b7ab8df0029075403fef11779846372 Mon Sep 17 00:00:00 2001 From: Jono Cole Date: Mon, 7 Dec 2009 16:54:21 +0100 Subject: Add support for the Selected QIcon::Mode when rendering the systray icon (Mac) Merge-request: 1599 Reviewed-by: Denis Dzyubenko --- src/gui/util/qsystemtrayicon_mac.mm | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/src/gui/util/qsystemtrayicon_mac.mm b/src/gui/util/qsystemtrayicon_mac.mm index b74ca85..93295a7 100644 --- a/src/gui/util/qsystemtrayicon_mac.mm +++ b/src/gui/util/qsystemtrayicon_mac.mm @@ -314,8 +314,22 @@ QT_END_NAMESPACE { Q_UNUSED(notification); down = NO; + + if( ![self icon]->icon().isNull() ) { +#ifndef QT_MAC_USE_COCOA + const short scale = GetMBarHeight()-4; +#else + CGFloat hgt = [[[NSApplication sharedApplication] mainMenu] menuBarHeight]; + const short scale = hgt - 4; +#endif + NSImage *nsimage = static_cast(qt_mac_create_nsimage([self icon]->icon().pixmap(QSize(scale, scale)))); + [self setImage: nsimage]; + [nsimage release]; + } + if([self icon]->contextMenu()) [self icon]->contextMenu()->hide(); + [self setNeedsDisplay:YES]; } @@ -327,6 +341,20 @@ QT_END_NAMESPACE [self icon]->contextMenu()->hide(); [self setNeedsDisplay:YES]; +#ifndef QT_MAC_USE_COCOA + const short scale = GetMBarHeight()-4; +#else + CGFloat hgt = [[[NSApplication sharedApplication] mainMenu] menuBarHeight]; + const short scale = hgt - 4; +#endif + + if( down && ![self icon]->icon().isNull() ) { + NSImage *nsaltimage = static_cast(qt_mac_create_nsimage([self icon]->icon().pixmap(QSize(scale, scale), QIcon::Selected))); + [self setImage: nsaltimage]; + [nsaltimage release]; + } + + if (down) [parent triggerSelector:self]; else if ((clickCount%2)) -- cgit v0.12 From 3aa9857322e4b016c3a0e0757eb4ba709db99b4f Mon Sep 17 00:00:00 2001 From: Paul Olav Tvete Date: Mon, 7 Dec 2009 19:01:01 +0100 Subject: Add copyright header so the autotest will pass. --- tests/manual/qwidget_zorder/main.cpp | 41 ++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/tests/manual/qwidget_zorder/main.cpp b/tests/manual/qwidget_zorder/main.cpp index 395d430..fe8e0a2 100644 --- a/tests/manual/qwidget_zorder/main.cpp +++ b/tests/manual/qwidget_zorder/main.cpp @@ -1,3 +1,44 @@ +/**************************************************************************** +** +** 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 test suite 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$ +** +****************************************************************************/ + #include class Widget : public QWidget -- cgit v0.12 From 322db8410bf7609f072837d554e7256dc385265b Mon Sep 17 00:00:00 2001 From: Kurt Korbatits Date: Tue, 8 Dec 2009 08:04:20 +1000 Subject: Qt fails to build on RHEL 4 and other older Linux versions because of old ALSA Added alsa version checking in config test, must have >= 1.0.10 to enable. Task-number:QTBUG-6493 Reviewed-by:Justin McPherson --- config.tests/unix/alsa/alsatest.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/config.tests/unix/alsa/alsatest.cpp b/config.tests/unix/alsa/alsatest.cpp index 1307c4e..f1092f8 100644 --- a/config.tests/unix/alsa/alsatest.cpp +++ b/config.tests/unix/alsa/alsatest.cpp @@ -40,8 +40,11 @@ ****************************************************************************/ #include +#if(!(SND_LIB_MAJOR == 1 && SND_LIB_MINOR == 0 && SND_LIB_SUBMINOR >= 10)) +#error "Alsa version found too old, require >= 1.0.10" +#endif + int main(int argc,char **argv) { - return 0; } -- cgit v0.12 From b70f9d3969fdf7789ba1c5f4d942b2625b1bf689 Mon Sep 17 00:00:00 2001 From: Kurt Korbatits Date: Tue, 8 Dec 2009 08:07:13 +1000 Subject: audioinput and audiooutput examples not using isFormatSupported function. The examples failed to easy, added check to test and get if required a format to use from the backend. Increases the chance of examples working on various platforms like n900. Reviewed-by:Justin McPherson --- examples/multimedia/audioinput/audioinput.cpp | 12 +++++++++++- examples/multimedia/audiooutput/audiooutput.cpp | 12 ++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/examples/multimedia/audioinput/audioinput.cpp b/examples/multimedia/audioinput/audioinput.cpp index 62afd73..75bddd6 100644 --- a/examples/multimedia/audioinput/audioinput.cpp +++ b/examples/multimedia/audioinput/audioinput.cpp @@ -195,7 +195,6 @@ InputTest::InputTest() pullMode = true; - // AudioInfo class only supports mono S16LE samples! format.setFrequency(8000); format.setChannels(1); format.setSampleSize(16); @@ -203,6 +202,17 @@ InputTest::InputTest() format.setByteOrder(QAudioFormat::LittleEndian); format.setCodec("audio/pcm"); + QAudioDeviceInfo info(QAudioDeviceInfo::defaultInputDevice()); + if (!info.isFormatSupported(format)) { + qWarning()<<"default format not supported try to use nearest"; + format = info.nearestFormat(format); + } + + if(format.sampleSize() != 16) { + qWarning()<<"audio device doesn't support 16 bit samples, example cannot run"; + return; + } + audioInput = new QAudioInput(format,this); connect(audioInput,SIGNAL(notify()),SLOT(status())); connect(audioInput,SIGNAL(stateChanged(QAudio::State)),SLOT(state(QAudio::State))); diff --git a/examples/multimedia/audiooutput/audiooutput.cpp b/examples/multimedia/audiooutput/audiooutput.cpp index 244840d..b6047db 100644 --- a/examples/multimedia/audiooutput/audiooutput.cpp +++ b/examples/multimedia/audiooutput/audiooutput.cpp @@ -170,6 +170,18 @@ AudioTest::AudioTest() settings.setCodec("audio/pcm"); settings.setByteOrder(QAudioFormat::LittleEndian); settings.setSampleType(QAudioFormat::SignedInt); + + QAudioDeviceInfo info(QAudioDeviceInfo::defaultOutputDevice()); + if (!info.isFormatSupported(settings)) { + qWarning()<<"default format not supported try to use nearest"; + settings = info.nearestFormat(settings); + } + + if(settings.sampleSize() != 16) { + qWarning()<<"audio device doesn't support 16 bit samples, example cannot run"; + return; + } + audioOutput = new QAudioOutput(settings,this); connect(audioOutput,SIGNAL(notify()),SLOT(status())); connect(audioOutput,SIGNAL(stateChanged(QAudio::State)),SLOT(state(QAudio::State))); -- cgit v0.12 From 12b032ca7c79955f03f744bdb8f7b0d60e222e40 Mon Sep 17 00:00:00 2001 From: Bill King Date: Tue, 8 Dec 2009 09:04:03 +1000 Subject: Proper fix for QTBUG-6421 fixes setForwardOnly() for both OCI and SQLite Task-number: QTBUG-6421 Reviewed-by: Justin McPherson --- src/sql/drivers/sqlite/qsql_sqlite.cpp | 17 ++++++++++++----- src/sql/kernel/qsqlcachedresult.cpp | 5 +++++ 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/src/sql/drivers/sqlite/qsql_sqlite.cpp b/src/sql/drivers/sqlite/qsql_sqlite.cpp index 8355de2..c62f15c 100644 --- a/src/sql/drivers/sqlite/qsql_sqlite.cpp +++ b/src/sql/drivers/sqlite/qsql_sqlite.cpp @@ -122,14 +122,14 @@ public: sqlite3_stmt *stmt; - uint skippedStatus: 1; // the status of the fetchNext() that's skipped - uint skipRow: 1; // skip the next fetchNext()? - uint utf8: 1; + bool skippedStatus; // the status of the fetchNext() that's skipped + bool skipRow; // skip the next fetchNext()? QSqlRecord rInf; + QVector firstRow; }; QSQLiteResultPrivate::QSQLiteResultPrivate(QSQLiteResult* res) : q(res), access(0), - stmt(0), skippedStatus(false), skipRow(false), utf8(false) + stmt(0), skippedStatus(false), skipRow(false) { } @@ -189,10 +189,17 @@ bool QSQLiteResultPrivate::fetchNext(QSqlCachedResult::ValueCache &values, int i // already fetched Q_ASSERT(!initialFetch); skipRow = false; + for(int i=0;isetLastError(QSqlError(QCoreApplication::translate("QSQLiteResult", "Unable to fetch row"), QCoreApplication::translate("QSQLiteResult", "No query"), QSqlError::ConnectionError)); @@ -399,7 +406,7 @@ bool QSQLiteResult::exec() "Parameter count mismatch"), QString(), QSqlError::StatementError)); return false; } - d->skippedStatus = d->fetchNext(cache(), 0, true); + d->skippedStatus = d->fetchNext(d->firstRow, 0, true); if (lastError().isValid()) { setSelect(false); setActive(false); diff --git a/src/sql/kernel/qsqlcachedresult.cpp b/src/sql/kernel/qsqlcachedresult.cpp index b4a9241..2e4d19e 100644 --- a/src/sql/kernel/qsqlcachedresult.cpp +++ b/src/sql/kernel/qsqlcachedresult.cpp @@ -278,6 +278,11 @@ bool QSqlCachedResult::cacheNext() if (d->atEnd) return false; + if(isForwardOnly()) { + d->cache.clear(); + d->cache.resize(d->colCount); + } + if (!gotoNext(d->cache, d->nextIndex())) { d->revertLast(); d->atEnd = true; -- cgit v0.12 From 05d4b4c72a5089885c1515833e34177607c2c511 Mon Sep 17 00:00:00 2001 From: Rhys Weatherley Date: Tue, 8 Dec 2009 11:02:46 +1000 Subject: Fix GL_BGRA formats under OpenGL/ES systems OpenGL/ES requires that the internal and external formats be the same when calling glTexImage2D(). This caused problems with devices that had the GL_EXT_bgra extension. This change makes the formats the same just before the upload and also makes sure that the pixel type is GL_UNSIGNED_BYTE when GL_BGRA is used. No change for desktop systems. Reviewed-by: Donald Carr --- src/opengl/qgl.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/opengl/qgl.cpp b/src/opengl/qgl.cpp index 1ff102f..967ba48 100644 --- a/src/opengl/qgl.cpp +++ b/src/opengl/qgl.cpp @@ -2234,6 +2234,14 @@ QGLTexture* QGLContextPrivate::bindTexture(const QImage &image, GLenum target, G } } } +#ifdef QT_OPENGL_ES + // OpenGL/ES requires that the internal and external formats be identical. + // This is typically used to convert GL_RGBA into GL_BGRA. + // Also, we need to use GL_UNSIGNED_BYTE when the format is GL_BGRA. + internalFormat = externalFormat; + if (pixel_type == GL_UNSIGNED_INT_8_8_8_8_REV) + pixel_type = GL_UNSIGNED_BYTE; +#endif #ifdef QGL_BIND_TEXTURE_DEBUG printf(" - uploading, image.format=%d, externalFormat=0x%x, internalFormat=0x%x, pixel_type=0x%x\n", img.format(), externalFormat, internalFormat, pixel_type); -- cgit v0.12 From 127d52df97b68fcf54a50e471a0b899d92fda10a Mon Sep 17 00:00:00 2001 From: Bill King Date: Tue, 8 Dec 2009 12:13:20 +1000 Subject: Remove this unnecessary and verbose line. --- tests/auto/qsqldatabase/tst_qsqldatabase.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/auto/qsqldatabase/tst_qsqldatabase.cpp b/tests/auto/qsqldatabase/tst_qsqldatabase.cpp index f840ca6..cb4e103 100644 --- a/tests/auto/qsqldatabase/tst_qsqldatabase.cpp +++ b/tests/auto/qsqldatabase/tst_qsqldatabase.cpp @@ -2493,7 +2493,6 @@ void tst_QSqlDatabase::oci_tables() QString systemTableName("system."+qTableName("mypassword")); QVERIFY_SQL(q, exec("CREATE TABLE "+systemTableName+"(name VARCHAR(20))")); QVERIFY(!db.tables().contains(systemTableName.toUpper())); - qDebug() << db.tables(QSql::SystemTables); QVERIFY(db.tables(QSql::SystemTables).contains(systemTableName.toUpper())); } -- cgit v0.12 From 854d8960b98a691094ac51ad69b60d6a3a798ac2 Mon Sep 17 00:00:00 2001 From: Janne Anttila Date: Tue, 8 Dec 2009 09:57:08 +0200 Subject: Minor fixes to softkey dimming support (commit 245c9cc0). In Qt invisible actions are disabled by default, and our "Options" softkey is set to invisible in order that it is not show in context menu. Thus we need don't want to dim in softkey even it is disabled. Additionally, QDialogButtonEnabledProxy need to set the initial enabled state for proxy action from button. Fixes bugs in commit: 245c9cc0 Reviewed-by: TrustMe --- src/gui/kernel/qsoftkeymanager.cpp | 6 +++++- src/gui/widgets/qdialogbuttonbox.cpp | 1 + 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/gui/kernel/qsoftkeymanager.cpp b/src/gui/kernel/qsoftkeymanager.cpp index 464a250..0e98f39 100644 --- a/src/gui/kernel/qsoftkeymanager.cpp +++ b/src/gui/kernel/qsoftkeymanager.cpp @@ -250,13 +250,17 @@ void QSoftKeyManagerPrivate::updateSoftKeys_sys(const QList &softkeys) ? EAknSoftkeyOptions : s60CommandStart + index; + // _q_menuSoftKeyAction action is set to "invisible" and all invisible actions are by default + // disabled. However we never want to dim options softkey, even it is set to "invisible" + bool dimmed = (command == EAknSoftkeyOptions) ? false : !softKeyAction->isEnabled(); + if (position != -1) { const int underlineShortCut = QApplication::style()->styleHint(QStyle::SH_UnderlineShortcut); QString iconText = softKeyAction->iconText(); TPtrC text = qt_QString2TPtrC( underlineShortCut ? softKeyAction->text() : iconText); QT_TRAP_THROWING( nativeContainer->SetCommandL(position, command, text); - nativeContainer->DimCommand(command, !softKeyAction->isEnabled()); + nativeContainer->DimCommand(command, dimmed); ); } } diff --git a/src/gui/widgets/qdialogbuttonbox.cpp b/src/gui/widgets/qdialogbuttonbox.cpp index 56cf545..9512785 100644 --- a/src/gui/widgets/qdialogbuttonbox.cpp +++ b/src/gui/widgets/qdialogbuttonbox.cpp @@ -265,6 +265,7 @@ public: QDialogButtonEnabledProxy(QObject *parent, QWidget *src, QAction *trg) : QObject(parent), source(src), target(trg) { source->installEventFilter(this); + target->setEnabled(source->isEnabled()); } ~QDialogButtonEnabledProxy() { -- cgit v0.12 From 91c47ba2c156e4dcaf9b2e03f7abf796c4828906 Mon Sep 17 00:00:00 2001 From: "Bradley T. Hughes" Date: Tue, 8 Dec 2009 08:50:14 +0100 Subject: Compile on Windows CE. Windows CE does not support Windows hook at all, so we need to call our hook function "manually" from process events. Task-number: QTBUG-6083 Reviewed-by: joerg --- src/corelib/kernel/qeventdispatcher_win.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/corelib/kernel/qeventdispatcher_win.cpp b/src/corelib/kernel/qeventdispatcher_win.cpp index c6eef5e..c305341 100644 --- a/src/corelib/kernel/qeventdispatcher_win.cpp +++ b/src/corelib/kernel/qeventdispatcher_win.cpp @@ -509,7 +509,11 @@ LRESULT CALLBACK qt_GetMessageHook(int code, WPARAM wp, LPARAM lp) } } } +#ifdef Q_OS_WINCE + return 0; +#else return CallNextHookEx(0, code, wp, lp); +#endif } static HWND qt_create_internal_window(const QEventDispatcherWin32 *eventDispatcher) @@ -636,11 +640,13 @@ void QEventDispatcherWin32::createInternalHwnd() return; d->internalHwnd = qt_create_internal_window(this); +#ifndef Q_OS_WINCE // setup GetMessage hook needed to drive our posted events d->getMessageHook = SetWindowsHookEx(WH_GETMESSAGE, (HOOKPROC) qt_GetMessageHook, NULL, GetCurrentThreadId()); if (!d->getMessageHook) { qFatal("Qt: INTERNALL ERROR: failed to install GetMessage hook"); } +#endif // register all socket notifiers QList sockets = (d->sn_read.keys().toSet() @@ -731,6 +737,11 @@ bool QEventDispatcherWin32::processEvents(QEventLoop::ProcessEventsFlags flags) } } if (haveMessage) { +#ifdef Q_OS_WINCE + // WinCE doesn't support hooks at all, so we have to call this by hand :( + (void) qt_GetMessageHook(0, PM_REMOVE, (LPARAM) &msg); +#endif + if (d->internalHwnd == msg.hwnd && msg.message == WM_QT_SENDPOSTEDEVENTS) { if (seenWM_QT_SENDPOSTEDEVENTS) { needWM_QT_SENDPOSTEDEVENTS = true; @@ -1065,9 +1076,11 @@ void QEventDispatcherWin32::closingDown() d->timerVec.clear(); d->timerDict.clear(); +#ifndef Q_OS_WINCE if (d->getMessageHook) UnhookWindowsHookEx(d->getMessageHook); d->getMessageHook = 0; +#endif } bool QEventDispatcherWin32::event(QEvent *e) -- cgit v0.12 From dfbdb86fd4614be9be17cbfb602ed5a3b5a38671 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Tue, 8 Dec 2009 09:10:40 +0100 Subject: Autotest: ensure that QSharedPointer does proper autocasting through function calls. Seen on qt-interest. Reviewed-by: Trust Me --- tests/auto/qsharedpointer/tst_qsharedpointer.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/tests/auto/qsharedpointer/tst_qsharedpointer.cpp b/tests/auto/qsharedpointer/tst_qsharedpointer.cpp index ed9206c..0cb08f9 100644 --- a/tests/auto/qsharedpointer/tst_qsharedpointer.cpp +++ b/tests/auto/qsharedpointer/tst_qsharedpointer.cpp @@ -73,6 +73,7 @@ private slots: void forwardDeclaration2(); void memoryManagement(); void downCast(); + void functionCallDownCast(); void upCast(); void qobjectWeakManagement(); void noSharedPointerFromWeakQObject(); @@ -503,6 +504,15 @@ void tst_QSharedPointer::downCast() QCOMPARE(DerivedData::derivedDestructorCounter, destructorCount + 1); } +void functionDataByValue(QSharedPointer p) { Q_UNUSED(p); }; +void functionDataByRef(const QSharedPointer &p) { Q_UNUSED(p); }; +void tst_QSharedPointer::functionCallDownCast() +{ + QSharedPointer p(new DerivedData()); + functionDataByValue(p); + functionDataByRef(p); +} + void tst_QSharedPointer::upCast() { QSharedPointer baseptr = QSharedPointer(new DerivedData); -- cgit v0.12 From 2e110daa8fb3889036db330837884a6aa61a92a1 Mon Sep 17 00:00:00 2001 From: Alan Alpert Date: Tue, 8 Dec 2009 09:32:49 +0100 Subject: Remove id property from QGraphicsObject It is not actually useful (exact same READ/WRITE as objectName) and is confusing when used in QML. Task-number: QTBUG-6580 Reviewed-by: andreas Reviewed-by: alexis Reviewed-by: ogoffart --- src/gui/graphicsview/qgraphicsitem.cpp | 7 ------- src/gui/graphicsview/qgraphicsitem.h | 1 - 2 files changed, 8 deletions(-) diff --git a/src/gui/graphicsview/qgraphicsitem.cpp b/src/gui/graphicsview/qgraphicsitem.cpp index 9e8d587..9846dbb 100644 --- a/src/gui/graphicsview/qgraphicsitem.cpp +++ b/src/gui/graphicsview/qgraphicsitem.cpp @@ -7292,13 +7292,6 @@ void QGraphicsObject::ungrabGesture(Qt::GestureType gesture) */ /*! - \property QGraphicsObject::id - \brief the id of of the item - - \sa QObject::objectName(), QObject::setObjectName() -*/ - -/*! \property QGraphicsObject::opacity \brief the opacity of the item diff --git a/src/gui/graphicsview/qgraphicsitem.h b/src/gui/graphicsview/qgraphicsitem.h index 8bbe9f1..8818a0b 100644 --- a/src/gui/graphicsview/qgraphicsitem.h +++ b/src/gui/graphicsview/qgraphicsitem.h @@ -537,7 +537,6 @@ class Q_GUI_EXPORT QGraphicsObject : public QObject, public QGraphicsItem { Q_OBJECT Q_PROPERTY(QGraphicsObject * parent READ parentObject WRITE setParentItem NOTIFY parentChanged DESIGNABLE false) - Q_PROPERTY(QString id READ objectName WRITE setObjectName) Q_PROPERTY(qreal opacity READ opacity WRITE setOpacity NOTIFY opacityChanged FINAL) Q_PROPERTY(bool enabled READ isEnabled WRITE setEnabled NOTIFY enabledChanged) Q_PROPERTY(bool visible READ isVisible WRITE setVisible NOTIFY visibleChanged FINAL) -- cgit v0.12 From 4f6dc78fb05026608ffb03dfae905c23a48aac43 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Nilsen?= Date: Tue, 8 Dec 2009 11:39:31 +0100 Subject: Doc: Explicitly mention that QWidget/QGraphicsItem takes ownership of effects. --- src/gui/graphicsview/qgraphicsitem.cpp | 2 ++ src/gui/kernel/qwidget.cpp | 2 ++ 2 files changed, 4 insertions(+) diff --git a/src/gui/graphicsview/qgraphicsitem.cpp b/src/gui/graphicsview/qgraphicsitem.cpp index 9846dbb..90cc132 100644 --- a/src/gui/graphicsview/qgraphicsitem.cpp +++ b/src/gui/graphicsview/qgraphicsitem.cpp @@ -2554,6 +2554,8 @@ QGraphicsEffect *QGraphicsItem::graphicsEffect() const If \a effect is the installed on a different item, setGraphicsEffect() will remove the effect from the item and install it on this item. + QGraphicsItem takes ownership of \a effect. + \note This function will apply the effect on itself and all its children. \since 4.6 diff --git a/src/gui/kernel/qwidget.cpp b/src/gui/kernel/qwidget.cpp index 00c7dc0..21aae3e 100644 --- a/src/gui/kernel/qwidget.cpp +++ b/src/gui/kernel/qwidget.cpp @@ -5046,6 +5046,8 @@ QGraphicsEffect *QWidget::graphicsEffect() const If \a effect is the installed on a different widget, setGraphicsEffect() will remove the effect from the widget and install it on this widget. + QWidget takes ownership of \a effect. + \note This function will apply the effect on itself and all its children. \since 4.6 -- cgit v0.12 From 85cd6e646376af5828e66d9df1812759fcf55f03 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Nilsen?= Date: Tue, 8 Dec 2009 11:52:20 +0100 Subject: Fixes broken graphics effect auto tests. This broke after commit: fb78a402b512b017c850e7410745c4d20da04a7c Effects and auto-tests are now in line with the documentation. --- tests/auto/qgraphicseffect/tst_qgraphicseffect.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tests/auto/qgraphicseffect/tst_qgraphicseffect.cpp b/tests/auto/qgraphicseffect/tst_qgraphicseffect.cpp index d216924..259df4d 100644 --- a/tests/auto/qgraphicseffect/tst_qgraphicseffect.cpp +++ b/tests/auto/qgraphicseffect/tst_qgraphicseffect.cpp @@ -196,8 +196,8 @@ void tst_QGraphicsEffect::source() // Uninstall effect on QGraphicsItem. effect->reset(); item->setGraphicsEffect(0); - QVERIFY(!effect->source()); - QVERIFY(effect->m_sourceChangedFlags & QGraphicsEffect::SourceDetached); + QVERIFY(!effect); + effect = new CustomEffect; // The item takes ownership and should delete the effect when destroyed. item->setGraphicsEffect(effect); @@ -249,10 +249,10 @@ void tst_QGraphicsEffect::boundingRect() QCOMPARE(effect->boundingRect(), effect->boundingRectFor(itemRect)); // Uninstall effect on QGraphicsItem. + QPointer ptr = effect; item->setGraphicsEffect(0); - QCOMPARE(effect->boundingRect(), QRectF()); + QVERIFY(!ptr); - delete effect; delete item; } @@ -343,11 +343,11 @@ void tst_QGraphicsEffect::draw() QCOMPARE(item->numRepaints, 0); // Make sure uninstalling an effect triggers a repaint. + QPointer ptr = effect; item->setGraphicsEffect(0); + QVERIFY(!ptr); QTest::qWait(50); - QCOMPARE(effect->numRepaints, 0); QCOMPARE(item->numRepaints, 1); - delete effect; } void tst_QGraphicsEffect::opacity() -- cgit v0.12 From 76f82b74780cb252782c31e6e690f8529b43b38f Mon Sep 17 00:00:00 2001 From: axis Date: Thu, 12 Nov 2009 13:45:41 +0100 Subject: Fixed searching and copy/paste from PDF documents. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Previously copy and paste from PDFs made by Qt would paste garbage into the target document, and searching was not possible. The bug happened because the internal buffer would open its data stream in truncate mode rather than append mode, thereby losing content, and producing a slightly corrupted PDF. Task: QTBUG-4912 Task: QTBUG-3661 RevBy: Trond KjernÃ¥sen (cherry picked from commit f7ee0c9efcb6cb36a95f49bc998524e25480f8ba) --- src/gui/painting/qpdf.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/painting/qpdf.cpp b/src/gui/painting/qpdf.cpp index 65e4a1e..b5cf54c 100644 --- a/src/gui/painting/qpdf.cpp +++ b/src/gui/painting/qpdf.cpp @@ -141,7 +141,7 @@ namespace QPdf { fileBackingActive(false), handleDirty(false) { - dev->open(QIODevice::ReadWrite); + dev->open(QIODevice::ReadWrite | QIODevice::Append); } ByteStream::ByteStream(bool fileBacking) -- cgit v0.12 From c361d1bb2855b43f5b50adbad321e53848e16b28 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sami=20Meril=C3=A4?= Date: Tue, 8 Dec 2009 15:25:39 +0200 Subject: Crash: when opening the File Dialog in Media Player (armv5) This is due to NGA API changes in Tb9.2. Because of API changes, S60Style needs to have a lot of internal changes. First, the changed style no longer itself tries to uncompress and handle CFbsBitmaps, but instead uses the QPixmap backend for it. Second, all references to CFbsBitmap::DataAddress() have been removed. Third, the lookup table for theme parts has been cleaned up. Task-number: QTBUG-4644 Reviewed-by: Janne Koskinen --- src/gui/styles/qs60style.cpp | 3 - src/gui/styles/qs60style_p.h | 2 +- src/gui/styles/qs60style_s60.cpp | 759 +++++++++++++++------------------------ src/gui/styles/styles.pri | 2 +- 4 files changed, 296 insertions(+), 470 deletions(-) diff --git a/src/gui/styles/qs60style.cpp b/src/gui/styles/qs60style.cpp index be4f15a..93b517f 100644 --- a/src/gui/styles/qs60style.cpp +++ b/src/gui/styles/qs60style.cpp @@ -84,9 +84,6 @@ extern Q_GUI_EXPORT int qt_defaultDpiY(); const QS60StylePrivate::SkinElementFlags QS60StylePrivate::KDefaultSkinElementFlags = SkinElementFlags(SF_PointNorth | SF_StateEnabled); -static const QByteArray propertyKeyLayouts = "layouts"; -static const QByteArray propertyKeyCurrentlayout = "currentlayout"; - static const qreal goldenRatio = 1.618; const layoutHeader QS60StylePrivate::m_layoutHeaders[] = { diff --git a/src/gui/styles/qs60style_p.h b/src/gui/styles/qs60style_p.h index 5ab2308..eed66dc 100644 --- a/src/gui/styles/qs60style_p.h +++ b/src/gui/styles/qs60style_p.h @@ -443,7 +443,7 @@ public: static QSize naviPaneSize(); //Checks that the current brush is transparent or has BrushStyle NoBrush, - //so that theme graphic background can be drawn. + //so that theme graphic background can be drawn. static bool canDrawThemeBackground(const QBrush &backgroundBrush); private: diff --git a/src/gui/styles/qs60style_s60.cpp b/src/gui/styles/qs60style_s60.cpp index 48b8fad..fbea644 100644 --- a/src/gui/styles/qs60style_s60.cpp +++ b/src/gui/styles/qs60style_s60.cpp @@ -62,6 +62,7 @@ #include #include #include +#include #if !defined(QT_NO_STYLE_S60) || defined(QT_PLUGIN) @@ -69,6 +70,7 @@ QT_BEGIN_NAMESPACE enum TDrawType { EDrawIcon, + EDrawGulIcon, EDrawBackground, ENoDraw }; @@ -80,8 +82,11 @@ enum TSupportRelease { ES60_5_0 = 0x0004, ES60_5_1 = 0x0008, ES60_5_2 = 0x0010, + ES60_3_X = ES60_3_1 | ES60_3_2, + // Releases before Symbian Foundation + ES60_PreSF = ES60_3_1 | ES60_3_2 | ES60_5_0, // Add all new releases here - ES60_AllReleases = ES60_3_1 | ES60_3_2 | ES60_5_0 | ES60_5_1 | ES60_5_2 + ES60_All = ES60_3_1 | ES60_3_2 | ES60_5_0 | ES60_5_1 | ES60_5_2 }; typedef struct { @@ -101,11 +106,12 @@ public: static QPixmap colorSkinnedGraphics(const QS60StyleEnums::SkinParts &stylepart, const QSize &size, QPainter *painter, QS60StylePrivate::SkinElementFlags flags); static QColor colorValue(const TAknsItemID &colorGroup, int colorIndex); - static QPixmap fromFbsBitmap(CFbsBitmap *icon, CFbsBitmap *mask, QS60StylePrivate::SkinElementFlags flags, QImage::Format format); + static QPixmap fromFbsBitmap(CFbsBitmap *icon, CFbsBitmap *mask, QS60StylePrivate::SkinElementFlags flags, const TSize& targetSize); static bool disabledPartGraphic(QS60StyleEnums::SkinParts &part); static bool disabledFrameGraphic(QS60StylePrivate::SkinFrameElements &frame); static QPixmap generateMissingThemeGraphic(QS60StyleEnums::SkinParts &part, const QSize &size, QS60StylePrivate::SkinElementFlags flags); static QSize naviPaneSize(); + static TAknsItemID partSpecificThemeId(int part); private: static QPixmap createSkinnedGraphicsLX(QS60StyleEnums::SkinParts part, @@ -115,209 +121,205 @@ private: const QSize &size, QPainter *painter, QS60StylePrivate::SkinElementFlags flags); static void frameIdAndCenterId(QS60StylePrivate::SkinFrameElements frameElement, TAknsItemID &frameId, TAknsItemID ¢erId); static TRect innerRectFromElement(QS60StylePrivate::SkinFrameElements frameElement, const TRect &outerRect); - static void checkAndUnCompressBitmapL(CFbsBitmap*& aOriginalBitmap); - static void checkAndUnCompressBitmap(CFbsBitmap*& aOriginalBitmap); - static void unCompressBitmapL(const TRect& aTrgRect, CFbsBitmap* aTrgBitmap, CFbsBitmap* aSrcBitmap); - static void fallbackInfo(const QS60StyleEnums::SkinParts &stylepart, TDes& fallbackFileName, TInt& fallbackIndex); + static void fallbackInfo(const QS60StyleEnums::SkinParts &stylePart, TInt &fallbackIndex); static bool checkSupport(const int supportedRelease); - static TAknsItemID checkAndUpdateReleaseSpecificGraphics(int part); // Array to match the skin ID, fallback graphics and Qt widget graphics. static const partMapEntry m_partMap[]; }; const partMapEntry QS60StyleModeSpecifics::m_partMap[] = { - /* SP_QgnGrafBarWait */ {KAknsIIDQgnGrafBarWaitAnim, EDrawIcon, ES60_AllReleases, -1,-1}, - /* SP_QgnGrafBarFrameCenter */ {KAknsIIDQgnGrafBarFrameCenter, EDrawIcon, ES60_AllReleases, -1,-1}, - /* SP_QgnGrafBarFrameSideL */ {KAknsIIDQgnGrafBarFrameSideL, EDrawIcon, ES60_AllReleases, -1,-1}, - /* SP_QgnGrafBarFrameSideR */ {KAknsIIDQgnGrafBarFrameSideR, EDrawIcon, ES60_AllReleases, -1,-1}, - /* SP_QgnGrafBarProgress */ {KAknsIIDQgnGrafBarProgress, EDrawIcon, ES60_AllReleases, -1,-1}, - /* SP_QgnGrafScrollArrowDown */ {KAknsIIDQgnGrafScrollArrowDown, EDrawIcon, ES60_AllReleases, -1,-1}, - /* SP_QgnGrafScrollArrowLeft */ {KAknsIIDQgnGrafScrollArrowLeft, EDrawIcon, ES60_AllReleases, -1,-1}, - /* SP_QgnGrafScrollArrowRight */ {KAknsIIDQgnGrafScrollArrowRight, EDrawIcon, ES60_AllReleases, -1,-1}, - /* SP_QgnGrafScrollArrowUp */ {KAknsIIDQgnGrafScrollArrowUp, EDrawIcon, ES60_AllReleases, -1,-1}, - /* SP_QgnGrafTabActiveL */ {KAknsIIDQgnGrafTabActiveL, EDrawIcon, ES60_AllReleases, -1,-1}, - /* SP_QgnGrafTabActiveM */ {KAknsIIDQgnGrafTabActiveM, EDrawIcon, ES60_AllReleases, -1,-1}, - /* SP_QgnGrafTabActiveR */ {KAknsIIDQgnGrafTabActiveR, EDrawIcon, ES60_AllReleases, -1,-1}, - /* SP_QgnGrafTabPassiveL */ {KAknsIIDQgnGrafTabPassiveL, EDrawIcon, ES60_AllReleases, -1,-1}, - /* SP_QgnGrafTabPassiveM */ {KAknsIIDQgnGrafTabPassiveM, EDrawIcon, ES60_AllReleases, -1,-1}, - /* SP_QgnGrafTabPassiveR */ {KAknsIIDQgnGrafTabPassiveR, EDrawIcon, ES60_AllReleases, -1,-1}, - /* SP_QgnIndiCheckboxOff */ {KAknsIIDQgnIndiCheckboxOff, EDrawIcon, ES60_AllReleases, -1,-1}, - /* SP_QgnIndiCheckboxOn */ {KAknsIIDQgnIndiCheckboxOn, EDrawIcon, ES60_AllReleases, -1,-1}, + /* SP_QgnGrafBarWait */ {KAknsIIDQgnGrafBarWaitAnim, EDrawIcon, ES60_All, -1,-1}, + /* SP_QgnGrafBarFrameCenter */ {KAknsIIDQgnGrafBarFrameCenter, EDrawIcon, ES60_All, -1,-1}, + /* SP_QgnGrafBarFrameSideL */ {KAknsIIDQgnGrafBarFrameSideL, EDrawIcon, ES60_All, -1,-1}, + /* SP_QgnGrafBarFrameSideR */ {KAknsIIDQgnGrafBarFrameSideR, EDrawIcon, ES60_All, -1,-1}, + /* SP_QgnGrafBarProgress */ {KAknsIIDQgnGrafBarProgress, EDrawIcon, ES60_All, -1,-1}, + /* SP_QgnGrafScrollArrowDown */ {KAknsIIDQgnGrafScrollArrowDown, EDrawGulIcon, ES60_All, -1,-1}, + /* SP_QgnGrafScrollArrowLeft */ {KAknsIIDQgnGrafScrollArrowLeft, EDrawGulIcon, ES60_All, -1,-1}, + /* SP_QgnGrafScrollArrowRight */ {KAknsIIDQgnGrafScrollArrowRight, EDrawGulIcon, ES60_All, -1,-1}, + /* SP_QgnGrafScrollArrowUp */ {KAknsIIDQgnGrafScrollArrowUp, EDrawGulIcon, ES60_All, -1,-1}, + /* SP_QgnGrafTabActiveL */ {KAknsIIDQgnGrafTabActiveL, EDrawIcon, ES60_All, -1,-1}, + /* SP_QgnGrafTabActiveM */ {KAknsIIDQgnGrafTabActiveM, EDrawIcon, ES60_All, -1,-1}, + /* SP_QgnGrafTabActiveR */ {KAknsIIDQgnGrafTabActiveR, EDrawIcon, ES60_All, -1,-1}, + /* SP_QgnGrafTabPassiveL */ {KAknsIIDQgnGrafTabPassiveL, EDrawIcon, ES60_All, -1,-1}, + /* SP_QgnGrafTabPassiveM */ {KAknsIIDQgnGrafTabPassiveM, EDrawIcon, ES60_All, -1,-1}, + /* SP_QgnGrafTabPassiveR */ {KAknsIIDQgnGrafTabPassiveR, EDrawIcon, ES60_All, -1,-1}, + /* SP_QgnIndiCheckboxOff */ {KAknsIIDQgnIndiCheckboxOff, EDrawIcon, ES60_All, -1,-1}, + /* SP_QgnIndiCheckboxOn */ {KAknsIIDQgnIndiCheckboxOn, EDrawIcon, ES60_All, -1,-1}, // Following 5 items (SP_QgnIndiHlColSuper - SP_QgnIndiHlLineStraight) are available starting from S60 release 3.2. // In 3.1 CommonStyle drawing is used for these QTreeView elements, since no similar icons in AVKON UI. - /* SP_QgnIndiHlColSuper */ {KAknsIIDNone, EDrawIcon, ES60_3_1, EAknsMajorGeneric, 0x17d5 /* KAknsIIDQgnIndiHlColSuper */}, - /* SP_QgnIndiHlExpSuper */ {KAknsIIDNone, EDrawIcon, ES60_3_1, EAknsMajorGeneric, 0x17d6 /* KAknsIIDQgnIndiHlExpSuper */}, - /* SP_QgnIndiHlLineBranch */ {KAknsIIDNone, EDrawIcon, ES60_3_1, EAknsMajorGeneric, 0x17d7 /* KAknsIIDQgnIndiHlLineBranch */}, - /* SP_QgnIndiHlLineEnd */ {KAknsIIDNone, EDrawIcon, ES60_3_1, EAknsMajorGeneric, 0x17d8 /* KAknsIIDQgnIndiHlLineEnd */}, - /* SP_QgnIndiHlLineStraight */ {KAknsIIDNone, EDrawIcon, ES60_3_1, EAknsMajorGeneric, 0x17d9 /* KAknsIIDQgnIndiHlLineStraight */}, - /* SP_QgnIndiMarkedAdd */ {KAknsIIDQgnIndiMarkedAdd, EDrawIcon, ES60_AllReleases, -1,-1}, - /* SP_QgnIndiNaviArrowLeft */ {KAknsIIDQgnGrafScrollArrowLeft, EDrawIcon, ES60_AllReleases, -1,-1}, - /* SP_QgnIndiNaviArrowRight */ {KAknsIIDQgnGrafScrollArrowRight, EDrawIcon, ES60_AllReleases, -1,-1}, - /* SP_QgnIndiRadiobuttOff */ {KAknsIIDQgnIndiRadiobuttOff, EDrawIcon, ES60_AllReleases, -1,-1}, - /* SP_QgnIndiRadiobuttOn */ {KAknsIIDQgnIndiRadiobuttOn, EDrawIcon, ES60_AllReleases, -1,-1}, - /* SP_QgnIndiSliderEdit */ {KAknsIIDQgnIndiSliderEdit, EDrawIcon, ES60_AllReleases, -1,-1}, - /* SP_QgnIndiSubMenu */ {KAknsIIDQgnIndiSubmenu, EDrawIcon, ES60_AllReleases, -1,-1}, - /* SP_QgnNoteErased */ {KAknsIIDQgnNoteErased, EDrawIcon, ES60_AllReleases, -1,-1}, - /* SP_QgnNoteError */ {KAknsIIDQgnNoteError, EDrawIcon, ES60_AllReleases, -1,-1}, - /* SP_QgnNoteInfo */ {KAknsIIDQgnNoteInfo, EDrawIcon, ES60_AllReleases, -1,-1}, - /* SP_QgnNoteOk */ {KAknsIIDQgnNoteOk, EDrawIcon, ES60_AllReleases, -1,-1}, - /* SP_QgnNoteQuery */ {KAknsIIDQgnNoteQuery, EDrawIcon, ES60_AllReleases, -1,-1}, - /* SP_QgnNoteWarning */ {KAknsIIDQgnNoteWarning, EDrawIcon, ES60_AllReleases, -1,-1}, - /* SP_QgnPropFileSmall */ {KAknsIIDQgnPropFileSmall, EDrawIcon, ES60_AllReleases, -1,-1}, - /* SP_QgnPropFolderCurrent */ {KAknsIIDQgnPropFolderCurrent, EDrawIcon, ES60_AllReleases, -1,-1}, - /* SP_QgnPropFolderSmall */ {KAknsIIDQgnPropFolderSmall, EDrawIcon, ES60_AllReleases, -1,-1}, - /* SP_QgnPropFolderSmallNew */ {KAknsIIDQgnPropFolderSmallNew, EDrawIcon, ES60_AllReleases, -1,-1}, - /* SP_QgnPropPhoneMemcLarge */ {KAknsIIDQgnPropPhoneMemcLarge, EDrawIcon, ES60_AllReleases, -1,-1}, + /* SP_QgnIndiHlColSuper */ {KAknsIIDNone, EDrawIcon, ES60_3_1, EAknsMajorGeneric, 0x17d5 /* KAknsIIDQgnIndiHlColSuper */}, + /* SP_QgnIndiHlExpSuper */ {KAknsIIDNone, EDrawIcon, ES60_3_1, EAknsMajorGeneric, 0x17d6 /* KAknsIIDQgnIndiHlExpSuper */}, + /* SP_QgnIndiHlLineBranch */ {KAknsIIDNone, EDrawIcon, ES60_3_1, EAknsMajorGeneric, 0x17d7 /* KAknsIIDQgnIndiHlLineBranch */}, + /* SP_QgnIndiHlLineEnd */ {KAknsIIDNone, EDrawIcon, ES60_3_1, EAknsMajorGeneric, 0x17d8 /* KAknsIIDQgnIndiHlLineEnd */}, + /* SP_QgnIndiHlLineStraight */ {KAknsIIDNone, EDrawIcon, ES60_3_1, EAknsMajorGeneric, 0x17d9 /* KAknsIIDQgnIndiHlLineStraight */}, + /* SP_QgnIndiMarkedAdd */ {KAknsIIDQgnIndiMarkedAdd, EDrawIcon, ES60_All, -1,-1}, + /* SP_QgnIndiNaviArrowLeft */ {KAknsIIDQgnIndiNaviArrowLeft, EDrawIcon, ES60_All, -1,-1}, + /* SP_QgnIndiNaviArrowRight */ {KAknsIIDQgnIndiNaviArrowRight, EDrawIcon, ES60_All, -1,-1}, + /* SP_QgnIndiRadiobuttOff */ {KAknsIIDQgnIndiRadiobuttOff, EDrawIcon, ES60_All, -1,-1}, + /* SP_QgnIndiRadiobuttOn */ {KAknsIIDQgnIndiRadiobuttOn, EDrawIcon, ES60_All, -1,-1}, + /* SP_QgnIndiSliderEdit */ {KAknsIIDQgnIndiSliderEdit, EDrawIcon, ES60_All, -1,-1}, + /* SP_QgnIndiSubMenu */ {KAknsIIDQgnIndiSubmenu, EDrawIcon, ES60_All, -1,-1}, + /* SP_QgnNoteErased */ {KAknsIIDQgnNoteErased, EDrawIcon, ES60_All, -1,-1}, + /* SP_QgnNoteError */ {KAknsIIDQgnNoteError, EDrawIcon, ES60_All, -1,-1}, + /* SP_QgnNoteInfo */ {KAknsIIDQgnNoteInfo, EDrawIcon, ES60_All, -1,-1}, + /* SP_QgnNoteOk */ {KAknsIIDQgnNoteOk, EDrawIcon, ES60_All, -1,-1}, + /* SP_QgnNoteQuery */ {KAknsIIDQgnNoteQuery, EDrawIcon, ES60_All, -1,-1}, + /* SP_QgnNoteWarning */ {KAknsIIDQgnNoteWarning, EDrawIcon, ES60_All, -1,-1}, + /* SP_QgnPropFileSmall */ {KAknsIIDQgnPropFileSmall, EDrawIcon, ES60_All, -1,-1}, + /* SP_QgnPropFolderCurrent */ {KAknsIIDQgnPropFolderCurrent, EDrawIcon, ES60_All, -1,-1}, + /* SP_QgnPropFolderSmall */ {KAknsIIDQgnPropFolderSmall, EDrawIcon, ES60_All, -1,-1}, + /* SP_QgnPropFolderSmallNew */ {KAknsIIDQgnPropFolderSmallNew, EDrawIcon, ES60_All, -1,-1}, + /* SP_QgnPropPhoneMemcLarge */ {KAknsIIDQgnPropPhoneMemcLarge, EDrawIcon, ES60_All, -1,-1}, // 3.1 & 3.2 do not have pressed state for scrollbar, so use normal scrollbar graphics instead. - /* SP_QsnCpScrollHandleBottomPressed*/ {KAknsIIDQsnCpScrollHandleBottom, EDrawIcon, ES60_3_1 | ES60_3_2, EAknsMajorGeneric, 0x20f8}, /*KAknsIIDQsnCpScrollHandleBottomPressed*/ - /* SP_QsnCpScrollHandleMiddlePressed*/ {KAknsIIDQsnCpScrollHandleMiddle, EDrawIcon, ES60_3_1 | ES60_3_2, EAknsMajorGeneric, 0x20f9}, /*KAknsIIDQsnCpScrollHandleMiddlePressed*/ - /* SP_QsnCpScrollHandleTopPressed*/ {KAknsIIDQsnCpScrollHandleTop, EDrawIcon, ES60_3_1 | ES60_3_2, EAknsMajorGeneric, 0x20fa}, /*KAknsIIDQsnCpScrollHandleTopPressed*/ - - /* SP_QsnBgScreen */ {KAknsIIDQsnBgScreen, EDrawBackground, ES60_AllReleases, -1,-1}, - - /* SP_QsnCpScrollBgBottom */ {KAknsIIDQsnCpScrollBgBottom, EDrawIcon, ES60_AllReleases, -1,-1}, - /* SP_QsnCpScrollBgMiddle */ {KAknsIIDQsnCpScrollBgMiddle, EDrawIcon, ES60_AllReleases, -1,-1}, - /* SP_QsnCpScrollBgTop */ {KAknsIIDQsnCpScrollBgTop, EDrawIcon, ES60_AllReleases, -1,-1}, - - /* SP_QsnCpScrollHandleBottom */ {KAknsIIDQsnCpScrollHandleBottom, EDrawIcon, ES60_AllReleases, -1,-1}, - /* SP_QsnCpScrollHandleMiddle */ {KAknsIIDQsnCpScrollHandleMiddle, EDrawIcon, ES60_AllReleases, -1,-1}, - /* SP_QsnCpScrollHandleTop */ {KAknsIIDQsnCpScrollHandleTop, EDrawIcon, ES60_AllReleases, -1,-1}, - - /* SP_QsnFrButtonTbCornerTl */ {KAknsIIDQsnFrButtonTbCornerTl, ENoDraw, ES60_AllReleases, -1,-1}, //todo: use "normal button" from 5.0 onwards - /* SP_QsnFrButtonTbCornerTr */ {KAknsIIDQsnFrButtonTbCornerTr, ENoDraw, ES60_AllReleases, -1,-1}, - /* SP_QsnFrButtonTbCornerBl */ {KAknsIIDQsnFrButtonTbCornerBl, ENoDraw, ES60_AllReleases, -1,-1}, - /* SP_QsnFrButtonTbCornerBr */ {KAknsIIDQsnFrButtonTbCornerBr, ENoDraw, ES60_AllReleases, -1,-1}, - /* SP_QsnFrButtonTbSideT */ {KAknsIIDQsnFrButtonTbSideT, ENoDraw, ES60_AllReleases, -1,-1}, - /* SP_QsnFrButtonTbSideB */ {KAknsIIDQsnFrButtonTbSideB, ENoDraw, ES60_AllReleases, -1,-1}, - /* SP_QsnFrButtonTbSideL */ {KAknsIIDQsnFrButtonTbSideL, ENoDraw, ES60_AllReleases, -1,-1}, - /* SP_QsnFrButtonTbSideR */ {KAknsIIDQsnFrButtonTbSideR, ENoDraw, ES60_AllReleases, -1,-1}, - /* SP_QsnFrButtonTbCenter */ {KAknsIIDQsnFrButtonTbCenter, EDrawIcon, ES60_AllReleases, -1,-1}, - - /* SP_QsnFrButtonTbCornerTlPressed */{KAknsIIDQsnFrButtonTbCornerTlPressed, ENoDraw, ES60_AllReleases, -1,-1}, - /* SP_QsnFrButtonTbCornerTrPressed */{KAknsIIDQsnFrButtonTbCornerTrPressed, ENoDraw, ES60_AllReleases, -1,-1}, - /* SP_QsnFrButtonTbCornerBlPressed */{KAknsIIDQsnFrButtonTbCornerBlPressed, ENoDraw, ES60_AllReleases, -1,-1}, - /* SP_QsnFrButtonTbCornerBrPressed */{KAknsIIDQsnFrButtonTbCornerBrPressed, ENoDraw, ES60_AllReleases, -1,-1}, - /* SP_QsnFrButtonTbSideTPressed */ {KAknsIIDQsnFrButtonTbSideTPressed, ENoDraw, ES60_AllReleases, -1,-1}, - /* SP_QsnFrButtonTbSideBPressed */ {KAknsIIDQsnFrButtonTbSideBPressed, ENoDraw, ES60_AllReleases, -1,-1}, - /* SP_QsnFrButtonTbSideLPressed */ {KAknsIIDQsnFrButtonTbSideLPressed, ENoDraw, ES60_AllReleases, -1,-1}, - /* SP_QsnFrButtonTbSideRPressed */ {KAknsIIDQsnFrButtonTbSideRPressed, ENoDraw, ES60_AllReleases, -1,-1}, - /* SP_QsnFrButtonTbCenterPressed */ {KAknsIIDQsnFrButtonTbCenterPressed, EDrawIcon, ES60_AllReleases, -1,-1}, - - /* SP_QsnFrCaleCornerTl */ {KAknsIIDQsnFrCaleCornerTl, ENoDraw, ES60_AllReleases, -1,-1}, - /* SP_QsnFrCaleCornerTr */ {KAknsIIDQsnFrCaleCornerTr, ENoDraw, ES60_AllReleases, -1,-1}, - /* SP_QsnFrCaleCornerBl */ {KAknsIIDQsnFrCaleCornerBl, ENoDraw, ES60_AllReleases, -1,-1}, - /* SP_QsnFrCaleCornerBr */ {KAknsIIDQsnFrCaleCornerBr, ENoDraw, ES60_AllReleases, -1,-1}, - /* SP_QsnFrCaleGSideT */ {KAknsIIDQsnFrCaleSideT, ENoDraw, ES60_AllReleases, -1,-1}, - /* SP_QsnFrCaleGSideB */ {KAknsIIDQsnFrCaleSideB, ENoDraw, ES60_AllReleases, -1,-1}, - /* SP_QsnFrCaleGSideL */ {KAknsIIDQsnFrCaleSideL, ENoDraw, ES60_AllReleases, -1,-1}, - /* SP_QsnFrCaleGSideR */ {KAknsIIDQsnFrCaleSideR, ENoDraw, ES60_AllReleases, -1,-1}, - /* SP_QsnFrCaleCenter */ {KAknsIIDQsnFrCaleCenter, ENoDraw, ES60_AllReleases, -1,-1}, - - /* SP_QsnFrCaleHeadingCornerTl */ {KAknsIIDQsnFrCaleHeadingCornerTl, ENoDraw, ES60_AllReleases, -1,-1}, - /* SP_QsnFrCaleHeadingCornerTr */ {KAknsIIDQsnFrCaleHeadingCornerTr, ENoDraw, ES60_AllReleases, -1,-1}, - /* SP_QsnFrCaleHeadingCornerBl */ {KAknsIIDQsnFrCaleHeadingCornerBl, ENoDraw, ES60_AllReleases, -1,-1}, - /* SP_QsnFrCaleHeadingCornerBr */ {KAknsIIDQsnFrCaleHeadingCornerBr, ENoDraw, ES60_AllReleases, -1,-1}, - /* SP_QsnFrCaleHeadingSideT */ {KAknsIIDQsnFrCaleHeadingSideT, ENoDraw, ES60_AllReleases, -1,-1}, - /* SP_QsnFrCaleHeadingSideB */ {KAknsIIDQsnFrCaleHeadingSideB, ENoDraw, ES60_AllReleases, -1,-1}, - /* SP_QsnFrCaleHeadingSideL */ {KAknsIIDQsnFrCaleHeadingSideL, ENoDraw, ES60_AllReleases, -1,-1}, - /* SP_QsnFrCaleHeadingSideR */ {KAknsIIDQsnFrCaleHeadingSideR, ENoDraw, ES60_AllReleases, -1,-1}, - /* SP_QsnFrCaleHeadingCenter */ {KAknsIIDQsnFrCaleHeadingCenter, ENoDraw, ES60_AllReleases, -1,-1}, - - /* SP_QsnFrInputCornerTl */ {KAknsIIDQsnFrInputCornerTl, ENoDraw, ES60_AllReleases, -1,-1}, - /* SP_QsnFrInputCornerTr */ {KAknsIIDQsnFrInputCornerTr, ENoDraw, ES60_AllReleases, -1,-1}, - /* SP_QsnFrInputCornerBl */ {KAknsIIDQsnFrInputCornerBl, ENoDraw, ES60_AllReleases, -1,-1}, - /* SP_QsnFrInputCornerBr */ {KAknsIIDQsnFrInputCornerBr, ENoDraw, ES60_AllReleases, -1,-1}, - /* SP_QsnFrInputSideT */ {KAknsIIDQsnFrInputSideT, ENoDraw, ES60_AllReleases, -1,-1}, - /* SP_QsnFrInputSideB */ {KAknsIIDQsnFrInputSideB, ENoDraw, ES60_AllReleases, -1,-1}, - /* SP_QsnFrInputSideL */ {KAknsIIDQsnFrInputSideL, ENoDraw, ES60_AllReleases, -1,-1}, - /* SP_QsnFrInputSideR */ {KAknsIIDQsnFrInputSideR, ENoDraw, ES60_AllReleases, -1,-1}, - /* SP_QsnFrInputCenter */ {KAknsIIDQsnFrInputCenter, ENoDraw, ES60_AllReleases, -1,-1}, - - /* SP_QsnFrListCornerTl */ {KAknsIIDQsnFrListCornerTl, ENoDraw, ES60_AllReleases, -1,-1}, - /* SP_QsnFrListCornerTr */ {KAknsIIDQsnFrListCornerTr, ENoDraw, ES60_AllReleases, -1,-1}, - /* SP_QsnFrListCornerBl */ {KAknsIIDQsnFrListCornerBl, ENoDraw, ES60_AllReleases, -1,-1}, - /* SP_QsnFrListCornerBr */ {KAknsIIDQsnFrListCornerBr, ENoDraw, ES60_AllReleases, -1,-1}, - /* SP_QsnFrListSideT */ {KAknsIIDQsnFrListSideT, ENoDraw, ES60_AllReleases, -1,-1}, - /* SP_QsnFrListSideB */ {KAknsIIDQsnFrListSideB, ENoDraw, ES60_AllReleases, -1,-1}, - /* SP_QsnFrListSideL */ {KAknsIIDQsnFrListSideL, ENoDraw, ES60_AllReleases, -1,-1}, - /* SP_QsnFrListSideR */ {KAknsIIDQsnFrListSideR, ENoDraw, ES60_AllReleases, -1,-1}, - /* SP_QsnFrListCenter */ {KAknsIIDQsnFrListCenter, ENoDraw, ES60_AllReleases, -1,-1}, - - /* SP_QsnFrPopupCornerTl */ {KAknsIIDQsnFrPopupCornerTl, ENoDraw, ES60_AllReleases, -1,-1}, - /* SP_QsnFrPopupCornerTr */ {KAknsIIDQsnFrPopupCornerTr, ENoDraw, ES60_AllReleases, -1,-1}, - /* SP_QsnFrPopupCornerBl */ {KAknsIIDQsnFrPopupCornerBl, ENoDraw, ES60_AllReleases, -1,-1}, - /* SP_QsnFrPopupCornerBr */ {KAknsIIDQsnFrPopupCornerBr, ENoDraw, ES60_AllReleases, -1,-1}, - /* SP_QsnFrPopupSideT */ {KAknsIIDQsnFrPopupSideT, ENoDraw, ES60_AllReleases, -1,-1}, - /* SP_QsnFrPopupSideB */ {KAknsIIDQsnFrPopupSideB, ENoDraw, ES60_AllReleases, -1,-1}, - /* SP_QsnFrPopupSideL */ {KAknsIIDQsnFrPopupSideL, ENoDraw, ES60_AllReleases, -1,-1}, - /* SP_QsnFrPopupSideR */ {KAknsIIDQsnFrPopupSideR, ENoDraw, ES60_AllReleases, -1,-1}, - /* SP_QsnFrPopupCenter */ {KAknsIIDQsnFrPopupCenter, ENoDraw, ES60_AllReleases, -1,-1}, + /* SP_QsnCpScrollHandleBottomPressed*/ {KAknsIIDQsnCpScrollHandleBottom, EDrawIcon, ES60_3_X, EAknsMajorGeneric, 0x20f8}, /*KAknsIIDQsnCpScrollHandleBottomPressed*/ + /* SP_QsnCpScrollHandleMiddlePressed*/ {KAknsIIDQsnCpScrollHandleMiddle, EDrawIcon, ES60_3_X, EAknsMajorGeneric, 0x20f9}, /*KAknsIIDQsnCpScrollHandleMiddlePressed*/ + /* SP_QsnCpScrollHandleTopPressed*/ {KAknsIIDQsnCpScrollHandleTop, EDrawIcon, ES60_3_X, EAknsMajorGeneric, 0x20fa}, /*KAknsIIDQsnCpScrollHandleTopPressed*/ + + /* SP_QsnBgScreen */ {KAknsIIDQsnBgScreen, EDrawBackground, ES60_All, -1,-1}, + + /* SP_QsnCpScrollBgBottom */ {KAknsIIDQsnCpScrollBgBottom, EDrawIcon, ES60_All, -1,-1}, + /* SP_QsnCpScrollBgMiddle */ {KAknsIIDQsnCpScrollBgMiddle, EDrawIcon, ES60_All, -1,-1}, + /* SP_QsnCpScrollBgTop */ {KAknsIIDQsnCpScrollBgTop, EDrawIcon, ES60_All, -1,-1}, + + /* SP_QsnCpScrollHandleBottom */ {KAknsIIDQsnCpScrollHandleBottom, EDrawIcon, ES60_All, -1,-1}, + /* SP_QsnCpScrollHandleMiddle */ {KAknsIIDQsnCpScrollHandleMiddle, EDrawIcon, ES60_All, -1,-1}, + /* SP_QsnCpScrollHandleTop */ {KAknsIIDQsnCpScrollHandleTop, EDrawIcon, ES60_All, -1,-1}, + + /* SP_QsnFrButtonTbCornerTl */ {KAknsIIDQsnFrButtonTbCornerTl, ENoDraw, ES60_All, -1, -1}, + /* SP_QsnFrButtonTbCornerTr */ {KAknsIIDQsnFrButtonTbCornerTr, ENoDraw, ES60_All, -1, -1}, + /* SP_QsnFrButtonTbCornerBl */ {KAknsIIDQsnFrButtonTbCornerBl, ENoDraw, ES60_All, -1, -1}, + /* SP_QsnFrButtonTbCornerBr */ {KAknsIIDQsnFrButtonTbCornerBr, ENoDraw, ES60_All, -1, -1}, + /* SP_QsnFrButtonTbSideT */ {KAknsIIDQsnFrButtonTbSideT, ENoDraw, ES60_All, -1, -1}, + /* SP_QsnFrButtonTbSideB */ {KAknsIIDQsnFrButtonTbSideB, ENoDraw, ES60_All, -1, -1}, + /* SP_QsnFrButtonTbSideL */ {KAknsIIDQsnFrButtonTbSideL, ENoDraw, ES60_All, -1, -1}, + /* SP_QsnFrButtonTbSideR */ {KAknsIIDQsnFrButtonTbSideR, ENoDraw, ES60_All, -1, -1}, + /* SP_QsnFrButtonTbCenter */ {KAknsIIDQsnFrButtonTbCenter, EDrawIcon, ES60_All, -1, -1}, + + /* SP_QsnFrButtonTbCornerTlPressed */{KAknsIIDQsnFrButtonTbCornerTlPressed, ENoDraw, ES60_All, -1,-1}, + /* SP_QsnFrButtonTbCornerTrPressed */{KAknsIIDQsnFrButtonTbCornerTrPressed, ENoDraw, ES60_All, -1,-1}, + /* SP_QsnFrButtonTbCornerBlPressed */{KAknsIIDQsnFrButtonTbCornerBlPressed, ENoDraw, ES60_All, -1,-1}, + /* SP_QsnFrButtonTbCornerBrPressed */{KAknsIIDQsnFrButtonTbCornerBrPressed, ENoDraw, ES60_All, -1,-1}, + /* SP_QsnFrButtonTbSideTPressed */ {KAknsIIDQsnFrButtonTbSideTPressed, ENoDraw, ES60_All, -1,-1}, + /* SP_QsnFrButtonTbSideBPressed */ {KAknsIIDQsnFrButtonTbSideBPressed, ENoDraw, ES60_All, -1,-1}, + /* SP_QsnFrButtonTbSideLPressed */ {KAknsIIDQsnFrButtonTbSideLPressed, ENoDraw, ES60_All, -1,-1}, + /* SP_QsnFrButtonTbSideRPressed */ {KAknsIIDQsnFrButtonTbSideRPressed, ENoDraw, ES60_All, -1,-1}, + /* SP_QsnFrButtonTbCenterPressed */ {KAknsIIDQsnFrButtonTbCenterPressed, EDrawIcon, ES60_All, -1,-1}, + + /* SP_QsnFrCaleCornerTl */ {KAknsIIDQsnFrCaleCornerTl, ENoDraw, ES60_All, -1,-1}, + /* SP_QsnFrCaleCornerTr */ {KAknsIIDQsnFrCaleCornerTr, ENoDraw, ES60_All, -1,-1}, + /* SP_QsnFrCaleCornerBl */ {KAknsIIDQsnFrCaleCornerBl, ENoDraw, ES60_All, -1,-1}, + /* SP_QsnFrCaleCornerBr */ {KAknsIIDQsnFrCaleCornerBr, ENoDraw, ES60_All, -1,-1}, + /* SP_QsnFrCaleGSideT */ {KAknsIIDQsnFrCaleSideT, ENoDraw, ES60_All, -1,-1}, + /* SP_QsnFrCaleGSideB */ {KAknsIIDQsnFrCaleSideB, ENoDraw, ES60_All, -1,-1}, + /* SP_QsnFrCaleGSideL */ {KAknsIIDQsnFrCaleSideL, ENoDraw, ES60_All, -1,-1}, + /* SP_QsnFrCaleGSideR */ {KAknsIIDQsnFrCaleSideR, ENoDraw, ES60_All, -1,-1}, + /* SP_QsnFrCaleCenter */ {KAknsIIDQsnFrCaleCenter, ENoDraw, ES60_All, -1,-1}, + + /* SP_QsnFrCaleHeadingCornerTl */ {KAknsIIDQsnFrCaleHeadingCornerTl, ENoDraw, ES60_All, -1,-1}, + /* SP_QsnFrCaleHeadingCornerTr */ {KAknsIIDQsnFrCaleHeadingCornerTr, ENoDraw, ES60_All, -1,-1}, + /* SP_QsnFrCaleHeadingCornerBl */ {KAknsIIDQsnFrCaleHeadingCornerBl, ENoDraw, ES60_All, -1,-1}, + /* SP_QsnFrCaleHeadingCornerBr */ {KAknsIIDQsnFrCaleHeadingCornerBr, ENoDraw, ES60_All, -1,-1}, + /* SP_QsnFrCaleHeadingSideT */ {KAknsIIDQsnFrCaleHeadingSideT, ENoDraw, ES60_All, -1,-1}, + /* SP_QsnFrCaleHeadingSideB */ {KAknsIIDQsnFrCaleHeadingSideB, ENoDraw, ES60_All, -1,-1}, + /* SP_QsnFrCaleHeadingSideL */ {KAknsIIDQsnFrCaleHeadingSideL, ENoDraw, ES60_All, -1,-1}, + /* SP_QsnFrCaleHeadingSideR */ {KAknsIIDQsnFrCaleHeadingSideR, ENoDraw, ES60_All, -1,-1}, + /* SP_QsnFrCaleHeadingCenter */ {KAknsIIDQsnFrCaleHeadingCenter, ENoDraw, ES60_All, -1,-1}, + + /* SP_QsnFrInputCornerTl */ {KAknsIIDQsnFrInputCornerTl, ENoDraw, ES60_All, -1,-1}, + /* SP_QsnFrInputCornerTr */ {KAknsIIDQsnFrInputCornerTr, ENoDraw, ES60_All, -1,-1}, + /* SP_QsnFrInputCornerBl */ {KAknsIIDQsnFrInputCornerBl, ENoDraw, ES60_All, -1,-1}, + /* SP_QsnFrInputCornerBr */ {KAknsIIDQsnFrInputCornerBr, ENoDraw, ES60_All, -1,-1}, + /* SP_QsnFrInputSideT */ {KAknsIIDQsnFrInputSideT, ENoDraw, ES60_All, -1,-1}, + /* SP_QsnFrInputSideB */ {KAknsIIDQsnFrInputSideB, ENoDraw, ES60_All, -1,-1}, + /* SP_QsnFrInputSideL */ {KAknsIIDQsnFrInputSideL, ENoDraw, ES60_All, -1,-1}, + /* SP_QsnFrInputSideR */ {KAknsIIDQsnFrInputSideR, ENoDraw, ES60_All, -1,-1}, + /* SP_QsnFrInputCenter */ {KAknsIIDQsnFrInputCenter, ENoDraw, ES60_All, -1,-1}, + + /* SP_QsnFrListCornerTl */ {KAknsIIDQsnFrListCornerTl, ENoDraw, ES60_All, -1,-1}, + /* SP_QsnFrListCornerTr */ {KAknsIIDQsnFrListCornerTr, ENoDraw, ES60_All, -1,-1}, + /* SP_QsnFrListCornerBl */ {KAknsIIDQsnFrListCornerBl, ENoDraw, ES60_All, -1,-1}, + /* SP_QsnFrListCornerBr */ {KAknsIIDQsnFrListCornerBr, ENoDraw, ES60_All, -1,-1}, + /* SP_QsnFrListSideT */ {KAknsIIDQsnFrListSideT, ENoDraw, ES60_All, -1,-1}, + /* SP_QsnFrListSideB */ {KAknsIIDQsnFrListSideB, ENoDraw, ES60_All, -1,-1}, + /* SP_QsnFrListSideL */ {KAknsIIDQsnFrListSideL, ENoDraw, ES60_All, -1,-1}, + /* SP_QsnFrListSideR */ {KAknsIIDQsnFrListSideR, ENoDraw, ES60_All, -1,-1}, + /* SP_QsnFrListCenter */ {KAknsIIDQsnFrListCenter, ENoDraw, ES60_All, -1,-1}, + + /* SP_QsnFrPopupCornerTl */ {KAknsIIDQsnFrPopupCornerTl, ENoDraw, ES60_All, -1,-1}, + /* SP_QsnFrPopupCornerTr */ {KAknsIIDQsnFrPopupCornerTr, ENoDraw, ES60_All, -1,-1}, + /* SP_QsnFrPopupCornerBl */ {KAknsIIDQsnFrPopupCornerBl, ENoDraw, ES60_All, -1,-1}, + /* SP_QsnFrPopupCornerBr */ {KAknsIIDQsnFrPopupCornerBr, ENoDraw, ES60_All, -1,-1}, + /* SP_QsnFrPopupSideT */ {KAknsIIDQsnFrPopupSideT, ENoDraw, ES60_All, -1,-1}, + /* SP_QsnFrPopupSideB */ {KAknsIIDQsnFrPopupSideB, ENoDraw, ES60_All, -1,-1}, + /* SP_QsnFrPopupSideL */ {KAknsIIDQsnFrPopupSideL, ENoDraw, ES60_All, -1,-1}, + /* SP_QsnFrPopupSideR */ {KAknsIIDQsnFrPopupSideR, ENoDraw, ES60_All, -1,-1}, + /* SP_QsnFrPopupCenter */ {KAknsIIDQsnFrPopupCenter, ENoDraw, ES60_All, -1,-1}, // ToolTip graphics different in 3.1 vs. 3.2+. - /* SP_QsnFrPopupPreviewCornerTl */ {KAknsIIDQsnFrPopupCornerTl, ENoDraw, ES60_3_1, EAknsMajorSkin, 0x19c5}, /* KAknsIIDQsnFrPopupPreviewCornerTl */ - /* SP_QsnFrPopupPreviewCornerTr */ {KAknsIIDQsnFrPopupCornerTr, ENoDraw, ES60_3_1, EAknsMajorSkin, 0x19c6}, - /* SP_QsnFrPopupPreviewCornerBl */ {KAknsIIDQsnFrPopupCornerBl, ENoDraw, ES60_3_1, EAknsMajorSkin, 0x19c3}, - /* SP_QsnFrPopupPreviewCornerBr */ {KAknsIIDQsnFrPopupCornerBr, ENoDraw, ES60_3_1, EAknsMajorSkin, 0x19c4}, - /* SP_QsnFrPopupPreviewSideT */ {KAknsIIDQsnFrPopupSideT, ENoDraw, ES60_3_1, EAknsMajorSkin, 0x19ca}, - /* SP_QsnFrPopupPreviewSideB */ {KAknsIIDQsnFrPopupSideB, ENoDraw, ES60_3_1, EAknsMajorSkin, 0x19c7}, - /* SP_QsnFrPopupPreviewSideL */ {KAknsIIDQsnFrPopupSideL, ENoDraw, ES60_3_1, EAknsMajorSkin, 0x19c8}, - /* SP_QsnFrPopupPreviewSideR */ {KAknsIIDQsnFrPopupSideR, ENoDraw, ES60_3_1, EAknsMajorSkin, 0x19c9}, - /* SP_QsnFrPopupPreviewCenter */ {KAknsIIDQsnFrPopupCenter, ENoDraw, ES60_3_1, EAknsMajorSkin, 0x19c2}, - - /* SP_QsnFrSetOptCornerTl */ {KAknsIIDQsnFrSetOptCornerTl, ENoDraw, ES60_AllReleases, -1,-1}, - /* SP_QsnFrSetOptCornerTr */ {KAknsIIDQsnFrSetOptCornerTr, ENoDraw, ES60_AllReleases, -1,-1}, - /* SP_QsnFrSetOptCornerBl */ {KAknsIIDQsnFrSetOptCornerBl, ENoDraw, ES60_AllReleases, -1,-1}, - /* SP_QsnFrSetOptCornerBr */ {KAknsIIDQsnFrSetOptCornerBr, ENoDraw, ES60_AllReleases, -1,-1}, - /* SP_QsnFrSetOptSideT */ {KAknsIIDQsnFrSetOptSideT, ENoDraw, ES60_AllReleases, -1,-1}, - /* SP_QsnFrSetOptSideB */ {KAknsIIDQsnFrSetOptSideB, ENoDraw, ES60_AllReleases, -1,-1}, - /* SP_QsnFrSetOptSideL */ {KAknsIIDQsnFrSetOptSideL, ENoDraw, ES60_AllReleases, -1,-1}, - /* SP_QsnFrSetOptSideR */ {KAknsIIDQsnFrSetOptSideR, ENoDraw, ES60_AllReleases, -1,-1}, - /* SP_QsnFrSetOptCenter */ {KAknsIIDQsnFrSetOptCenter, ENoDraw, ES60_AllReleases, -1,-1}, + /* SP_QsnFrPopupPreviewCornerTl */ {KAknsIIDQsnFrPopupCornerTl, ENoDraw, ES60_3_1, EAknsMajorSkin, 0x19c5}, /* KAknsIIDQsnFrPopupPreviewCornerTl */ + /* SP_QsnFrPopupPreviewCornerTr */ {KAknsIIDQsnFrPopupCornerTr, ENoDraw, ES60_3_1, EAknsMajorSkin, 0x19c6}, + /* SP_QsnFrPopupPreviewCornerBl */ {KAknsIIDQsnFrPopupCornerBl, ENoDraw, ES60_3_1, EAknsMajorSkin, 0x19c3}, + /* SP_QsnFrPopupPreviewCornerBr */ {KAknsIIDQsnFrPopupCornerBr, ENoDraw, ES60_3_1, EAknsMajorSkin, 0x19c4}, + /* SP_QsnFrPopupPreviewSideT */ {KAknsIIDQsnFrPopupSideT, ENoDraw, ES60_3_1, EAknsMajorSkin, 0x19ca}, + /* SP_QsnFrPopupPreviewSideB */ {KAknsIIDQsnFrPopupSideB, ENoDraw, ES60_3_1, EAknsMajorSkin, 0x19c7}, + /* SP_QsnFrPopupPreviewSideL */ {KAknsIIDQsnFrPopupSideL, ENoDraw, ES60_3_1, EAknsMajorSkin, 0x19c8}, + /* SP_QsnFrPopupPreviewSideR */ {KAknsIIDQsnFrPopupSideR, ENoDraw, ES60_3_1, EAknsMajorSkin, 0x19c9}, + /* SP_QsnFrPopupPreviewCenter */ {KAknsIIDQsnFrPopupCenter, ENoDraw, ES60_3_1, EAknsMajorSkin, 0x19c2}, + + /* SP_QsnFrSetOptCornerTl */ {KAknsIIDQsnFrSetOptCornerTl, ENoDraw, ES60_All, -1,-1}, + /* SP_QsnFrSetOptCornerTr */ {KAknsIIDQsnFrSetOptCornerTr, ENoDraw, ES60_All, -1,-1}, + /* SP_QsnFrSetOptCornerBl */ {KAknsIIDQsnFrSetOptCornerBl, ENoDraw, ES60_All, -1,-1}, + /* SP_QsnFrSetOptCornerBr */ {KAknsIIDQsnFrSetOptCornerBr, ENoDraw, ES60_All, -1,-1}, + /* SP_QsnFrSetOptSideT */ {KAknsIIDQsnFrSetOptSideT, ENoDraw, ES60_All, -1,-1}, + /* SP_QsnFrSetOptSideB */ {KAknsIIDQsnFrSetOptSideB, ENoDraw, ES60_All, -1,-1}, + /* SP_QsnFrSetOptSideL */ {KAknsIIDQsnFrSetOptSideL, ENoDraw, ES60_All, -1,-1}, + /* SP_QsnFrSetOptSideR */ {KAknsIIDQsnFrSetOptSideR, ENoDraw, ES60_All, -1,-1}, + /* SP_QsnFrSetOptCenter */ {KAknsIIDQsnFrSetOptCenter, ENoDraw, ES60_All, -1,-1}, // No toolbar frame for 5.0+ releases. - /* SP_QsnFrPopupSubCornerTl */ {KAknsIIDQsnFrPopupSubCornerTl, ENoDraw, ES60_3_1 | ES60_3_2, -1,-1}, - /* SP_QsnFrPopupSubCornerTr */ {KAknsIIDQsnFrPopupSubCornerTr, ENoDraw, ES60_3_1 | ES60_3_2, -1,-1}, - /* SP_QsnFrPopupSubCornerBl */ {KAknsIIDQsnFrPopupSubCornerBl, ENoDraw, ES60_3_1 | ES60_3_2, -1,-1}, - /* SP_QsnFrPopupSubCornerBr */ {KAknsIIDQsnFrPopupSubCornerBr, ENoDraw, ES60_3_1 | ES60_3_2, -1,-1}, - /* SP_QsnFrPopupSubSideT */ {KAknsIIDQsnFrPopupSubSideT, ENoDraw, ES60_3_1 | ES60_3_2, -1,-1}, - /* SP_QsnFrPopupSubSideB */ {KAknsIIDQsnFrPopupSubSideB, ENoDraw, ES60_3_1 | ES60_3_2, -1,-1}, - /* SP_QsnFrPopupSubSideL */ {KAknsIIDQsnFrPopupSubSideL, ENoDraw, ES60_3_1 | ES60_3_2, -1,-1}, - /* SP_QsnFrPopupSubSideR */ {KAknsIIDQsnFrPopupSubSideR, ENoDraw, ES60_3_1 | ES60_3_2, -1,-1}, - /* SP_QsnFrPopupSubCenter */ {KAknsIIDQsnFrPopupCenterSubmenu, ENoDraw, ES60_3_1 | ES60_3_2, -1,-1}, + /* SP_QsnFrPopupSubCornerTl */ {KAknsIIDQsnFrPopupSubCornerTl, ENoDraw, ES60_3_X, -1,-1}, + /* SP_QsnFrPopupSubCornerTr */ {KAknsIIDQsnFrPopupSubCornerTr, ENoDraw, ES60_3_X, -1,-1}, + /* SP_QsnFrPopupSubCornerBl */ {KAknsIIDQsnFrPopupSubCornerBl, ENoDraw, ES60_3_X, -1,-1}, + /* SP_QsnFrPopupSubCornerBr */ {KAknsIIDQsnFrPopupSubCornerBr, ENoDraw, ES60_3_X, -1,-1}, + /* SP_QsnFrPopupSubSideT */ {KAknsIIDQsnFrPopupSubSideT, ENoDraw, ES60_3_X, -1,-1}, + /* SP_QsnFrPopupSubSideB */ {KAknsIIDQsnFrPopupSubSideB, ENoDraw, ES60_3_X, -1,-1}, + /* SP_QsnFrPopupSubSideL */ {KAknsIIDQsnFrPopupSubSideL, ENoDraw, ES60_3_X, -1,-1}, + /* SP_QsnFrPopupSubSideR */ {KAknsIIDQsnFrPopupSubSideR, ENoDraw, ES60_3_X, -1,-1}, + /* SP_QsnFrPopupSubCenter */ {KAknsIIDQsnFrPopupCenterSubmenu, ENoDraw, ES60_3_X, -1,-1}, // Toolbar graphics is different in 3.1/3.2 vs. 5.0 - /* SP_QsnFrSctrlButtonCornerTl */ {KAknsIIDQsnFrButtonTbCornerTl, ENoDraw, ES60_3_1 | ES60_3_2, EAknsMajorSkin, 0x2301}, /* KAknsIIDQgnFrSctrlButtonCornerTl*/ - /* SP_QsnFrSctrlButtonCornerTr */ {KAknsIIDQsnFrButtonTbCornerTr, ENoDraw, ES60_3_1 | ES60_3_2, EAknsMajorSkin, 0x2302}, - /* SP_QsnFrSctrlButtonCornerBl */ {KAknsIIDQsnFrButtonTbCornerBl, ENoDraw, ES60_3_1 | ES60_3_2, EAknsMajorSkin, 0x2303}, - /* SP_QsnFrSctrlButtonCornerBr */ {KAknsIIDQsnFrButtonTbCornerBr, ENoDraw, ES60_3_1 | ES60_3_2, EAknsMajorSkin, 0x2304}, - /* SP_QsnFrSctrlButtonSideT */ {KAknsIIDQsnFrButtonTbSideT, ENoDraw, ES60_3_1 | ES60_3_2, EAknsMajorSkin, 0x2305}, - /* SP_QsnFrSctrlButtonSideB */ {KAknsIIDQsnFrButtonTbSideB, ENoDraw, ES60_3_1 | ES60_3_2, EAknsMajorSkin, 0x2306}, - /* SP_QsnFrSctrlButtonSideL */ {KAknsIIDQsnFrButtonTbSideL, ENoDraw, ES60_3_1 | ES60_3_2, EAknsMajorSkin, 0x2307}, - /* SP_QsnFrSctrlButtonSideR */ {KAknsIIDQsnFrButtonTbSideR, ENoDraw, ES60_3_1 | ES60_3_2, EAknsMajorSkin, 0x2308}, - /* SP_QsnFrSctrlButtonCenter */ {KAknsIIDQsnFrButtonTbCenter, ENoDraw, ES60_3_1 | ES60_3_2, EAknsMajorSkin, 0x2309}, /*KAknsIIDQgnFrSctrlButtonCenter*/ + /* SP_QsnFrSctrlButtonCornerTl */ {KAknsIIDQsnFrButtonTbCornerTl, ENoDraw, ES60_3_X, EAknsMajorSkin, 0x2301}, /* KAknsIIDQgnFrSctrlButtonCornerTl*/ + /* SP_QsnFrSctrlButtonCornerTr */ {KAknsIIDQsnFrButtonTbCornerTr, ENoDraw, ES60_3_X, EAknsMajorSkin, 0x2302}, + /* SP_QsnFrSctrlButtonCornerBl */ {KAknsIIDQsnFrButtonTbCornerBl, ENoDraw, ES60_3_X, EAknsMajorSkin, 0x2303}, + /* SP_QsnFrSctrlButtonCornerBr */ {KAknsIIDQsnFrButtonTbCornerBr, ENoDraw, ES60_3_X, EAknsMajorSkin, 0x2304}, + /* SP_QsnFrSctrlButtonSideT */ {KAknsIIDQsnFrButtonTbSideT, ENoDraw, ES60_3_X, EAknsMajorSkin, 0x2305}, + /* SP_QsnFrSctrlButtonSideB */ {KAknsIIDQsnFrButtonTbSideB, ENoDraw, ES60_3_X, EAknsMajorSkin, 0x2306}, + /* SP_QsnFrSctrlButtonSideL */ {KAknsIIDQsnFrButtonTbSideL, ENoDraw, ES60_3_X, EAknsMajorSkin, 0x2307}, + /* SP_QsnFrSctrlButtonSideR */ {KAknsIIDQsnFrButtonTbSideR, ENoDraw, ES60_3_X, EAknsMajorSkin, 0x2308}, + /* SP_QsnFrSctrlButtonCenter */ {KAknsIIDQsnFrButtonTbCenter, ENoDraw, ES60_3_X, EAknsMajorSkin, 0x2309}, /*KAknsIIDQgnFrSctrlButtonCenter*/ // No pressed state for toolbar button in 3.1/3.2. - /* SP_QsnFrSctrlButtonCornerTlPressed */ {KAknsIIDQsnFrButtonTbCornerTl, ENoDraw, ES60_3_1 | ES60_3_2, EAknsMajorSkin, 0x2621}, /*KAknsIIDQsnFrSctrlButtonCornerTlPressed*/ - /* SP_QsnFrSctrlButtonCornerTrPressed */ {KAknsIIDQsnFrButtonTbCornerTr, ENoDraw, ES60_3_1 | ES60_3_2, EAknsMajorSkin, 0x2622}, - /* SP_QsnFrSctrlButtonCornerBlPressed */ {KAknsIIDQsnFrButtonTbCornerBl, ENoDraw, ES60_3_1 | ES60_3_2, EAknsMajorSkin, 0x2623}, - /* SP_QsnFrSctrlButtonCornerBrPressed */ {KAknsIIDQsnFrButtonTbCornerBr, ENoDraw, ES60_3_1 | ES60_3_2, EAknsMajorSkin, 0x2624}, - /* SP_QsnFrSctrlButtonSideTPressed */ {KAknsIIDQsnFrButtonTbSideT, ENoDraw, ES60_3_1 | ES60_3_2, EAknsMajorSkin, 0x2625}, - /* SP_QsnFrSctrlButtonSideBPressed */ {KAknsIIDQsnFrButtonTbSideB, ENoDraw, ES60_3_1 | ES60_3_2, EAknsMajorSkin, 0x2626}, - /* SP_QsnFrSctrlButtonSideLPressed */ {KAknsIIDQsnFrButtonTbSideL, ENoDraw, ES60_3_1 | ES60_3_2, EAknsMajorSkin, 0x2627}, - /* SP_QsnFrSctrlButtonSideRPressed */ {KAknsIIDQsnFrButtonTbSideR, ENoDraw, ES60_3_1 | ES60_3_2, EAknsMajorSkin, 0x2628}, - /* SP_QsnFrSctrlButtonCenterPressed */ {KAknsIIDQsnFrButtonTbCenter, ENoDraw, ES60_3_1 | ES60_3_2, EAknsMajorSkin, 0x2629}, + /* SP_QsnFrSctrlButtonCornerTlPressed */ {KAknsIIDQsnFrButtonTbCornerTl, ENoDraw, ES60_3_X, EAknsMajorSkin, 0x2621}, /*KAknsIIDQsnFrSctrlButtonCornerTlPressed*/ + /* SP_QsnFrSctrlButtonCornerTrPressed */ {KAknsIIDQsnFrButtonTbCornerTr, ENoDraw, ES60_3_X, EAknsMajorSkin, 0x2622}, + /* SP_QsnFrSctrlButtonCornerBlPressed */ {KAknsIIDQsnFrButtonTbCornerBl, ENoDraw, ES60_3_X, EAknsMajorSkin, 0x2623}, + /* SP_QsnFrSctrlButtonCornerBrPressed */ {KAknsIIDQsnFrButtonTbCornerBr, ENoDraw, ES60_3_X, EAknsMajorSkin, 0x2624}, + /* SP_QsnFrSctrlButtonSideTPressed */ {KAknsIIDQsnFrButtonTbSideT, ENoDraw, ES60_3_X, EAknsMajorSkin, 0x2625}, + /* SP_QsnFrSctrlButtonSideBPressed */ {KAknsIIDQsnFrButtonTbSideB, ENoDraw, ES60_3_X, EAknsMajorSkin, 0x2626}, + /* SP_QsnFrSctrlButtonSideLPressed */ {KAknsIIDQsnFrButtonTbSideL, ENoDraw, ES60_3_X, EAknsMajorSkin, 0x2627}, + /* SP_QsnFrSctrlButtonSideRPressed */ {KAknsIIDQsnFrButtonTbSideR, ENoDraw, ES60_3_X, EAknsMajorSkin, 0x2628}, + /* SP_QsnFrSctrlButtonCenterPressed */ {KAknsIIDQsnFrButtonTbCenter, ENoDraw, ES60_3_X, EAknsMajorSkin, 0x2629}, // No inactive button graphics in 3.1/3.2 - /* SP_QsnFrButtonCornerTlInactive */ {KAknsIIDQsnFrButtonTbCornerTl, ENoDraw, ES60_3_1 | ES60_3_2, EAknsMajorSkin, 0x21b1}, /*KAknsIIDQsnFrButtonCornerTlInactive*/ - /* SP_QsnFrButtonCornerTrInactive */ {KAknsIIDQsnFrButtonTbCornerTr, ENoDraw, ES60_3_1 | ES60_3_2, EAknsMajorSkin, 0x21b2}, - /* SP_QsnFrButtonCornerBlInactive */ {KAknsIIDQsnFrButtonTbCornerBl, ENoDraw, ES60_3_1 | ES60_3_2, EAknsMajorSkin, 0x21b3}, - /* SP_QsnFrButtonCornerTrInactive */ {KAknsIIDQsnFrButtonTbCornerBr, ENoDraw, ES60_3_1 | ES60_3_2, EAknsMajorSkin, 0x21b4}, - /* SP_QsnFrButtonSideTInactive */ {KAknsIIDQsnFrButtonTbSideT, ENoDraw, ES60_3_1 | ES60_3_2, EAknsMajorSkin, 0x21b5}, - /* SP_QsnFrButtonSideBInactive */ {KAknsIIDQsnFrButtonTbSideB, ENoDraw, ES60_3_1 | ES60_3_2, EAknsMajorSkin, 0x21b6}, - /* SP_QsnFrButtonSideLInactive */ {KAknsIIDQsnFrButtonTbSideL, ENoDraw, ES60_3_1 | ES60_3_2, EAknsMajorSkin, 0x21b7}, - /* SP_QsnFrButtonSideRInactive */ {KAknsIIDQsnFrButtonTbSideR, ENoDraw, ES60_3_1 | ES60_3_2, EAknsMajorSkin, 0x21b8}, - /* SP_QsnFrButtonCenterInactive */ {KAknsIIDQsnFrButtonTbCenter, EDrawIcon, ES60_3_1 | ES60_3_2, EAknsMajorSkin, 0x21b9}, + /* SP_QsnFrButtonCornerTlInactive */ {KAknsIIDQsnFrButtonTbCornerTl, ENoDraw, ES60_3_X, EAknsMajorSkin, 0x21b1}, /*KAknsIIDQsnFrButtonCornerTlInactive*/ + /* SP_QsnFrButtonCornerTrInactive */ {KAknsIIDQsnFrButtonTbCornerTr, ENoDraw, ES60_3_X, EAknsMajorSkin, 0x21b2}, + /* SP_QsnFrButtonCornerBlInactive */ {KAknsIIDQsnFrButtonTbCornerBl, ENoDraw, ES60_3_X, EAknsMajorSkin, 0x21b3}, + /* SP_QsnFrButtonCornerTrInactive */ {KAknsIIDQsnFrButtonTbCornerBr, ENoDraw, ES60_3_X, EAknsMajorSkin, 0x21b4}, + /* SP_QsnFrButtonSideTInactive */ {KAknsIIDQsnFrButtonTbSideT, ENoDraw, ES60_3_X, EAknsMajorSkin, 0x21b5}, + /* SP_QsnFrButtonSideBInactive */ {KAknsIIDQsnFrButtonTbSideB, ENoDraw, ES60_3_X, EAknsMajorSkin, 0x21b6}, + /* SP_QsnFrButtonSideLInactive */ {KAknsIIDQsnFrButtonTbSideL, ENoDraw, ES60_3_X, EAknsMajorSkin, 0x21b7}, + /* SP_QsnFrButtonSideRInactive */ {KAknsIIDQsnFrButtonTbSideR, ENoDraw, ES60_3_X, EAknsMajorSkin, 0x21b8}, + /* SP_QsnFrButtonCenterInactive */ {KAknsIIDQsnFrButtonTbCenter, EDrawIcon, ES60_3_X, EAknsMajorSkin, 0x21b9}, }; @@ -349,7 +351,7 @@ QPixmap QS60StyleModeSpecifics::skinnedGraphics( } QPixmap QS60StyleModeSpecifics::colorSkinnedGraphics( - const QS60StyleEnums::SkinParts &stylepart, const QSize &size, QPainter *painter, + const QS60StyleEnums::SkinParts &stylepart, const QSize &size, QPainter *painter, QS60StylePrivate::SkinElementFlags flags) { QPixmap colorGraphics; @@ -357,155 +359,118 @@ QPixmap QS60StyleModeSpecifics::colorSkinnedGraphics( return error ? QPixmap() : colorGraphics; } -void QS60StyleModeSpecifics::fallbackInfo(const QS60StyleEnums::SkinParts &stylepart, TDes& fallbackFileName, TInt& fallbackIndex) +void QS60StyleModeSpecifics::fallbackInfo(const QS60StyleEnums::SkinParts &stylePart, TInt &fallbackIndex) { - switch(stylepart) { + switch(stylePart) { case QS60StyleEnums::SP_QgnGrafBarWait: - fallbackFileName = KAvkonBitmapFile(); fallbackIndex = EMbmAvkonQgn_graf_bar_wait_1; break; case QS60StyleEnums::SP_QgnGrafBarFrameCenter: - fallbackFileName = KAvkonBitmapFile(); fallbackIndex = EMbmAvkonQgn_graf_bar_frame_center; break; case QS60StyleEnums::SP_QgnGrafBarFrameSideL: - fallbackFileName = KAvkonBitmapFile(); fallbackIndex = EMbmAvkonQgn_graf_bar_frame_side_l; break; case QS60StyleEnums::SP_QgnGrafBarFrameSideR: - fallbackFileName = KAvkonBitmapFile(); fallbackIndex = EMbmAvkonQgn_graf_bar_frame_side_r; break; case QS60StyleEnums::SP_QgnGrafBarProgress: - fallbackFileName = KAvkonBitmapFile(); fallbackIndex = EMbmAvkonQgn_graf_bar_progress; break; case QS60StyleEnums::SP_QgnGrafTabActiveL: - fallbackFileName = KAvkonBitmapFile(); fallbackIndex = EMbmAvkonQgn_graf_tab_active_l; break; case QS60StyleEnums::SP_QgnGrafTabActiveM: - fallbackFileName = KAvkonBitmapFile(); fallbackIndex = EMbmAvkonQgn_graf_tab_active_m; break; case QS60StyleEnums::SP_QgnGrafTabActiveR: - fallbackFileName = KAvkonBitmapFile(); fallbackIndex = EMbmAvkonQgn_graf_tab_active_r; break; case QS60StyleEnums::SP_QgnGrafTabPassiveL: - fallbackFileName = KAvkonBitmapFile(); fallbackIndex = EMbmAvkonQgn_graf_tab_passive_l; break; case QS60StyleEnums::SP_QgnGrafTabPassiveM: - fallbackFileName = KAvkonBitmapFile(); fallbackIndex = EMbmAvkonQgn_graf_tab_passive_m; break; case QS60StyleEnums::SP_QgnGrafTabPassiveR: - fallbackFileName = KAvkonBitmapFile(); fallbackIndex = EMbmAvkonQgn_graf_tab_passive_r; break; case QS60StyleEnums::SP_QgnIndiCheckboxOff: - fallbackFileName = KAvkonBitmapFile(); fallbackIndex = EMbmAvkonQgn_indi_checkbox_off; break; case QS60StyleEnums::SP_QgnIndiCheckboxOn: - fallbackFileName = KAvkonBitmapFile(); fallbackIndex = EMbmAvkonQgn_indi_checkbox_on; break; case QS60StyleEnums::SP_QgnIndiHlColSuper: - fallbackFileName = KAvkonBitmapFile(); fallbackIndex = 0x4456; /* EMbmAvkonQgn_indi_hl_col_super */ break; case QS60StyleEnums::SP_QgnIndiHlExpSuper: - fallbackFileName = KAvkonBitmapFile(); fallbackIndex = 0x4458; /* EMbmAvkonQgn_indi_hl_exp_super */ break; case QS60StyleEnums::SP_QgnIndiHlLineBranch: - fallbackFileName = KAvkonBitmapFile(); fallbackIndex = 0x445A; /* EMbmAvkonQgn_indi_hl_line_branch */ break; case QS60StyleEnums::SP_QgnIndiHlLineEnd: - fallbackFileName = KAvkonBitmapFile(); fallbackIndex = 0x445C; /* EMbmAvkonQgn_indi_hl_line_end */ break; case QS60StyleEnums::SP_QgnIndiHlLineStraight: - fallbackFileName = KAvkonBitmapFile(); fallbackIndex = 0x445E; /* EMbmAvkonQgn_indi_hl_line_straight */ break; case QS60StyleEnums::SP_QgnIndiMarkedAdd: - fallbackFileName = KAvkonBitmapFile(); fallbackIndex = EMbmAvkonQgn_indi_marked_add; break; case QS60StyleEnums::SP_QgnIndiNaviArrowLeft: - fallbackFileName = KAvkonBitmapFile(); fallbackIndex = EMbmAvkonQgn_indi_navi_arrow_left; break; case QS60StyleEnums::SP_QgnIndiNaviArrowRight: - fallbackFileName = KAvkonBitmapFile(); fallbackIndex = EMbmAvkonQgn_indi_navi_arrow_right; break; case QS60StyleEnums::SP_QgnIndiRadiobuttOff: - fallbackFileName = KAvkonBitmapFile(); fallbackIndex = EMbmAvkonQgn_indi_radiobutt_off; break; case QS60StyleEnums::SP_QgnIndiRadiobuttOn: - fallbackFileName = KAvkonBitmapFile(); fallbackIndex = EMbmAvkonQgn_indi_radiobutt_on; break; case QS60StyleEnums::SP_QgnIndiSliderEdit: - fallbackFileName = KAvkonBitmapFile(); fallbackIndex = EMbmAvkonQgn_indi_slider_edit; break; case QS60StyleEnums::SP_QgnIndiSubMenu: - fallbackFileName = KAvkonBitmapFile(); fallbackIndex = EMbmAvkonQgn_indi_submenu; break; case QS60StyleEnums::SP_QgnNoteErased: - fallbackFileName = KAvkonBitmapFile(); fallbackIndex = EMbmAvkonQgn_note_erased; break; case QS60StyleEnums::SP_QgnNoteError: - fallbackFileName = KAvkonBitmapFile(); fallbackIndex = EMbmAvkonQgn_note_error; break; case QS60StyleEnums::SP_QgnNoteInfo: - fallbackFileName = KAvkonBitmapFile(); fallbackIndex = EMbmAvkonQgn_note_info; break; case QS60StyleEnums::SP_QgnNoteOk: - fallbackFileName = KAvkonBitmapFile(); fallbackIndex = EMbmAvkonQgn_note_ok; break; case QS60StyleEnums::SP_QgnNoteQuery: - fallbackFileName = KAvkonBitmapFile(); fallbackIndex = EMbmAvkonQgn_note_query; break; case QS60StyleEnums::SP_QgnNoteWarning: - fallbackFileName = KAvkonBitmapFile(); fallbackIndex = EMbmAvkonQgn_note_warning; break; case QS60StyleEnums::SP_QgnPropFileSmall: - fallbackFileName = KAvkonBitmapFile(); fallbackIndex = EMbmAvkonQgn_prop_file_small; break; case QS60StyleEnums::SP_QgnPropFolderCurrent: - fallbackFileName = KAvkonBitmapFile(); fallbackIndex = EMbmAvkonQgn_prop_folder_current; break; case QS60StyleEnums::SP_QgnPropFolderSmall: - fallbackFileName = KAvkonBitmapFile(); fallbackIndex = EMbmAvkonQgn_prop_folder_small; break; case QS60StyleEnums::SP_QgnPropFolderSmallNew: - fallbackFileName = KAvkonBitmapFile(); fallbackIndex = EMbmAvkonQgn_prop_folder_small_new; break; case QS60StyleEnums::SP_QgnPropPhoneMemcLarge: - fallbackFileName = KAvkonBitmapFile(); fallbackIndex = EMbmAvkonQgn_prop_phone_memc_large; break; default: - fallbackFileName = KNullDesC(); fallbackIndex = -1; break; } @@ -521,8 +486,7 @@ QPixmap QS60StyleModeSpecifics::colorSkinnedGraphicsLX( TInt fallbackGraphicID = -1; HBufC* iconFile = HBufC::NewLC( KMaxFileName ); - TPtr fileNamePtr = iconFile->Des(); - fallbackInfo(stylepart, fileNamePtr, fallbackGraphicID); + fallbackInfo(stylepart, fallbackGraphicID); TAknsItemID colorGroup = KAknsIIDQsnIconColors; TRgb defaultColor = KRgbBlack; @@ -543,10 +507,18 @@ QPixmap QS60StyleModeSpecifics::colorSkinnedGraphicsLX( fallbackGraphicID == KErrNotFound?KErrNotFound:fallbackGraphicID+1; //masks are auto-generated as next in mif files MAknsSkinInstance* skinInstance = AknsUtils::SkinInstance(); AknsUtils::CreateColorIconLC( - skinInstance, skinId, colorGroup, colorIndex, icon, iconMask, fileNamePtr, fallbackGraphicID , fallbackGraphicsMaskID, defaultColor); - User::LeaveIfError(AknIconUtils::SetSize(icon, targetSize, EAspectRatioNotPreserved)); - User::LeaveIfError(AknIconUtils::SetSize(iconMask, targetSize, EAspectRatioNotPreserved)); - QPixmap result = fromFbsBitmap(icon, iconMask, flags, qt_TDisplayMode2Format(icon->DisplayMode())); + skinInstance, + skinId, + colorGroup, + colorIndex, + icon, + iconMask, + AknIconUtils::AvkonIconFileName(), + fallbackGraphicID, + fallbackGraphicsMaskID, + defaultColor); + + QPixmap result = fromFbsBitmap(icon, iconMask, flags, targetSize); CleanupStack::PopAndDestroy(3); //icon, iconMask, iconFile return result; } @@ -566,55 +538,43 @@ struct QAutoFbsBitmapHeapLock CFbsBitmap* mBmp; }; -QPixmap QS60StyleModeSpecifics::fromFbsBitmap(CFbsBitmap *icon, CFbsBitmap *mask, QS60StylePrivate::SkinElementFlags flags, QImage::Format format) +QPixmap QS60StyleModeSpecifics::fromFbsBitmap(CFbsBitmap *icon, CFbsBitmap *mask, QS60StylePrivate::SkinElementFlags flags, const TSize &targetSize) { Q_ASSERT(icon); - const TSize iconSize = icon->SizeInPixels(); - const int iconBytesPerLine = CFbsBitmap::ScanLineLength(iconSize.iWidth, icon->DisplayMode()); - const int iconBytesCount = iconBytesPerLine * iconSize.iHeight; - QImage iconImage(qt_TSize2QSize(iconSize), format); - if (iconImage.isNull()) - return QPixmap(); + AknIconUtils::DisableCompression(icon); + TInt error = AknIconUtils::SetSize(icon, targetSize, EAspectRatioNotPreserved); - checkAndUnCompressBitmap(icon); - if (!icon) //checkAndUnCompressBitmap might set icon to NULL + if (mask && !error) { + AknIconUtils::DisableCompression(mask); + error = AknIconUtils::SetSize(mask, targetSize, EAspectRatioNotPreserved); + } + if (error) return QPixmap(); - icon->LockHeap(); - const uchar *const iconBytes = (uchar*)icon->DataAddress(); - // The icon data needs to be copied, since the color format will be - // automatically converted to Format_ARGB32 when setAlphaChannel is called. - memcpy(iconImage.bits(), iconBytes, iconBytesCount); - icon->UnlockHeap(); - if (mask) { - checkAndUnCompressBitmap(mask); - if (mask) { //checkAndUnCompressBitmap might set mask to NULL - const TSize maskSize = icon->SizeInPixels(); - const int maskBytesPerLine = CFbsBitmap::ScanLineLength(maskSize.iWidth, mask->DisplayMode()); - // heap lock object required because QImage ctor might throw - QAutoFbsBitmapHeapLock maskHeapLock(mask); - const uchar *const maskBytes = (uchar *)mask->DataAddress(); - // Since no other bitmap should be locked, we can just "borrow" the mask data for setAlphaChannel - const QImage maskImage(maskBytes, maskSize.iWidth, maskSize.iHeight, maskBytesPerLine, QImage::Format_Indexed8); - if (!maskImage.isNull()) - iconImage.setAlphaChannel(maskImage); + QPixmap pixmap = QPixmap::fromSymbianCFbsBitmap(icon); + if (mask) + pixmap.setAlphaChannel(QPixmap::fromSymbianCFbsBitmap(mask)); + + if ((flags & QS60StylePrivate::SF_PointEast) || + (flags & QS60StylePrivate::SF_PointSouth) || + (flags & QS60StylePrivate::SF_PointWest)) { + QImage iconImage = pixmap.toImage(); + QTransform imageTransform; + if (flags & QS60StylePrivate::SF_PointEast) { + imageTransform.rotate(90); + } else if (flags & QS60StylePrivate::SF_PointSouth) { + imageTransform.rotate(180); + iconImage = iconImage.transformed(imageTransform); + } else if (flags & QS60StylePrivate::SF_PointWest) { + imageTransform.rotate(270); } - } + if (imageTransform.isRotating()) + iconImage = iconImage.transformed(imageTransform); - QTransform imageTransform; - if (flags & QS60StylePrivate::SF_PointEast) { - imageTransform.rotate(90); - } else if (flags & QS60StylePrivate::SF_PointSouth) { - imageTransform.rotate(180); - iconImage = iconImage.transformed(imageTransform); - } else if (flags & QS60StylePrivate::SF_PointWest) { - imageTransform.rotate(270); + pixmap = QPixmap::fromImage(iconImage); } - if (imageTransform.isRotating()) - iconImage = iconImage.transformed(imageTransform); - - return QPixmap::fromImage(iconImage); + return pixmap; } bool QS60StylePrivate::isTouchSupported() @@ -645,7 +605,7 @@ QPoint qt_s60_fill_background_offset(const QWidget *targetWidget) } QPixmap QS60StyleModeSpecifics::createSkinnedGraphicsLX( - QS60StyleEnums::SkinParts part, const QSize &size, + QS60StyleEnums::SkinParts part, const QSize &size, QS60StylePrivate::SkinElementFlags flags) { // this function can throw both exceptions and leaves. There are no cleanup dependencies between Qt and Symbian parts. @@ -653,7 +613,7 @@ QPixmap QS60StyleModeSpecifics::createSkinnedGraphicsLX( return QPixmap(); // Check release support and change part, if necessary. - const TAknsItemID skinId = checkAndUpdateReleaseSpecificGraphics((int)part); + const TAknsItemID skinId = partSpecificThemeId((int)part); const int stylepartIndex = (int)part; const TDrawType drawType = m_partMap[stylepartIndex].drawType; Q_ASSERT(drawType != ENoDraw); @@ -667,24 +627,34 @@ QPixmap QS60StyleModeSpecifics::createSkinnedGraphicsLX( QPixmap result; switch (drawType) { + case EDrawGulIcon: { + CGulIcon* icon = AknsUtils::CreateGulIconL( AknsUtils::SkinInstance(), skinId, EFalse ); + if (icon) + result = fromFbsBitmap(icon->Bitmap(), icon->Mask(), flags, targetSize); + delete icon; + break; + } case EDrawIcon: { TInt fallbackGraphicID = -1; - HBufC* iconFile = HBufC::NewLC( KMaxFileName ); - TPtr fileNamePtr = iconFile->Des(); - fallbackInfo(part, fileNamePtr, fallbackGraphicID); - // todo: could we instead use AknIconUtils::AvkonIconFileName(); to avoid allocating each time? + fallbackInfo(part, fallbackGraphicID); CFbsBitmap *icon = 0; CFbsBitmap *iconMask = 0; const TInt fallbackGraphicsMaskID = fallbackGraphicID == KErrNotFound?KErrNotFound:fallbackGraphicID+1; //masks are auto-generated as next in mif files - // QS60WindowSurface::unlockBitmapHeap(); - AknsUtils::CreateIconLC(skinInstance, skinId, icon, iconMask, fileNamePtr, fallbackGraphicID , fallbackGraphicsMaskID); - User::LeaveIfError(AknIconUtils::SetSize(icon, targetSize, EAspectRatioNotPreserved)); - User::LeaveIfError(AknIconUtils::SetSize(iconMask, targetSize, EAspectRatioNotPreserved)); - result = fromFbsBitmap(icon, iconMask, flags, qt_TDisplayMode2Format(icon->DisplayMode())); - CleanupStack::PopAndDestroy(3); // iconMask, icon, iconFile - // QS60WindowSurface::lockBitmapHeap(); + + AknsUtils::CreateIconL( + skinInstance, + skinId, + icon, + iconMask, + AknIconUtils::AvkonIconFileName(), + fallbackGraphicID , + fallbackGraphicsMaskID); + + result = fromFbsBitmap(icon, iconMask, flags, targetSize); + delete icon; + delete iconMask; break; } case EDrawBackground: { @@ -715,13 +685,16 @@ QPixmap QS60StyleModeSpecifics::createSkinnedGraphicsLX( KAknsDrawParamDefault | KAknsDrawParamRGBOnly); if (drawn) - result = fromFbsBitmap(background, NULL, flags, QImage::Format_RGB32); + result = fromFbsBitmap(background, NULL, flags, targetSize); + // if drawing fails in skin server, just ignore the background (probably OOM occured) CleanupStack::PopAndDestroy(4, background); //background, dev, gc, bgContext // QS60WindowSurface::lockBitmapHeap(); break; } } + if (!result) + result = QPixmap(); return result; } @@ -755,24 +728,46 @@ QPixmap QS60StyleModeSpecifics::createSkinnedGraphicsLX(QS60StylePrivate::SkinFr User::LeaveIfError(bitmapDev->CreateContext(bitmapGc)); CleanupStack::PushL(bitmapGc); +#ifndef Q_SYMBIAN_HAS_EXTENDED_BITMAP_TYPE frame->LockHeap(); memset(frame->DataAddress(), 0, frame->SizeInPixels().iWidth * frame->SizeInPixels().iHeight * 4); // 4: argb bytes frame->UnlockHeap(); +#endif const TRect outerRect(TPoint(0, 0), targetSize); const TRect innerRect = innerRectFromElement(frameElement, outerRect); TAknsItemID frameSkinID, centerSkinID; - frameSkinID = centerSkinID = checkAndUpdateReleaseSpecificGraphics(QS60StylePrivate::m_frameElementsData[frameElement].center); + frameSkinID = centerSkinID = partSpecificThemeId(QS60StylePrivate::m_frameElementsData[frameElement].center); frameIdAndCenterId(frameElement, frameSkinID, centerSkinID); - const TBool drawn = AknsDrawUtils::DrawFrame( skinInstance, - *bitmapGc, outerRect, innerRect, - frameSkinID, centerSkinID, - drawParam ); + + TBool drawn = AknsDrawUtils::DrawFrame( + skinInstance, + *bitmapGc, + outerRect, + innerRect, + frameSkinID, + centerSkinID, + drawParam ); if (S60->supportsPremultipliedAlpha) { - if (drawn) - result = fromFbsBitmap(frame, NULL, flags, QImage::Format_ARGB32_Premultiplied); + if (drawn) { + result = fromFbsBitmap(frame, NULL, flags, targetSize); + } else { + // Drawing might fail due to OOM (we can do nothing about that), + // or due to skin item not being available. + // If the latter occurs, lets try switch to non-release specific items (if available) + // and re-try the drawing. + frameSkinID = centerSkinID = m_partMap[(int)QS60StylePrivate::m_frameElementsData[frameElement].center].skinID; + frameIdAndCenterId(frameElement, frameSkinID, centerSkinID); + drawn = AknsDrawUtils::DrawFrame( skinInstance, + *bitmapGc, outerRect, innerRect, + frameSkinID, centerSkinID, + drawParam ); + // in case drawing fails, even after using default graphics, ignore the error + if (drawn) + result = fromFbsBitmap(frame, NULL, flags, targetSize); + } } else { TDisplayMode maskDepth = EGray2; // Query the skin item for possible frame graphics mask details. @@ -802,11 +797,12 @@ QPixmap QS60StyleModeSpecifics::createSkinnedGraphicsLX(QS60StylePrivate::SkinFr maskBitGc->Clear(); maskBitGc->SetBrushStyle(CGraphicsContext::ENullBrush); - AknsDrawUtils::DrawFrame(skinInstance, + drawn = AknsDrawUtils::DrawFrame(skinInstance, *maskBitGc, outerRect, innerRect, frameSkinID, centerSkinID, KAknsSDMAlphaOnly |KAknsDrawParamNoClearUnderImage); - result = fromFbsBitmap(frame, frameMask, flags, QImage::Format_ARGB32); + if (drawn) + result = fromFbsBitmap(frame, frameMask, flags, targetSize); } CleanupStack::PopAndDestroy(3, frameMask); } @@ -880,10 +876,12 @@ bool QS60StyleModeSpecifics::checkSupport(const int supportedRelease) const QSysInfo::S60Version currentRelease = QSysInfo::s60Version(); return ( (currentRelease == QSysInfo::SV_S60_3_1 && supportedRelease & ES60_3_1) || (currentRelease == QSysInfo::SV_S60_3_2 && supportedRelease & ES60_3_2) || - (currentRelease == QSysInfo::SV_S60_5_0 && supportedRelease & ES60_5_0)); + (currentRelease == QSysInfo::SV_S60_5_0 && supportedRelease & ES60_5_0) || + (currentRelease == QSysInfo::SV_S60_5_1 && supportedRelease & ES60_5_1) || + (currentRelease == QSysInfo::SV_S60_5_2 && supportedRelease & ES60_5_2)); } -TAknsItemID QS60StyleModeSpecifics::checkAndUpdateReleaseSpecificGraphics(int part) +TAknsItemID QS60StyleModeSpecifics::partSpecificThemeId(int part) { TAknsItemID newSkinId; if (!checkSupport(m_partMap[(int)part].supportInfo)) @@ -893,33 +891,6 @@ TAknsItemID QS60StyleModeSpecifics::checkAndUpdateReleaseSpecificGraphics(int pa return newSkinId; } -void QS60StyleModeSpecifics::checkAndUnCompressBitmap(CFbsBitmap*& aOriginalBitmap) -{ - TRAPD(error, checkAndUnCompressBitmapL(aOriginalBitmap)); - if (error) - aOriginalBitmap = NULL; -} - -void QS60StyleModeSpecifics::checkAndUnCompressBitmapL(CFbsBitmap*& aOriginalBitmap) -{ - const TSize iconSize = aOriginalBitmap->SizeInPixels(); - const int iconBytesPerLine = CFbsBitmap::ScanLineLength(iconSize.iWidth, aOriginalBitmap->DisplayMode()); - const int iconBytesCount = iconBytesPerLine * iconSize.iHeight; - if (aOriginalBitmap->IsCompressedInRAM() || aOriginalBitmap->Header().iBitmapSize < iconBytesCount) { - const TSize iconSize(aOriginalBitmap->SizeInPixels().iWidth, - aOriginalBitmap->SizeInPixels().iHeight); - CFbsBitmap* uncompressedBitmap = new (ELeave) CFbsBitmap(); - CleanupStack::PushL(uncompressedBitmap); - User::LeaveIfError(uncompressedBitmap->Create(iconSize, - aOriginalBitmap->DisplayMode())); - unCompressBitmapL(iconSize, uncompressedBitmap, aOriginalBitmap); - CleanupStack::Pop(uncompressedBitmap); - User::LeaveIfError(aOriginalBitmap->Duplicate( - uncompressedBitmap->Handle())); - delete uncompressedBitmap; - } -} - QFont QS60StylePrivate::s60Font_specific( QS60StyleEnums::FontCategories fontCategory, int pointSize) { @@ -1167,148 +1138,6 @@ QPixmap QS60StylePrivate::backgroundTexture() return *m_background; } -// If the public SDK returns compressed images, please let us also uncompress those! -void QS60StyleModeSpecifics::unCompressBitmapL(const TRect& aTrgRect, CFbsBitmap* aTrgBitmap, CFbsBitmap* aSrcBitmap) -{ - if (!aSrcBitmap) - User::Leave(KErrArgument); - if (!aTrgBitmap) - User::Leave(KErrArgument); - - // Note! aSrcBitmap->IsCompressedInRAM() is always ETrue, since this method is called only if that applies! - // Extra note! this function is also being used when bitmaps appear to be compressed (because DataSize is too small) - // even when they pretend they are not. Assert removed. -// ASSERT(aSrcBitmap->IsCompressedInRAM()); - - TDisplayMode displayMode = aSrcBitmap->DisplayMode(); - - if (displayMode != aTrgBitmap->DisplayMode()) - User::Leave(KErrArgument); - - const TSize trgSize = aTrgBitmap->SizeInPixels(); - const TSize srcSize = aSrcBitmap->SizeInPixels(); - - // calculate the valid drawing area - TRect drawRect = aTrgRect; - drawRect.Intersection(TRect(TPoint(0, 0), trgSize)); - - if (drawRect.IsEmpty()) - return; - - CFbsBitmap* realSource = new (ELeave) CFbsBitmap(); - CleanupStack::PushL(realSource); - User::LeaveIfError(realSource->Create(srcSize, displayMode)); - CFbsBitmapDevice* dev = CFbsBitmapDevice::NewL(realSource); - CleanupStack::PushL(dev); - CFbsBitGc* gc = NULL; - User::LeaveIfError(dev->CreateContext(gc)); - CleanupStack::PushL(gc); - gc->BitBlt(TPoint(0, 0), aSrcBitmap); - CleanupStack::PopAndDestroy(2); // dev, gc - - // Heap lock for FBServ large chunk is only needed with large bitmaps. - if (realSource->IsLargeBitmap() || aTrgBitmap->IsLargeBitmap()) { - aTrgBitmap->LockHeapLC(ETrue); // fbsheaplock - } else { - CleanupStack::PushL((TAny*) NULL); - } - - TUint32* srcAddress = realSource->DataAddress(); - TUint32* trgAddress = aTrgBitmap->DataAddress(); - - const TInt xSkip = (srcSize.iWidth << 8) / aTrgRect.Width(); - const TInt ySkip = (srcSize.iHeight << 8) / aTrgRect.Height(); - - const TInt drawWidth = drawRect.Width(); - const TInt drawHeight = drawRect.Height(); - - const TRect offsetRect(aTrgRect.iTl, drawRect.iTl); - const TInt yPosOffset = ySkip * offsetRect.Height(); - const TInt xPosOffset = xSkip * offsetRect.Width(); - - if ((displayMode == EGray256) || (displayMode == EColor256)) { - const TInt srcScanLen8 = CFbsBitmap::ScanLineLength(srcSize.iWidth, - displayMode); - const TInt trgScanLen8 = CFbsBitmap::ScanLineLength(trgSize.iWidth, - displayMode); - - TUint8* trgAddress8 = reinterpret_cast (trgAddress); - - TInt yPos = yPosOffset; - // skip left and top margins in the beginning - trgAddress8 += trgScanLen8 * drawRect.iTl.iY + drawRect.iTl.iX; - - for (TInt y = 0; y < drawHeight; y++) { - const TUint8* srcAddress8 = reinterpret_cast (srcAddress) - + (srcScanLen8 * (yPos >> 8)); - - TInt xPos = xPosOffset; - for (TInt x = 0; x < drawWidth; x++) { - *(trgAddress8++) = srcAddress8[xPos >> 8]; - xPos += xSkip; - } - - yPos += ySkip; - - trgAddress8 += trgScanLen8 - drawWidth; - } - } else if (displayMode == EColor4K || displayMode == EColor64K) { - const TInt srcScanLen16 = CFbsBitmap::ScanLineLength(srcSize.iWidth, - displayMode) >>1; - const TInt trgScanLen16 = CFbsBitmap::ScanLineLength(trgSize.iWidth, - displayMode) >>1; - - TUint16* trgAddress16 = reinterpret_cast (trgAddress); - - TInt yPos = yPosOffset; - // skip left and top margins in the beginning - trgAddress16 += trgScanLen16 * drawRect.iTl.iY + drawRect.iTl.iX; - - for (TInt y = 0; y < drawHeight; y++) { - const TUint16* srcAddress16 = reinterpret_cast (srcAddress) - + (srcScanLen16 * (yPos >> 8)); - - TInt xPos = xPosOffset; - for (TInt x = 0; x < drawWidth; x++) { - *(trgAddress16++) = srcAddress16[xPos >> 8]; - xPos += xSkip; - } - - yPos += ySkip; - - trgAddress16 += trgScanLen16 - drawWidth; - } - } else if (displayMode == EColor16MU || displayMode == EColor16MA) { - const TInt srcScanLen32 = CFbsBitmap::ScanLineLength(srcSize.iWidth, - displayMode) >>2; - const TInt trgScanLen32 = CFbsBitmap::ScanLineLength(trgSize.iWidth, - displayMode) >>2; - - TUint32* trgAddress32 = reinterpret_cast (trgAddress); - - TInt yPos = yPosOffset; - // skip left and top margins in the beginning - trgAddress32 += trgScanLen32 * drawRect.iTl.iY + drawRect.iTl.iX; - - for (TInt y = 0; y < drawHeight; y++) { - const TUint32* srcAddress32 = reinterpret_cast (srcAddress) - + (srcScanLen32 * (yPos >> 8)); - - TInt xPos = xPosOffset; - for (TInt x = 0; x < drawWidth; x++) { - *(trgAddress32++) = srcAddress32[xPos >> 8]; - xPos += xSkip; - } - - yPos += ySkip; - - trgAddress32 += trgScanLen32 - drawWidth; - } - } else { User::Leave(KErrUnknown);} - - CleanupStack::PopAndDestroy(2); // fbsheaplock, realSource -} - QSize QS60StylePrivate::screenSize() { const TSize screenSize = QS60Data::screenDevice()->SizeInPixels(); diff --git a/src/gui/styles/styles.pri b/src/gui/styles/styles.pri index 88a2cce..7e5c55a 100644 --- a/src/gui/styles/styles.pri +++ b/src/gui/styles/styles.pri @@ -168,7 +168,7 @@ contains( styles, s60 ):contains(QT_CONFIG, s60) { SOURCES += styles/qs60style.cpp symbian { SOURCES += styles/qs60style_s60.cpp - LIBS += -laknicon -laknskins -laknskinsrv -lfontutils + LIBS += -laknicon -laknskins -laknskinsrv -lfontutils -legul } else { SOURCES += styles/qs60style_simulated.cpp RESOURCES += styles/qstyle_s60_simulated.qrc -- cgit v0.12 From 971acc6d34559a2c5035888a5891ea29ad8628af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Morten=20Johan=20S=C3=B8rvig?= Date: Tue, 8 Dec 2009 14:30:38 +0100 Subject: Compile with -no-exceptions on Mac. qfontdialog_mac.mm needs to handle exceptions thrown by Cocoa, even if Qt is configured with if -no-exceptions. This ads a bit of qmake logic for the benefit of a single file, but I would like to keep -no-exceptions working. The savings are significant (around 10-15%). Revby: Richard Moe Gustavsen --- configure | 2 +- src/gui/dialogs/dialogs.pri | 18 ++++++++++++++++-- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/configure b/configure index 6dc3898..486dc0c 100755 --- a/configure +++ b/configure @@ -131,7 +131,7 @@ compilerSupportsFlag() cat >conftest.cpp < Date: Tue, 8 Dec 2009 15:07:02 +0100 Subject: Fix possible off-by-one inconsistency against system look and feel when drawing vertically aligned text When text is drawn in a font which has an odd-numbered height and it's vertically aligned in a rectangle which has an even-numbered height (or vice versa) we have to round the y-position, as the backend cannot position the text in subpixels. The y-position in this case will be at half a pixel and we can either round it up or down without increasing the size of the error. In Qt 4.5, the font height would be reported as one higher than what it actually was. Therefore, in many widgets such as comboboxes, we would appear to round the y-position down when faced with this issue. This is apparently also what Windows does, probably because most latin fonts have more glyphs extending into the maximum descent than the ascent. In Qt 4.6, the font height bug was fixed, and since we use qRound() we now round half-pixels up, thus moving all the text faced with this issue one pixel down. This looks odd and inconsistent, both with the platform look and feel and with older versions of Qt. The patch reverts to the old look and feel by rounding the half pixels down rather than up for the particular case in question. Task-number: QTBUG-6578 Reviewed-by: Samuel --- src/gui/painting/qpainter.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/painting/qpainter.cpp b/src/gui/painting/qpainter.cpp index 30f8c9e..66bf4f7 100644 --- a/src/gui/painting/qpainter.cpp +++ b/src/gui/painting/qpainter.cpp @@ -7630,7 +7630,7 @@ start_lengthVariant: // in the paint engines when drawing on floating point offsets const qreal scale = painter->transform().m22(); if (scale != 0) - yoff = qRound(yoff * scale) / scale; + yoff = -qRound(-yoff * scale) / scale; } } } -- cgit v0.12 From 9ddbc21e76564d2d8cba5a7ea831971c4e628130 Mon Sep 17 00:00:00 2001 From: Shane Kearns Date: Tue, 8 Dec 2009 14:10:34 +0000 Subject: Implement qsrand() for Symbian OS After checking the source code of OpenC stdlib, rand and srand are thread safe (they use Symbian's TLS internally) so the Symbian implementation mostly follows the Windows one (where this is also true) Task-number: QTBUG-6372 Reviewed-by: Janne Koskinen --- src/corelib/global/qglobal.cpp | 31 ++++++++++++++++++------------- 1 file changed, 18 insertions(+), 13 deletions(-) diff --git a/src/corelib/global/qglobal.cpp b/src/corelib/global/qglobal.cpp index 62b5409..0c94482 100644 --- a/src/corelib/global/qglobal.cpp +++ b/src/corelib/global/qglobal.cpp @@ -77,6 +77,7 @@ #include #include #include +#include # include "private/qcore_symbian_p.h" _LIT(qt_S60Filter, "Series60v?.*.sis"); @@ -2493,7 +2494,7 @@ bool qputenv(const char *varName, const QByteArray& value) #endif } -#if (defined(Q_OS_UNIX) || defined(Q_OS_WIN)) && !defined(QT_NO_THREAD) && !defined(Q_OS_SYMBIAN) +#if (defined(Q_OS_UNIX) || defined(Q_OS_WIN)) && !defined(QT_NO_THREAD) # if defined(Q_OS_INTEGRITY) && defined(__GHS_VERSION_NUMBER) && (__GHS_VERSION_NUMBER < 500) // older versions of INTEGRITY used a long instead of a uint for the seed. @@ -2516,8 +2517,6 @@ Q_GLOBAL_STATIC(SeedStorage, randTLS) // Thread Local Storage for seed value Sets the argument \a seed to be used to generate a new random number sequence of pseudo random integers to be returned by qrand(). - If no seed value is provided, qrand() is automatically seeded with a value of 1. - The sequence of random numbers generated is deterministic per thread. For example, if two threads call qsrand(1) and subsequently calls qrand(), the threads will get the same random number sequence. @@ -2541,8 +2540,9 @@ void qsrand(uint seed) srand(seed); } #else - // On Windows srand() and rand() already use Thread-Local-Storage + // On Windows and Symbian srand() and rand() already use Thread-Local-Storage // to store the seed between calls + // this is also valid for QT_NO_THREAD srand(seed); #endif } @@ -2558,7 +2558,7 @@ void qsrand(uint seed) */ void qsrand() { -#if (defined(Q_OS_UNIX) || defined(Q_OS_WIN)) && !defined(QT_NO_THREAD) && !defined(Q_OS_SYMBIAN) +#if (defined(Q_OS_UNIX) || defined(Q_OS_WIN)) && !defined(QT_NO_THREAD) SeedStorage *seedStorage = randTLS(); if (seedStorage) { SeedStorageType *pseed = seedStorage->localData(); @@ -2572,24 +2572,28 @@ void qsrand() *pseed = QDateTime::currentDateTime().toTime_t() + quintptr(&pseed) + serial.fetchAndAddRelaxed(1); -#if defined(Q_OS_WIN) - // for Windows the srand function must still be called. +#if defined(Q_OS_WIN) || defined(Q_OS_SYMBIAN) + // for Windows and Symbian the srand function must still be called. srand(*pseed); #endif } -#elif defined(Q_OS_WIN) +//QT_NO_THREAD implementations +#else static unsigned int seed = 0; if (seed) return; +#if defined(Q_OS_SYMBIAN) + seed = Math::Random(); +#elif defined(Q_OS_WIN) seed = GetTickCount(); - srand(seed); #else - // Symbian? - -#endif // defined(Q_OS_UNIX) || defined(Q_OS_WIN)) && !defined(QT_NO_THREAD) && !defined(Q_OS_SYMBIAN) + seed = quintptr(&seed) + QDateTime::currentDateTime().toTime_t(); +#endif + srand(seed); +#endif // defined(Q_OS_UNIX) || defined(Q_OS_WIN)) && !defined(QT_NO_THREAD) } /*! @@ -2626,8 +2630,9 @@ int qrand() return rand(); } #else - // On Windows srand() and rand() already use Thread-Local-Storage + // On Windows and Symbian srand() and rand() already use Thread-Local-Storage // to store the seed between calls + // this is also valid for QT_NO_THREAD return rand(); #endif } -- cgit v0.12 From 23334d3272834408adeaab604727284846ecdab9 Mon Sep 17 00:00:00 2001 From: Shane Kearns Date: Tue, 8 Dec 2009 15:21:08 +0100 Subject: Def file updates Reviewed-by: TrustMe --- src/s60installs/bwins/QtGuiu.def | 25 +++++++++++++++---------- src/s60installs/eabi/QtGuiu.def | 18 +++++++++++------- 2 files changed, 26 insertions(+), 17 deletions(-) diff --git a/src/s60installs/bwins/QtGuiu.def b/src/s60installs/bwins/QtGuiu.def index 166b6fe..d50e85f 100644 --- a/src/s60installs/bwins/QtGuiu.def +++ b/src/s60installs/bwins/QtGuiu.def @@ -271,7 +271,7 @@ EXPORTS ??0QImageIOHandler@@IAE@AAVQImageIOHandlerPrivate@@@Z @ 270 NONAME ; QImageIOHandler::QImageIOHandler(class QImageIOHandlerPrivate &) ??0QImageIOHandler@@QAE@XZ @ 271 NONAME ; QImageIOHandler::QImageIOHandler(void) ??0QImageIOPlugin@@QAE@PAVQObject@@@Z @ 272 NONAME ; QImageIOPlugin::QImageIOPlugin(class QObject *) - ??0QImagePixmapCleanupHooks@@QAE@XZ @ 273 NONAME ; QImagePixmapCleanupHooks::QImagePixmapCleanupHooks(void) + ??0QImagePixmapCleanupHooks@@QAE@XZ @ 273 NONAME ABSENT ; QImagePixmapCleanupHooks::QImagePixmapCleanupHooks(void) ??0QImageReader@@QAE@ABVQString@@ABVQByteArray@@@Z @ 274 NONAME ; QImageReader::QImageReader(class QString const &, class QByteArray const &) ??0QImageReader@@QAE@PAVQIODevice@@ABVQByteArray@@@Z @ 275 NONAME ; QImageReader::QImageReader(class QIODevice *, class QByteArray const &) ??0QImageReader@@QAE@XZ @ 276 NONAME ; QImageReader::QImageReader(void) @@ -2021,7 +2021,7 @@ EXPORTS ?addButton@QMessageBox@@QAEPAVQPushButton@@ABVQString@@W4ButtonRole@1@@Z @ 2020 NONAME ; class QPushButton * QMessageBox::addButton(class QString const &, enum QMessageBox::ButtonRole) ?addButton@QMessageBox@@QAEPAVQPushButton@@W4StandardButton@1@@Z @ 2021 NONAME ; class QPushButton * QMessageBox::addButton(enum QMessageBox::StandardButton) ?addButton@QMessageBox@@QAEXPAVQAbstractButton@@W4ButtonRole@1@@Z @ 2022 NONAME ; void QMessageBox::addButton(class QAbstractButton *, enum QMessageBox::ButtonRole) - ?addCacheData@QVectorPath@@QAEPAUCacheEntry@1@PAVQPaintEngineEx@@PAXP6AX1@Z@Z @ 2023 NONAME ; struct QVectorPath::CacheEntry * QVectorPath::addCacheData(class QPaintEngineEx *, void *, void (*)(void *)) + ?addCacheData@QVectorPath@@QAEPAUCacheEntry@1@PAVQPaintEngineEx@@PAXP6AX1@Z@Z @ 2023 NONAME ABSENT ; struct QVectorPath::CacheEntry * QVectorPath::addCacheData(class QPaintEngineEx *, void *, void (*)(void *)) ?addChild@QGraphicsItemPrivate@@QAEXPAVQGraphicsItem@@@Z @ 2024 NONAME ; void QGraphicsItemPrivate::addChild(class QGraphicsItem *) ?addChild@QTreeWidgetItem@@QAEXPAV1@@Z @ 2025 NONAME ; void QTreeWidgetItem::addChild(class QTreeWidgetItem *) ?addChildLayout@QLayout@@IAEXPAV1@@Z @ 2026 NONAME ; void QLayout::addChildLayout(class QLayout *) @@ -3724,7 +3724,7 @@ EXPORTS ?directory@QFileDialog@@QBE?AVQDir@@XZ @ 3723 NONAME ; class QDir QFileDialog::directory(void) const ?directoryEntered@QFileDialog@@IAEXABVQString@@@Z @ 3724 NONAME ; void QFileDialog::directoryEntered(class QString const &) ?dirtyRegionOffset@QAbstractItemView@@IBE?AVQPoint@@XZ @ 3725 NONAME ; class QPoint QAbstractItemView::dirtyRegionOffset(void) const - ?discardUpdateRequest@QGraphicsItemPrivate@@QBE_N_N000@Z @ 3726 NONAME ; bool QGraphicsItemPrivate::discardUpdateRequest(bool, bool, bool, bool) const + ?discardUpdateRequest@QGraphicsItemPrivate@@QBE_N_N000@Z @ 3726 NONAME ABSENT ; bool QGraphicsItemPrivate::discardUpdateRequest(bool, bool, bool, bool) const ?disconnectFromModel@QProxyModel@@IBEXPBVQAbstractItemModel@@@Z @ 3727 NONAME ; void QProxyModel::disconnectFromModel(class QAbstractItemModel const *) const ?dispatchEnterLeave@QApplicationPrivate@@SAXPAVQWidget@@0@Z @ 3728 NONAME ; void QApplicationPrivate::dispatchEnterLeave(class QWidget *, class QWidget *) ?display@QLCDNumber@@QAEXABVQString@@@Z @ 3729 NONAME ; void QLCDNumber::display(class QString const &) @@ -5522,8 +5522,8 @@ EXPORTS ?invalidateBuffer@QWidgetPrivate@@QAEXABVQRect@@@Z @ 5521 NONAME ; void QWidgetPrivate::invalidateBuffer(class QRect const &) ?invalidateBuffer@QWidgetPrivate@@QAEXABVQRegion@@@Z @ 5522 NONAME ; void QWidgetPrivate::invalidateBuffer(class QRegion const &) ?invalidateBuffer_resizeHelper@QWidgetPrivate@@QAEXABVQPoint@@ABVQSize@@@Z @ 5523 NONAME ; void QWidgetPrivate::invalidateBuffer_resizeHelper(class QPoint const &, class QSize const &) - ?invalidateCachedClipPath@QGraphicsItemPrivate@@QAEXXZ @ 5524 NONAME ; void QGraphicsItemPrivate::invalidateCachedClipPath(void) - ?invalidateCachedClipPathRecursively@QGraphicsItemPrivate@@QAEX_NABVQRectF@@@Z @ 5525 NONAME ; void QGraphicsItemPrivate::invalidateCachedClipPathRecursively(bool, class QRectF const &) + ?invalidateCachedClipPath@QGraphicsItemPrivate@@QAEXXZ @ 5524 NONAME ABSENT ; void QGraphicsItemPrivate::invalidateCachedClipPath(void) + ?invalidateCachedClipPathRecursively@QGraphicsItemPrivate@@QAEX_NABVQRectF@@@Z @ 5525 NONAME ABSENT ; void QGraphicsItemPrivate::invalidateCachedClipPathRecursively(bool, class QRectF const &) ?invalidateChildrenSceneTransform@QGraphicsItemPrivate@@QAEXXZ @ 5526 NONAME ; void QGraphicsItemPrivate::invalidateChildrenSceneTransform(void) ?invalidateDepthRecursively@QGraphicsItemPrivate@@QAEXXZ @ 5527 NONAME ; void QGraphicsItemPrivate::invalidateDepthRecursively(void) ?invalidateFilter@QSortFilterProxyModel@@IAEXXZ @ 5528 NONAME ; void QSortFilterProxyModel::invalidateFilter(void) @@ -5589,7 +5589,7 @@ EXPORTS ?isClickable@QHeaderView@@QBE_NXZ @ 5588 NONAME ; bool QHeaderView::isClickable(void) const ?isClipEnabled@QPaintEngineState@@QBE_NXZ @ 5589 NONAME ; bool QPaintEngineState::isClipEnabled(void) const ?isClipped@QGraphicsItem@@QBE_NXZ @ 5590 NONAME ; bool QGraphicsItem::isClipped(void) const - ?isClippedAway@QGraphicsItemPrivate@@QBE_NXZ @ 5591 NONAME ; bool QGraphicsItemPrivate::isClippedAway(void) const + ?isClippedAway@QGraphicsItemPrivate@@QBE_NXZ @ 5591 NONAME ABSENT ; bool QGraphicsItemPrivate::isClippedAway(void) const ?isClosed@QPolygonF@@QBE_NXZ @ 5592 NONAME ; bool QPolygonF::isClosed(void) const ?isCollapsible@QSplitter@@QBE_NH@Z @ 5593 NONAME ; bool QSplitter::isCollapsible(int) const ?isColumnHidden@QTableView@@QBE_NH@Z @ 5594 NONAME ; bool QTableView::isColumnHidden(int) const @@ -8586,7 +8586,7 @@ EXPORTS ?setCacheMode@QGraphicsItem@@QAEXW4CacheMode@1@ABVQSize@@@Z @ 8585 NONAME ; void QGraphicsItem::setCacheMode(enum QGraphicsItem::CacheMode, class QSize const &) ?setCacheMode@QGraphicsView@@QAEXV?$QFlags@W4CacheModeFlag@QGraphicsView@@@@@Z @ 8586 NONAME ; void QGraphicsView::setCacheMode(class QFlags) ?setCacheMode@QMovie@@QAEXW4CacheMode@1@@Z @ 8587 NONAME ; void QMovie::setCacheMode(enum QMovie::CacheMode) - ?setCachedClipPath@QGraphicsItemPrivate@@QAEXABVQPainterPath@@@Z @ 8588 NONAME ; void QGraphicsItemPrivate::setCachedClipPath(class QPainterPath const &) + ?setCachedClipPath@QGraphicsItemPrivate@@QAEXABVQPainterPath@@@Z @ 8588 NONAME ABSENT ; void QGraphicsItemPrivate::setCachedClipPath(class QPainterPath const &) ?setCalendarPopup@QDateTimeEdit@@QAEX_N@Z @ 8589 NONAME ; void QDateTimeEdit::setCalendarPopup(bool) ?setCalendarWidget@QDateTimeEdit@@QAEXPAVQCalendarWidget@@@Z @ 8590 NONAME ; void QDateTimeEdit::setCalendarWidget(class QCalendarWidget *) ?setCancelButton@QProgressDialog@@QAEXPAVQPushButton@@@Z @ 8591 NONAME ; void QProgressDialog::setCancelButton(class QPushButton *) @@ -8901,8 +8901,8 @@ EXPORTS ?setElementPositionAt@QPainterPath@@QAEXHMM@Z @ 8900 NONAME ; void QPainterPath::setElementPositionAt(int, float, float) ?setElideMode@QTabBar@@QAEXW4TextElideMode@Qt@@@Z @ 8901 NONAME ; void QTabBar::setElideMode(enum Qt::TextElideMode) ?setElideMode@QTabWidget@@QAEXW4TextElideMode@Qt@@@Z @ 8902 NONAME ; void QTabWidget::setElideMode(enum Qt::TextElideMode) - ?setEmptyCachedClipPath@QGraphicsItemPrivate@@QAEXXZ @ 8903 NONAME ; void QGraphicsItemPrivate::setEmptyCachedClipPath(void) - ?setEmptyCachedClipPathRecursively@QGraphicsItemPrivate@@QAEXABVQRectF@@@Z @ 8904 NONAME ; void QGraphicsItemPrivate::setEmptyCachedClipPathRecursively(class QRectF const &) + ?setEmptyCachedClipPath@QGraphicsItemPrivate@@QAEXXZ @ 8903 NONAME ABSENT ; void QGraphicsItemPrivate::setEmptyCachedClipPath(void) + ?setEmptyCachedClipPathRecursively@QGraphicsItemPrivate@@QAEXABVQRectF@@@Z @ 8904 NONAME ABSENT ; void QGraphicsItemPrivate::setEmptyCachedClipPathRecursively(class QRectF const &) ?setEmptyLabel@QUndoView@@QAEXABVQString@@@Z @ 8905 NONAME ; void QUndoView::setEmptyLabel(class QString const &) ?setEnabled@QAction@@QAEX_N@Z @ 8906 NONAME ; void QAction::setEnabled(bool) ?setEnabled@QActionGroup@@QAEX_N@Z @ 8907 NONAME ; void QActionGroup::setEnabled(bool) @@ -11919,7 +11919,7 @@ EXPORTS ?updateBlock@QAbstractTextDocumentLayout@@IAEXABVQTextBlock@@@Z @ 11918 NONAME ; void QAbstractTextDocumentLayout::updateBlock(class QTextBlock const &) ?updateBoundingRect@QGraphicsEffect@@IAEXXZ @ 11919 NONAME ; void QGraphicsEffect::updateBoundingRect(void) ?updateCacheIfNecessary@QWidgetItemV2@@ABEXXZ @ 11920 NONAME ; void QWidgetItemV2::updateCacheIfNecessary(void) const - ?updateCachedClipPathFromSetPosHelper@QGraphicsItemPrivate@@QAEXABVQPointF@@@Z @ 11921 NONAME ; void QGraphicsItemPrivate::updateCachedClipPathFromSetPosHelper(class QPointF const &) + ?updateCachedClipPathFromSetPosHelper@QGraphicsItemPrivate@@QAEXABVQPointF@@@Z @ 11921 NONAME ABSENT ; void QGraphicsItemPrivate::updateCachedClipPathFromSetPosHelper(class QPointF const &) ?updateCell@QCalendarWidget@@IAEXABVQDate@@@Z @ 11922 NONAME ; void QCalendarWidget::updateCell(class QDate const &) ?updateCells@QCalendarWidget@@IAEXXZ @ 11923 NONAME ; void QCalendarWidget::updateCells(void) ?updateDisplayText@QLineControl@@AAEXXZ @ 11924 NONAME ; void QLineControl::updateDisplayText(void) @@ -12517,4 +12517,9 @@ EXPORTS ?effectiveFocusWidget@QWidgetPrivate@@QAEPAVQWidget@@XZ @ 12516 NONAME ; class QWidget * QWidgetPrivate::effectiveFocusWidget(void) ?ignoreUnusedNavigationEvents@QTextControl@@QBE_NXZ @ 12517 NONAME ; bool QTextControl::ignoreUnusedNavigationEvents(void) const ?setIgnoreUnusedNavigationEvents@QTextControl@@QAEX_N@Z @ 12518 NONAME ; void QTextControl::setIgnoreUnusedNavigationEvents(bool) + ??1QImagePixmapCleanupHooks@@QAE@XZ @ 12519 NONAME ; QImagePixmapCleanupHooks::~QImagePixmapCleanupHooks(void) + ??1QVectorPath@@QAE@XZ @ 12520 NONAME ; QVectorPath::~QVectorPath(void) + ?addCacheData@QVectorPath@@QBEPAUCacheEntry@1@PAVQPaintEngineEx@@PAXP6AX01@Z@Z @ 12521 NONAME ; struct QVectorPath::CacheEntry * QVectorPath::addCacheData(class QPaintEngineEx *, void *, void (*)(class QPaintEngineEx *, void *)) const + ?discardUpdateRequest@QGraphicsItemPrivate@@QBE_N_N00@Z @ 12522 NONAME ; bool QGraphicsItemPrivate::discardUpdateRequest(bool, bool, bool) const + ?makeCacheable@QVectorPath@@QBEXXZ @ 12523 NONAME ; void QVectorPath::makeCacheable(void) const diff --git a/src/s60installs/eabi/QtGuiu.def b/src/s60installs/eabi/QtGuiu.def index 6c45a6e..429ca79 100644 --- a/src/s60installs/eabi/QtGuiu.def +++ b/src/s60installs/eabi/QtGuiu.def @@ -4680,9 +4680,9 @@ EXPORTS _ZN20QGraphicsItemPrivate28ensureSequentialSiblingIndexEv @ 4679 NONAME _ZN20QGraphicsItemPrivate29ensureSceneTransformRecursiveEPP13QGraphicsItem @ 4680 NONAME _ZN20QGraphicsItemPrivate30updateSceneTransformFromParentEv @ 4681 NONAME - _ZN20QGraphicsItemPrivate33setEmptyCachedClipPathRecursivelyERK6QRectF @ 4682 NONAME - _ZN20QGraphicsItemPrivate35invalidateCachedClipPathRecursivelyEbRK6QRectF @ 4683 NONAME - _ZN20QGraphicsItemPrivate36updateCachedClipPathFromSetPosHelperERK7QPointF @ 4684 NONAME + _ZN20QGraphicsItemPrivate33setEmptyCachedClipPathRecursivelyERK6QRectF @ 4682 NONAME ABSENT + _ZN20QGraphicsItemPrivate35invalidateCachedClipPathRecursivelyEbRK6QRectF @ 4683 NONAME ABSENT + _ZN20QGraphicsItemPrivate36updateCachedClipPathFromSetPosHelperERK7QPointF @ 4684 NONAME ABSENT _ZN20QGraphicsItemPrivate8addChildEP13QGraphicsItem @ 4685 NONAME _ZN20QGraphicsPolygonItem10setPolygonERK9QPolygonF @ 4686 NONAME _ZN20QGraphicsPolygonItem11setFillRuleEN2Qt8FillRuleE @ 4687 NONAME @@ -5221,8 +5221,8 @@ EXPORTS _ZN24QImagePixmapCleanupHooks17executeImageHooksEx @ 5220 NONAME _ZN24QImagePixmapCleanupHooks18executePixmapHooksEP7QPixmap @ 5221 NONAME ABSENT _ZN24QImagePixmapCleanupHooks8instanceEv @ 5222 NONAME - _ZN24QImagePixmapCleanupHooksC1Ev @ 5223 NONAME - _ZN24QImagePixmapCleanupHooksC2Ev @ 5224 NONAME + _ZN24QImagePixmapCleanupHooksC1Ev @ 5223 NONAME ABSENT + _ZN24QImagePixmapCleanupHooksC2Ev @ 5224 NONAME ABSENT _ZN24QPixmapConvolutionFilter11qt_metacallEN11QMetaObject4CallEiPPv @ 5225 NONAME _ZN24QPixmapConvolutionFilter11qt_metacastEPKc @ 5226 NONAME _ZN24QPixmapConvolutionFilter16staticMetaObjectE @ 5227 NONAME DATA 16 @@ -9388,7 +9388,7 @@ EXPORTS _ZNK20QGraphicsItemPrivate15initStyleOptionEP24QStyleOptionGraphicsItemRK10QTransformRK7QRegionb @ 9387 NONAME _ZNK20QGraphicsItemPrivate19genericMapFromSceneERK7QPointFPK7QWidget @ 9388 NONAME _ZNK20QGraphicsItemPrivate19maybeExtraItemCacheEv @ 9389 NONAME - _ZNK20QGraphicsItemPrivate20discardUpdateRequestEbbbb @ 9390 NONAME + _ZNK20QGraphicsItemPrivate20discardUpdateRequestEbbbb @ 9390 NONAME ABSENT _ZNK20QGraphicsItemPrivate21effectiveBoundingRectEv @ 9391 NONAME _ZNK20QGraphicsItemPrivate22inputMethodQueryHelperEN2Qt16InputMethodQueryE @ 9392 NONAME _ZNK20QGraphicsItemPrivate24combineTransformToParentEP10QTransformPKS0_ @ 9393 NONAME @@ -11571,7 +11571,7 @@ EXPORTS _ZN11QTapGesture19getStaticMetaObjectEv @ 11570 NONAME _ZN11QTapGestureC1EP7QObject @ 11571 NONAME _ZN11QTapGestureC2EP7QObject @ 11572 NONAME - _ZN11QVectorPath12addCacheDataEP14QPaintEngineExPvPFvS2_E @ 11573 NONAME + _ZN11QVectorPath12addCacheDataEP14QPaintEngineExPvPFvS2_E @ 11573 NONAME ABSENT _ZN12QApplication18symbianEventFilterEPK13QSymbianEvent @ 11574 NONAME _ZN12QApplication19symbianProcessEventEPK13QSymbianEvent @ 11575 NONAME _ZN13QGestureEvent11setAcceptedEN2Qt11GestureTypeEb @ 11576 NONAME @@ -11737,4 +11737,8 @@ EXPORTS _Zls6QDebugRKN12QStyleOption10OptionTypeE @ 11736 NONAME _ZN12QTextControl31setIgnoreUnusedNavigationEventsEb @ 11737 NONAME _ZNK12QTextControl28ignoreUnusedNavigationEventsEv @ 11738 NONAME + _ZN11QVectorPathD1Ev @ 11739 NONAME + _ZN11QVectorPathD2Ev @ 11740 NONAME + _ZNK11QVectorPath12addCacheDataEP14QPaintEngineExPvPFvS1_S2_E @ 11741 NONAME + _ZNK20QGraphicsItemPrivate20discardUpdateRequestEbbb @ 11742 NONAME -- cgit v0.12 From 120a12f5dc13dea327cdbbbc94b58f29d1f3306b Mon Sep 17 00:00:00 2001 From: Gunnar Sletta Date: Tue, 8 Dec 2009 17:47:37 +0200 Subject: Speed up rotated/transformed text on OpenGL2 paint engine Reviewed-by: Trond Reviewed-by: Tom --- .../gl2paintengineex/qpaintengineex_opengl2.cpp | 95 ++++++++-------------- 1 file changed, 34 insertions(+), 61 deletions(-) diff --git a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp index 3fce384..17af9cb 100644 --- a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp +++ b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp @@ -589,53 +589,31 @@ void QGL2PaintEngineExPrivate::updateMatrix() // matrix multiplication as most of the components are trivial. const QTransform& transform = q->state()->matrix; - if (mode == TextDrawingMode) { - // Text drawing mode is only used for non-scaling transforms - pmvMatrix[0][0] = 2.0 / width; - pmvMatrix[0][1] = 0.0; - pmvMatrix[0][2] = 0.0; - pmvMatrix[0][3] = 0.0; - pmvMatrix[1][0] = 0.0; - pmvMatrix[1][1] = -2.0 / height; - pmvMatrix[1][2] = 0.0; - pmvMatrix[1][3] = 0.0; - pmvMatrix[2][0] = 0.0; - pmvMatrix[2][1] = 0.0; - pmvMatrix[2][2] = -1.0; - pmvMatrix[2][3] = 0.0; - pmvMatrix[3][0] = pmvMatrix[0][0] * qRound(transform.dx()) - 1.0; - pmvMatrix[3][1] = pmvMatrix[1][1] * qRound(transform.dy()) + 1.0; - pmvMatrix[3][2] = 0.0; - pmvMatrix[3][3] = 1.0; - - inverseScale = 1; - } else { - qreal wfactor = 2.0 / width; - qreal hfactor = -2.0 / height; - - pmvMatrix[0][0] = wfactor * transform.m11() - transform.m13(); - pmvMatrix[0][1] = hfactor * transform.m12() + transform.m13(); - pmvMatrix[0][2] = 0.0; - pmvMatrix[0][3] = transform.m13(); - pmvMatrix[1][0] = wfactor * transform.m21() - transform.m23(); - pmvMatrix[1][1] = hfactor * transform.m22() + transform.m23(); - pmvMatrix[1][2] = 0.0; - pmvMatrix[1][3] = transform.m23(); - pmvMatrix[2][0] = 0.0; - pmvMatrix[2][1] = 0.0; - pmvMatrix[2][2] = -1.0; - pmvMatrix[2][3] = 0.0; - pmvMatrix[3][0] = wfactor * transform.dx() - transform.m33(); - pmvMatrix[3][1] = hfactor * transform.dy() + transform.m33(); - pmvMatrix[3][2] = 0.0; - pmvMatrix[3][3] = transform.m33(); - - // 1/10000 == 0.0001, so we have good enough res to cover curves - // that span the entire widget... - inverseScale = qMax(1 / qMax( qMax(qAbs(transform.m11()), qAbs(transform.m22())), - qMax(qAbs(transform.m12()), qAbs(transform.m21())) ), - qreal(0.0001)); - } + qreal wfactor = 2.0 / width; + qreal hfactor = -2.0 / height; + + pmvMatrix[0][0] = wfactor * transform.m11() - transform.m13(); + pmvMatrix[0][1] = hfactor * transform.m12() + transform.m13(); + pmvMatrix[0][2] = 0.0; + pmvMatrix[0][3] = transform.m13(); + pmvMatrix[1][0] = wfactor * transform.m21() - transform.m23(); + pmvMatrix[1][1] = hfactor * transform.m22() + transform.m23(); + pmvMatrix[1][2] = 0.0; + pmvMatrix[1][3] = transform.m23(); + pmvMatrix[2][0] = 0.0; + pmvMatrix[2][1] = 0.0; + pmvMatrix[2][2] = -1.0; + pmvMatrix[2][3] = 0.0; + pmvMatrix[3][0] = wfactor * transform.dx() - transform.m33(); + pmvMatrix[3][1] = hfactor * transform.dy() + transform.m33(); + pmvMatrix[3][2] = 0.0; + pmvMatrix[3][3] = transform.m33(); + + // 1/10000 == 0.0001, so we have good enough res to cover curves + // that span the entire widget... + inverseScale = qMax(1 / qMax( qMax(qAbs(transform.m11()), qAbs(transform.m22())), + qMax(qAbs(transform.m12()), qAbs(transform.m21())) ), + qreal(0.0001)); matrixDirty = false; @@ -817,17 +795,12 @@ void QGL2PaintEngineExPrivate::transferMode(EngineMode newMode) lastTexture = GLuint(-1); } - if (mode == TextDrawingMode) - matrixDirty = true; - if (newMode == TextDrawingMode) { glEnableVertexAttribArray(QT_VERTEX_COORDS_ATTR); glEnableVertexAttribArray(QT_TEXTURE_COORDS_ATTR); glVertexAttribPointer(QT_VERTEX_COORDS_ATTR, 2, GL_FLOAT, GL_FALSE, 0, vertexCoordinateArray.data()); glVertexAttribPointer(QT_TEXTURE_COORDS_ATTR, 2, GL_FLOAT, GL_FALSE, 0, textureCoordinateArray.data()); - - matrixDirty = true; } if (newMode == ImageDrawingMode) { @@ -930,7 +903,7 @@ void QGL2PaintEngineExPrivate::fill(const QVectorPath& path) int floatSizeInBytes = vertexCount * 2 * sizeof(float); cache->vertexCount = vertexCount; cache->primitiveType = GL_TRIANGLE_FAN; - cache->iscale = inverseScale; + cache->iscale = inverseScale; #ifdef QT_OPENGL_CACHE_AS_VBOS glGenBuffers(1, &cache->vbo); glBindBuffer(GL_ARRAY_BUFFER, cache->vbo); @@ -1545,21 +1518,21 @@ void QGL2PaintEngineEx::drawTextItem(const QPointF &p, const QTextItem &textItem const QTextItemInt &ti = static_cast(textItem); - bool drawCached = true; + QTransform::TransformationType txtype = s->matrix.type(); - if (s->matrix.type() > QTransform::TxTranslate) - drawCached = false; + float det = s->matrix.determinant(); + bool drawCached = txtype < QTransform::TxProject; - // don't try to cache huge fonts + // don't try to cache huge fonts or vastly transformed fonts const qreal pixelSize = ti.fontEngine->fontDef.pixelSize; - if (pixelSize * pixelSize * qAbs(s->matrix.determinant()) >= 64 * 64) + if (pixelSize * pixelSize * qAbs(det) >= 64 * 64 || det < 0.25f || det > 4.f) drawCached = false; QFontEngineGlyphCache::Type glyphType = ti.fontEngine->glyphFormat >= 0 ? QFontEngineGlyphCache::Type(ti.fontEngine->glyphFormat) : d->glyphCacheType; - if (d->inRenderText) + if (d->inRenderText || txtype > QTransform::TxTranslate) glyphType = QFontEngineGlyphCache::Raster_A8; if (glyphType == QFontEngineGlyphCache::Raster_RGBMask @@ -1589,10 +1562,10 @@ void QGL2PaintEngineExPrivate::drawCachedGlyphs(const QPointF &p, QFontEngineGly ti.fontEngine->getGlyphPositions(ti.glyphs, matrix, ti.flags, glyphs, positions); QGLTextureGlyphCache *cache = - (QGLTextureGlyphCache *) ti.fontEngine->glyphCache(ctx, s->matrix); + (QGLTextureGlyphCache *) ti.fontEngine->glyphCache(ctx, QTransform()); if (!cache || cache->cacheType() != glyphType) { - cache = new QGLTextureGlyphCache(ctx, glyphType, s->matrix); + cache = new QGLTextureGlyphCache(ctx, glyphType, QTransform()); ti.fontEngine->setGlyphCache(ctx, cache); } -- cgit v0.12 From 0b78ccc201f58b53c90e6327b051bfdb8c08ee14 Mon Sep 17 00:00:00 2001 From: Donald Carr Date: Tue, 8 Dec 2009 16:28:43 +0000 Subject: Fixed uninitialized background artifacts in QWidget::render. backport of 64d38ba23b4acc46fdb9145f1953315573e3f8dc Reviewed-by: Anders Bakken --- src/gui/kernel/qwidget.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/kernel/qwidget.cpp b/src/gui/kernel/qwidget.cpp index 85c1955..91e43ce 100644 --- a/src/gui/kernel/qwidget.cpp +++ b/src/gui/kernel/qwidget.cpp @@ -4955,7 +4955,7 @@ void QWidgetPrivate::render_helper(QPainter *painter, const QPoint &targetOffset return; QPixmap pixmap(size); - if (!(renderFlags & QWidget::DrawWindowBackground)) + if (!(renderFlags & QWidget::DrawWindowBackground) || !isOpaque) pixmap.fill(Qt::transparent); q->render(&pixmap, QPoint(), toBePainted, renderFlags); -- cgit v0.12 From f3c37838ab149a8a570b7f1df987705815ae45c0 Mon Sep 17 00:00:00 2001 From: Robert Griebl Date: Tue, 8 Dec 2009 17:10:57 +0100 Subject: QGtkStyle: support for the inner-border property in GtkButtons This additional padding was not taken into account up to now. It didn't matter for desktop themes, but Maemo5 uses a large (8pix) padding that can not be ignored. Reviewed-by: jbache --- src/gui/styles/qgtkstyle.cpp | 16 ++++++++++++++++ src/gui/styles/qgtkstyle_p.cpp | 2 ++ src/gui/styles/qgtkstyle_p.h | 2 ++ 3 files changed, 20 insertions(+) diff --git a/src/gui/styles/qgtkstyle.cpp b/src/gui/styles/qgtkstyle.cpp index afa3325..097a2b5 100644 --- a/src/gui/styles/qgtkstyle.cpp +++ b/src/gui/styles/qgtkstyle.cpp @@ -3375,12 +3375,28 @@ QIcon QGtkStyle::standardIconImplementation(StandardPixmap standardIcon, /*! \reimp */ QRect QGtkStyle::subElementRect(SubElement element, const QStyleOption *option, const QWidget *widget) const { + Q_D(const QGtkStyle); + QRect r = QCleanlooksStyle::subElementRect(element, option, widget); switch (element) { case SE_ProgressBarLabel: case SE_ProgressBarContents: case SE_ProgressBarGroove: return option->rect; + case SE_PushButtonContents: + if (!d->gtk_check_version(2, 10, 0)) { + GtkWidget *gtkButton = d->gtkWidget(QLS("GtkButton")); + GtkBorder *border = 0; + d->gtk_widget_style_get(gtkButton, "inner-border", &border, NULL); + if (border) { + r = option->rect.adjusted(border->left, border->top, -border->right, -border->top); + d->gtk_border_free(border); + } else { + r = option->rect.adjusted(1, 1, -1, -1); + } + r = visualRect(option->direction, option->rect, r); + } + break; default: break; } diff --git a/src/gui/styles/qgtkstyle_p.cpp b/src/gui/styles/qgtkstyle_p.cpp index 22dfc62..a644a5b 100644 --- a/src/gui/styles/qgtkstyle_p.cpp +++ b/src/gui/styles/qgtkstyle_p.cpp @@ -158,6 +158,7 @@ Ptr_gtk_window_get_type QGtkStylePrivate::gtk_window_get_type = 0; Ptr_gtk_widget_get_type QGtkStylePrivate::gtk_widget_get_type = 0; Ptr_gtk_rc_get_style_by_paths QGtkStylePrivate::gtk_rc_get_style_by_paths = 0; Ptr_gtk_check_version QGtkStylePrivate::gtk_check_version = 0; +Ptr_gtk_border_free QGtkStylePrivate::gtk_border_free = 0; Ptr_pango_font_description_get_size QGtkStylePrivate::pango_font_description_get_size = 0; Ptr_pango_font_description_get_weight QGtkStylePrivate::pango_font_description_get_weight = 0; @@ -416,6 +417,7 @@ void QGtkStylePrivate::resolveGtk() const gtk_widget_get_type =(Ptr_gtk_widget_get_type)libgtk.resolve("gtk_widget_get_type"); gtk_rc_get_style_by_paths =(Ptr_gtk_rc_get_style_by_paths)libgtk.resolve("gtk_rc_get_style_by_paths"); gtk_check_version =(Ptr_gtk_check_version)libgtk.resolve("gtk_check_version"); + gtk_border_free =(Ptr_gtk_border_free)libgtk.resolve("gtk_border_free"); pango_font_description_get_size = (Ptr_pango_font_description_get_size)libgtk.resolve("pango_font_description_get_size"); pango_font_description_get_weight = (Ptr_pango_font_description_get_weight)libgtk.resolve("pango_font_description_get_weight"); pango_font_description_get_family = (Ptr_pango_font_description_get_family)libgtk.resolve("pango_font_description_get_family"); diff --git a/src/gui/styles/qgtkstyle_p.h b/src/gui/styles/qgtkstyle_p.h index f6ab8a3..c27308f 100644 --- a/src/gui/styles/qgtkstyle_p.h +++ b/src/gui/styles/qgtkstyle_p.h @@ -176,6 +176,7 @@ typedef GtkWidget* (*Ptr_gtk_file_chooser_dialog_new)(const gchar *title, typedef void (*Ptr_gtk_file_chooser_set_current_name) (GtkFileChooser *, const gchar *); typedef gboolean (*Ptr_gtk_file_chooser_set_filename) (GtkFileChooser *chooser, const gchar *name); typedef gint (*Ptr_gtk_dialog_run) (GtkDialog*); +typedef void (*Ptr_gtk_border_free)(GtkBorder *); typedef guchar* (*Ptr_gdk_pixbuf_get_pixels) (const GdkPixbuf *pixbuf); typedef int (*Ptr_gdk_pixbuf_get_width) (const GdkPixbuf *pixbuf); @@ -371,6 +372,7 @@ public: static Ptr_gtk_widget_get_type gtk_widget_get_type; static Ptr_gtk_rc_get_style_by_paths gtk_rc_get_style_by_paths; static Ptr_gtk_check_version gtk_check_version; + static Ptr_gtk_border_free gtk_border_free; static Ptr_pango_font_description_get_size pango_font_description_get_size; static Ptr_pango_font_description_get_weight pango_font_description_get_weight; -- cgit v0.12 From 51297287f1be5c31337203cbf5a0e3eae6047a88 Mon Sep 17 00:00:00 2001 From: Rhys Weatherley Date: Wed, 9 Dec 2009 08:46:37 +1000 Subject: Make sure a context is current when loading compressed textures. Reviewed-by: trustme --- src/opengl/qpixmapdata_gl.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/opengl/qpixmapdata_gl.cpp b/src/opengl/qpixmapdata_gl.cpp index 0299cea..4e1d50d 100644 --- a/src/opengl/qpixmapdata_gl.cpp +++ b/src/opengl/qpixmapdata_gl.cpp @@ -424,6 +424,7 @@ bool QGLPixmapData::fromFile(const QString &filename, const char *format, resize(0, 0); data = file.readAll(); file.close(); + QGLShareContextScope ctx(qt_gl_share_widget()->context()); QSize size = m_texture.bindCompressedTexture (data.constData(), data.size(), format); if (!size.isEmpty()) { @@ -449,6 +450,7 @@ bool QGLPixmapData::fromData(const uchar *buffer, uint len, const char *format, const char *buf = reinterpret_cast(buffer); if (m_texture.canBindCompressedTexture(buf, int(len), format, &alpha)) { resize(0, 0); + QGLShareContextScope ctx(qt_gl_share_widget()->context()); QSize size = m_texture.bindCompressedTexture(buf, int(len), format); if (!size.isEmpty()) { w = size.width(); -- cgit v0.12 From 62fac41edfff5e42e4c3308376cb08e5d9a10afe Mon Sep 17 00:00:00 2001 From: Rhys Weatherley Date: Wed, 9 Dec 2009 09:10:11 +1000 Subject: Fix upside down PVR compressed textures. The "vertical flip" flag in the PVR format is the inverse of the "inverted y" state that we use in Qt. Reviewed-by: trustme --- src/opengl/qgl.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/opengl/qgl.cpp b/src/opengl/qgl.cpp index 967ba48..8003a29 100644 --- a/src/opengl/qgl.cpp +++ b/src/opengl/qgl.cpp @@ -5363,11 +5363,12 @@ QSize QGLTexture::bindCompressedTexturePVR(const char *buf, int len) // Restore the default pixel alignment for later texture uploads. glPixelStorei(GL_UNPACK_ALIGNMENT, 4); - // Set the invert flag for the texture. + // Set the invert flag for the texture. The "vertical flip" + // flag in PVR is the opposite sense to our sense of inversion. if ((pvrHeader->flags & PVR_VERTICAL_FLIP) != 0) - options |= QGLContext::InvertedYBindOption; - else options &= ~QGLContext::InvertedYBindOption; + else + options |= QGLContext::InvertedYBindOption; return QSize(pvrHeader->width, pvrHeader->height); } -- cgit v0.12 From f814791b18df3ba0828fefa9f40b2fc955185daf Mon Sep 17 00:00:00 2001 From: Kurt Korbatits Date: Wed, 9 Dec 2009 10:31:53 +1000 Subject: Add -audio-backend and -no-audio-backend configure option. Allow better control over audio backend used. Reviewed-by:Justin McPherson --- configure | 19 +++++++++++++++++-- configure.exe | Bin 1173504 -> 1176576 bytes src/multimedia/audio/audio.pri | 5 +++++ src/multimedia/audio/qaudiodevicefactory.cpp | 14 ++++++++++++++ tools/configure/configureapp.cpp | 11 +++++++++-- 5 files changed, 45 insertions(+), 4 deletions(-) diff --git a/configure b/configure index b6ce9e6..41f4991 100755 --- a/configure +++ b/configure @@ -672,6 +672,7 @@ CFG_RELEASE_QMAKE=no CFG_PHONON=auto CFG_PHONON_BACKEND=yes CFG_MULTIMEDIA=yes +CFG_AUDIO_BACKEND=yes CFG_SVG=yes CFG_DECLARATIVE=auto CFG_WEBKIT=auto # (yes|no|auto) @@ -914,7 +915,7 @@ while [ "$#" -gt 0 ]; do VAL=no ;; #Qt style yes options - -incremental|-qvfb|-profile|-shared|-static|-sm|-xinerama|-xshape|-xsync|-xinput|-reduce-exports|-pch|-separate-debug-info|-stl|-freetype|-xcursor|-xfixes|-xrandr|-xrender|-mitshm|-fontconfig|-xkb|-nis|-qdbus|-dbus|-dbus-linked|-glib|-gstreamer|-gtkstyle|-cups|-iconv|-largefile|-h|-help|-v|-verbose|-debug|-release|-fast|-accessibility|-confirm-license|-gnumake|-framework|-qt3support|-debug-and-release|-exceptions|-cocoa|-universal|-prefix-install|-silent|-armfpa|-optimized-qmake|-dwarf2|-reduce-relocations|-sse|-openssl|-openssl-linked|-ptmalloc|-xmlpatterns|-phonon|-phonon-backend|-multimedia|-svg|-declarative|-webkit|-javascript-jit|-script|-scripttools|-rpath|-force-pkg-config) + -incremental|-qvfb|-profile|-shared|-static|-sm|-xinerama|-xshape|-xsync|-xinput|-reduce-exports|-pch|-separate-debug-info|-stl|-freetype|-xcursor|-xfixes|-xrandr|-xrender|-mitshm|-fontconfig|-xkb|-nis|-qdbus|-dbus|-dbus-linked|-glib|-gstreamer|-gtkstyle|-cups|-iconv|-largefile|-h|-help|-v|-verbose|-debug|-release|-fast|-accessibility|-confirm-license|-gnumake|-framework|-qt3support|-debug-and-release|-exceptions|-cocoa|-universal|-prefix-install|-silent|-armfpa|-optimized-qmake|-dwarf2|-reduce-relocations|-sse|-openssl|-openssl-linked|-ptmalloc|-xmlpatterns|-phonon|-phonon-backend|-multimedia|-audio-backend|-svg|-declarative|-webkit|-javascript-jit|-script|-scripttools|-rpath|-force-pkg-config) VAR=`echo $1 | sed "s,^-\(.*\),\1,"` VAL=yes ;; @@ -2078,6 +2079,13 @@ while [ "$#" -gt 0 ]; do UNKNOWN_OPT=yes fi ;; + audio-backend) + if [ "$VAL" = "yes" ] || [ "$VAL" = "no" ]; then + CFG_AUDIO_BACKEND="$VAL" + else + UNKNOWN_OPT=yes + fi + ;; *) UNKNOWN_OPT=yes ;; @@ -3255,7 +3263,7 @@ Usage: $relconf [-h] [-prefix ] [-prefix-install] [-bindir ] [-libdir [-qtnamespace ] [-qtlibinfix ] [-separate-debug-info] [-armfpa] [-no-optimized-qmake] [-optimized-qmake] [-no-xmlpatterns] [-xmlpatterns] [-no-multimedia] [-multimedia] [-no-phonon] [-phonon] [-no-phonon-backend] [-phonon-backend] - [-no-openssl] [-openssl] [-openssl-linked] + [-no-audio-backend] [-audio-backend] [-no-openssl] [-openssl] [-openssl-linked] [-no-gtkstyle] [-gtkstyle] [-no-svg] [-svg] [-no-webkit] [-webkit] [-no-javascript-jit] [-javascript-jit] [-no-script] [-script] [-no-scripttools] [-scripttools] [-no-declarative] [-declarative] @@ -3393,6 +3401,9 @@ fi -no-multimedia ..... Do not build the QtMultimedia module. + -multimedia ........ Build the QtMultimedia module. + -no-audio-backend .. Do not build the platform audio backend into QtMultimedia. + + -audio-backend ..... Build the platform audio backend into QtMultimedia if available. + -no-phonon ......... Do not build the Phonon module. + -phonon ............ Build the Phonon module. Phonon is built if a decent C++ compiler is used. @@ -6440,6 +6451,10 @@ else QT_CONFIG="$QT_CONFIG multimedia" fi +if [ "$CFG_AUDIO_BACKEND" = "yes" ]; then + QT_CONFIG="$QT_CONFIG audio-backend" +fi + if [ "$CFG_SVG" = "yes" ]; then QT_CONFIG="$QT_CONFIG svg" else diff --git a/configure.exe b/configure.exe index 7fe4a93..a410efc 100755 Binary files a/configure.exe and b/configure.exe differ diff --git a/src/multimedia/audio/audio.pri b/src/multimedia/audio/audio.pri index c445941..625b871c 100644 --- a/src/multimedia/audio/audio.pri +++ b/src/multimedia/audio/audio.pri @@ -17,6 +17,8 @@ SOURCES += $$PWD/qaudio.cpp \ $$PWD/qaudioengine.cpp \ $$PWD/qaudiodevicefactory.cpp +contains(QT_CONFIG, audio-backend) { + mac { HEADERS += $$PWD/qaudioinput_mac_p.h \ $$PWD/qaudiooutput_mac_p.h \ @@ -51,3 +53,6 @@ mac { } } } +} else { + DEFINES += QT_NO_AUDIO_BACKEND +} diff --git a/src/multimedia/audio/qaudiodevicefactory.cpp b/src/multimedia/audio/qaudiodevicefactory.cpp index 89e4394..bc1656d 100644 --- a/src/multimedia/audio/qaudiodevicefactory.cpp +++ b/src/multimedia/audio/qaudiodevicefactory.cpp @@ -45,6 +45,7 @@ #include #include "qaudiodevicefactory_p.h" +#ifndef QT_NO_AUDIO_BACKEND #if defined(Q_OS_WIN) #include "qaudiodeviceinfo_win32_p.h" #include "qaudiooutput_win32_p.h" @@ -58,6 +59,7 @@ #include "qaudiooutput_alsa_p.h" #include "qaudioinput_alsa_p.h" #endif +#endif QT_BEGIN_NAMESPACE @@ -125,10 +127,12 @@ public: QList QAudioDeviceFactory::availableDevices(QAudio::Mode mode) { QList devices; +#ifndef QT_NO_AUDIO_BACKEND #if (defined(Q_OS_WIN) || defined(Q_OS_MAC) || defined(HAS_ALSA)) foreach (const QByteArray &handle, QAudioDeviceInfoInternal::availableDevices(mode)) devices << QAudioDeviceInfo(QLatin1String("builtin"), handle, mode); #endif +#endif QFactoryLoader* l = loader(); foreach (QString const& key, l->keys()) { @@ -153,9 +157,11 @@ QAudioDeviceInfo QAudioDeviceFactory::defaultInputDevice() if (list.size() > 0) return QAudioDeviceInfo(QLatin1String("default"), list.at(0), QAudio::AudioInput); } +#ifndef QT_NO_AUDIO_BACKEND #if (defined(Q_OS_WIN) || defined(Q_OS_MAC) || defined(HAS_ALSA)) return QAudioDeviceInfo(QLatin1String("builtin"), QAudioDeviceInfoInternal::defaultInputDevice(), QAudio::AudioInput); #endif +#endif return QAudioDeviceInfo(); } @@ -168,9 +174,11 @@ QAudioDeviceInfo QAudioDeviceFactory::defaultOutputDevice() if (list.size() > 0) return QAudioDeviceInfo(QLatin1String("default"), list.at(0), QAudio::AudioOutput); } +#ifndef QT_NO_AUDIO_BACKEND #if (defined(Q_OS_WIN) || defined(Q_OS_MAC) || defined(HAS_ALSA)) return QAudioDeviceInfo(QLatin1String("builtin"), QAudioDeviceInfoInternal::defaultOutputDevice(), QAudio::AudioOutput); #endif +#endif return QAudioDeviceInfo(); } @@ -178,10 +186,12 @@ QAbstractAudioDeviceInfo* QAudioDeviceFactory::audioDeviceInfo(const QString &re { QAbstractAudioDeviceInfo *rc = 0; +#ifndef QT_NO_AUDIO_BACKEND #if (defined(Q_OS_WIN) || defined(Q_OS_MAC) || defined(HAS_ALSA)) if (realm == QLatin1String("builtin")) return new QAudioDeviceInfoInternal(handle, mode); #endif +#endif QAudioEngineFactoryInterface* plugin = qobject_cast(loader()->instance(realm)); @@ -205,10 +215,12 @@ QAbstractAudioInput* QAudioDeviceFactory::createInputDevice(QAudioDeviceInfo con { if (deviceInfo.isNull()) return new QNullInputDevice(); +#ifndef QT_NO_AUDIO_BACKEND #if (defined(Q_OS_WIN) || defined(Q_OS_MAC) || defined(HAS_ALSA)) if (deviceInfo.realm() == QLatin1String("builtin")) return new QAudioInputPrivate(deviceInfo.handle(), format); #endif +#endif QAudioEngineFactoryInterface* plugin = qobject_cast(loader()->instance(deviceInfo.realm())); @@ -222,10 +234,12 @@ QAbstractAudioOutput* QAudioDeviceFactory::createOutputDevice(QAudioDeviceInfo c { if (deviceInfo.isNull()) return new QNullOutputDevice(); +#ifndef QT_NO_AUDIO_BACKEND #if (defined(Q_OS_WIN) || defined(Q_OS_MAC) || defined(HAS_ALSA)) if (deviceInfo.realm() == QLatin1String("builtin")) return new QAudioOutputPrivate(deviceInfo.handle(), format); #endif +#endif QAudioEngineFactoryInterface* plugin = qobject_cast(loader()->instance(deviceInfo.realm())); diff --git a/tools/configure/configureapp.cpp b/tools/configure/configureapp.cpp index 735e030..9143ca7 100644 --- a/tools/configure/configureapp.cpp +++ b/tools/configure/configureapp.cpp @@ -247,6 +247,7 @@ Configure::Configure( int& argc, char** argv ) dictionary[ "PHONON" ] = "auto"; dictionary[ "PHONON_BACKEND" ] = "yes"; dictionary[ "MULTIMEDIA" ] = "yes"; + dictionary[ "AUDIO_BACKEND" ] = "yes"; dictionary[ "DIRECTSHOW" ] = "no"; dictionary[ "WEBKIT" ] = "auto"; dictionary[ "DECLARATIVE" ] = "auto"; @@ -897,6 +898,10 @@ void Configure::parseCmdLine() dictionary[ "MULTIMEDIA" ] = "no"; } else if( configCmdLine.at(i) == "-multimedia" ) { dictionary[ "MULTIMEDIA" ] = "yes"; + } else if( configCmdLine.at(i) == "-audio-backend" ) { + dictionary[ "AUDIO_BACKEND" ] = "yes"; + } else if( configCmdLine.at(i) == "-no-audio-backend" ) { + dictionary[ "AUDIO_BACKEND" ] = "no"; } else if( configCmdLine.at(i) == "-no-phonon" ) { dictionary[ "PHONON" ] = "no"; } else if( configCmdLine.at(i) == "-phonon" ) { @@ -1567,9 +1572,9 @@ bool Configure::displayHelp() "[-no-openssl] [-no-dbus] [-dbus] [-dbus-linked] [-platform ]\n" "[-qtnamespace ] [-qtlibinfix ] [-no-phonon]\n" "[-phonon] [-no-phonon-backend] [-phonon-backend]\n" - "[-no-multimedia] [-multimedia] [-no-webkit] [-webkit]\n" + "[-no-multimedia] [-multimedia] [-no-audio-backend] [-audio-backend]\n" "[-no-script] [-script] [-no-scripttools] [-scripttools]\n" - "[-graphicssystem raster|opengl|openvg]\n\n", 0, 7); + "[-no-webkit] [-webkit] [-graphicssystem raster|opengl|openvg]\n\n", 0, 7); desc("Installation options:\n\n"); @@ -1749,6 +1754,8 @@ bool Configure::displayHelp() desc("PHONON_BACKEND","yes","-phonon-backend", "Compile in the platform-specific Phonon backend-plugin"); desc("MULTIMEDIA", "no", "-no-multimedia", "Do not compile the multimedia module"); desc("MULTIMEDIA", "yes","-multimedia", "Compile in multimedia module"); + desc("AUDIO_BACKEND", "no","-no-audio-backend", "Do not compile in the platform audio backend into QtMultimedia"); + desc("AUDIO_BACKEND", "yes","-audio-backend", "Compile in the platform audio backend into QtMultimedia"); desc("WEBKIT", "no", "-no-webkit", "Do not compile in the WebKit module"); desc("WEBKIT", "yes", "-webkit", "Compile in the WebKit module (WebKit is built if a decent C++ compiler is used.)"); desc("SCRIPT", "no", "-no-script", "Do not build the QtScript module."); -- cgit v0.12 From ad2509f8d7c634364ae7082dcc83b6906d235750 Mon Sep 17 00:00:00 2001 From: Kurt Korbatits Date: Wed, 9 Dec 2009 10:34:19 +1000 Subject: Fix up documentation examples for low-level audio. QTBUG-6548 QAudioOutput::start() crashes when the QIODevice is destructed Made documentation clearer. Task-number:QTBUG-6548 Reviewed-by:Justin McPherson --- src/multimedia/audio/qaudioinput.cpp | 15 +++++++++++++-- src/multimedia/audio/qaudiooutput.cpp | 15 +++++++++++++-- 2 files changed, 26 insertions(+), 4 deletions(-) diff --git a/src/multimedia/audio/qaudioinput.cpp b/src/multimedia/audio/qaudioinput.cpp index 8b368d5..d81df7a 100644 --- a/src/multimedia/audio/qaudioinput.cpp +++ b/src/multimedia/audio/qaudioinput.cpp @@ -77,8 +77,12 @@ QT_BEGIN_NAMESPACE file, you can: \code + QFile outputFile; // class member. + QAudioInput* audio; // class member. + \endcode + + \code { - QFile outputFile; outputFile.setFileName("/tmp/test.raw"); outputFile.open( QIODevice::WriteOnly | QIODevice::Truncate ); @@ -91,7 +95,13 @@ QT_BEGIN_NAMESPACE format.setByteOrder(QAudioFormat::LittleEndian); format.setSampleType(QAudioFormat::UnSignedInt); - QAudioInput *audio = new QAudioInput(format, this); + if (QAudioDeviceInfo info(QAudioDeviceInfo::defaultInputDevice()); + if (!info.isFormatSupported(format)) { + qWarning()<<"default format not supported try to use nearest"; + format = info.nearestFormat(format); + } + + audio = new QAudioInput(format, this); QTimer::singleShot(3000, this, SLOT(stopRecording())); audio->start(outputFile); // Records audio for 3000ms @@ -109,6 +119,7 @@ QT_BEGIN_NAMESPACE { audio->stop(); outputFile->close(); + delete audio; } \endcode diff --git a/src/multimedia/audio/qaudiooutput.cpp b/src/multimedia/audio/qaudiooutput.cpp index f8f2fa1..1c7b617 100644 --- a/src/multimedia/audio/qaudiooutput.cpp +++ b/src/multimedia/audio/qaudiooutput.cpp @@ -73,7 +73,11 @@ QT_BEGIN_NAMESPACE simple as: \code - QFile inputFile; + QFile inputFile; // class member. + QAudioOutput* audio; // class member. + \endcode + + \code inputFile.setFileName("/tmp/test.raw"); inputFile.open(QIODevice::ReadOnly); @@ -86,7 +90,13 @@ QT_BEGIN_NAMESPACE format.setByteOrder(QAudioFormat::LittleEndian); format.setSampleType(QAudioFormat::UnSignedInt); - QAudioOutput *audio = new QAudioOutput(format, this); + QAudioDeviceInfo info(QAudioDeviceInfo::defaultOutputDevice()); + if (!info.isFormatSupported(format)) { + qWarning()<<"raw audio format not supported by backend, cannot play audio."; + return; + } + + audio = new QAudioOutput(format, this); connect(audio,SIGNAL(stateChanged(QAudio::State)),SLOT(finishedPlaying(QAudio::State))); audio->start(inputFile); @@ -104,6 +114,7 @@ QT_BEGIN_NAMESPACE if(state == QAudio::IdleState) { audio->stop(); inputFile.close(); + delete audio; } } \endcode -- cgit v0.12 From f59908d4a6edcd333a156d4c94ddbd9b30f7e810 Mon Sep 17 00:00:00 2001 From: Rhys Weatherley Date: Wed, 9 Dec 2009 11:06:30 +1000 Subject: Export QGLShareRegister because qgl_share_reg() is exported Reviewed-by: trustme --- src/opengl/qgl_p.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/opengl/qgl_p.h b/src/opengl/qgl_p.h index 179d69a..615fb60 100644 --- a/src/opengl/qgl_p.h +++ b/src/opengl/qgl_p.h @@ -397,7 +397,7 @@ public: Q_DECLARE_OPERATORS_FOR_FLAGS(QGLExtensions::Extensions) -class Q_AUTOTEST_EXPORT QGLShareRegister +class Q_OPENGL_EXPORT QGLShareRegister { public: QGLShareRegister() {} -- cgit v0.12 From c44f142cedf847bfb676eb70cb52f61a6c6ba232 Mon Sep 17 00:00:00 2001 From: Rohan McGovern Date: Wed, 9 Dec 2009 15:46:41 +1000 Subject: Fixed (unstable) tst_QTimeLine::currentTime test failure Use qFuzzyCompare instead of an exact floating point comparison when checking if valueChanged should be emitted. Task-number: QTBUG-6189 Reviewed-by: Dmytro Poplavskiy --- src/corelib/tools/qtimeline.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/corelib/tools/qtimeline.cpp b/src/corelib/tools/qtimeline.cpp index cd3483d..ce49e3f 100644 --- a/src/corelib/tools/qtimeline.cpp +++ b/src/corelib/tools/qtimeline.cpp @@ -125,7 +125,7 @@ void QTimeLinePrivate::setCurrentTime(int msecs) #ifdef QTIMELINE_DEBUG qDebug() << "QTimeLinePrivate::setCurrentTime: frameForTime" << currentTime << currentFrame; #endif - if (lastValue != q->currentValue()) + if (!qFuzzyCompare(lastValue, q->currentValue())) emit q->valueChanged(q->currentValue()); if (lastFrame != currentFrame) { const int transitionframe = (direction == QTimeLine::Forward ? endFrame : startFrame); -- cgit v0.12 From 472c13edc85a6c7efef1e3b904333d0c9a5f9da6 Mon Sep 17 00:00:00 2001 From: Anders Bakken Date: Thu, 3 Dec 2009 08:55:20 -0800 Subject: Set stacking class for stays-on-top windows in DFB For better compatibility with non-QWS DirectFB apps running in the same session we should set the stacking class of Windows that have the StaysOnTop flag set. This corresponds nicely to DWSC_UPPER. Reviewed-by: Jervey Kong --- src/plugins/gfxdrivers/directfb/qdirectfbwindowsurface.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbwindowsurface.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbwindowsurface.cpp index 021d52e..b79418a 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbwindowsurface.cpp +++ b/src/plugins/gfxdrivers/directfb/qdirectfbwindowsurface.cpp @@ -128,7 +128,6 @@ IDirectFBWindow *QDirectFBWindowSurface::directFBWindow() const return (dfbWindow ? dfbWindow : (sibling ? sibling->dfbWindow : 0)); } - void QDirectFBWindowSurface::createWindow(const QRect &rect) { IDirectFBDisplayLayer *layer = screen->dfbDisplayLayer(); @@ -169,6 +168,9 @@ void QDirectFBWindowSurface::createWindow(const QRect &rect) DirectFBErrorFatal("QDirectFBWindowSurface::createWindow", result); if (window()) { + if (window()->windowFlags() & Qt::WindowStaysOnTopHint) { + dfbWindow->SetStackingClass(dfbWindow, DWSC_UPPER); + } DFBWindowID winid; result = dfbWindow->GetID(dfbWindow, &winid); if (result != DFB_OK) { -- cgit v0.12 From 941c6637a83f765c028f40973bb7bcca0ecbafb5 Mon Sep 17 00:00:00 2001 From: Anders Bakken Date: Tue, 8 Dec 2009 08:19:58 -0800 Subject: Enable customizing of DirectFB layer to use This patch enables you to use a different layer for Qt apps by specifying: E.g. QWS_DISPLAY=directfb:layerid=2 Reviewed-by: Donald Carr --- src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp index 4cb0184..d3fe183 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp +++ b/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp @@ -1259,11 +1259,14 @@ bool QDirectFBScreen::connect(const QString &displaySpec) setIntOption(displayArgs, QLatin1String("height"), &h); #ifndef QT_NO_DIRECTFB_LAYER - result = d_ptr->dfb->GetDisplayLayer(d_ptr->dfb, DLID_PRIMARY, + int layerId = DLID_PRIMARY; + setIntOption(displayArgs, QLatin1String("layerid"), &layerId); + + result = d_ptr->dfb->GetDisplayLayer(d_ptr->dfb, static_cast(layerId), &d_ptr->dfbLayer); if (result != DFB_OK) { DirectFBError("QDirectFBScreen::connect: " - "Unable to get primary display layer!", result); + "Unable to get display layer!", result); return false; } result = d_ptr->dfbLayer->GetScreen(d_ptr->dfbLayer, &d_ptr->dfbScreen); -- cgit v0.12 From 9c32e6f919704a50fbb5f46541b16fb712c24c4c Mon Sep 17 00:00:00 2001 From: Anders Bakken Date: Tue, 1 Dec 2009 12:09:24 -0800 Subject: Clean up debug message with DirectFB Remove some superfluous spaces. Reviewed-by: Donald Carr --- .../gfxdrivers/directfb/qdirectfbscreen.cpp | 58 +++++++++++----------- 1 file changed, 29 insertions(+), 29 deletions(-) diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp index d3fe183..4744eb6 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp +++ b/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp @@ -958,47 +958,47 @@ struct FlagDescription { }; static const FlagDescription accelerationDescriptions[] = { - { " DFXL_NONE ", DFXL_NONE }, - { " DFXL_FILLRECTANGLE", DFXL_FILLRECTANGLE }, - { " DFXL_DRAWRECTANGLE", DFXL_DRAWRECTANGLE }, - { " DFXL_DRAWLINE", DFXL_DRAWLINE }, - { " DFXL_FILLTRIANGLE", DFXL_FILLTRIANGLE }, - { " DFXL_BLIT", DFXL_BLIT }, - { " DFXL_STRETCHBLIT", DFXL_STRETCHBLIT }, - { " DFXL_TEXTRIANGLES", DFXL_TEXTRIANGLES }, - { " DFXL_DRAWSTRING", DFXL_DRAWSTRING }, + { "DFXL_NONE", DFXL_NONE }, + { "DFXL_FILLRECTANGLE", DFXL_FILLRECTANGLE }, + { "DFXL_DRAWRECTANGLE", DFXL_DRAWRECTANGLE }, + { "DFXL_DRAWLINE", DFXL_DRAWLINE }, + { "DFXL_FILLTRIANGLE", DFXL_FILLTRIANGLE }, + { "DFXL_BLIT", DFXL_BLIT }, + { "DFXL_STRETCHBLIT", DFXL_STRETCHBLIT }, + { "DFXL_TEXTRIANGLES", DFXL_TEXTRIANGLES }, + { "DFXL_DRAWSTRING", DFXL_DRAWSTRING }, { 0, 0 } }; static const FlagDescription blitDescriptions[] = { - { " DSBLIT_NOFX", DSBLIT_NOFX }, - { " DSBLIT_BLEND_ALPHACHANNEL", DSBLIT_BLEND_ALPHACHANNEL }, - { " DSBLIT_BLEND_COLORALPHA", DSBLIT_BLEND_COLORALPHA }, - { " DSBLIT_COLORIZE", DSBLIT_COLORIZE }, - { " DSBLIT_SRC_COLORKEY", DSBLIT_SRC_COLORKEY }, - { " DSBLIT_DST_COLORKEY", DSBLIT_DST_COLORKEY }, - { " DSBLIT_SRC_PREMULTIPLY", DSBLIT_SRC_PREMULTIPLY }, - { " DSBLIT_DST_PREMULTIPLY", DSBLIT_DST_PREMULTIPLY }, - { " DSBLIT_DEMULTIPLY", DSBLIT_DEMULTIPLY }, - { " DSBLIT_DEINTERLACE", DSBLIT_DEINTERLACE }, + { "DSBLIT_NOFX", DSBLIT_NOFX }, + { "DSBLIT_BLEND_ALPHACHANNEL", DSBLIT_BLEND_ALPHACHANNEL }, + { "DSBLIT_BLEND_COLORALPHA", DSBLIT_BLEND_COLORALPHA }, + { "DSBLIT_COLORIZE", DSBLIT_COLORIZE }, + { "DSBLIT_SRC_COLORKEY", DSBLIT_SRC_COLORKEY }, + { "DSBLIT_DST_COLORKEY", DSBLIT_DST_COLORKEY }, + { "DSBLIT_SRC_PREMULTIPLY", DSBLIT_SRC_PREMULTIPLY }, + { "DSBLIT_DST_PREMULTIPLY", DSBLIT_DST_PREMULTIPLY }, + { "DSBLIT_DEMULTIPLY", DSBLIT_DEMULTIPLY }, + { "DSBLIT_DEINTERLACE", DSBLIT_DEINTERLACE }, #if (Q_DIRECTFB_VERSION >= 0x000923) - { " DSBLIT_SRC_PREMULTCOLOR", DSBLIT_SRC_PREMULTCOLOR }, - { " DSBLIT_XOR", DSBLIT_XOR }, + { "DSBLIT_SRC_PREMULTCOLOR", DSBLIT_SRC_PREMULTCOLOR }, + { "DSBLIT_XOR", DSBLIT_XOR }, #endif #if (Q_DIRECTFB_VERSION >= 0x010000) - { " DSBLIT_INDEX_TRANSLATION", DSBLIT_INDEX_TRANSLATION }, + { "DSBLIT_INDEX_TRANSLATION", DSBLIT_INDEX_TRANSLATION }, #endif { 0, 0 } }; static const FlagDescription drawDescriptions[] = { - { " DSDRAW_NOFX", DSDRAW_NOFX }, - { " DSDRAW_BLEND", DSDRAW_BLEND }, - { " DSDRAW_DST_COLORKEY", DSDRAW_DST_COLORKEY }, - { " DSDRAW_SRC_PREMULTIPLY", DSDRAW_SRC_PREMULTIPLY }, - { " DSDRAW_DST_PREMULTIPLY", DSDRAW_DST_PREMULTIPLY }, - { " DSDRAW_DEMULTIPLY", DSDRAW_DEMULTIPLY }, - { " DSDRAW_XOR", DSDRAW_XOR }, + { "DSDRAW_NOFX", DSDRAW_NOFX }, + { "DSDRAW_BLEND", DSDRAW_BLEND }, + { "DSDRAW_DST_COLORKEY", DSDRAW_DST_COLORKEY }, + { "DSDRAW_SRC_PREMULTIPLY", DSDRAW_SRC_PREMULTIPLY }, + { "DSDRAW_DST_PREMULTIPLY", DSDRAW_DST_PREMULTIPLY }, + { "DSDRAW_DEMULTIPLY", DSDRAW_DEMULTIPLY }, + { "DSDRAW_XOR", DSDRAW_XOR }, { 0, 0 } }; #endif -- cgit v0.12 From d5d39f04c2c473401e9147d57d5a7c62f6111656 Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Tue, 8 Dec 2009 12:15:19 +0100 Subject: Fix regression in qVariantFromValue when converting from complex type to simple type QVariant v = QColor(Qt::red); v.setValue(1000); Would produce a variant with garbage. the destructor of QColor would not be called, and the 1000 would be in the QVariant::PrivateShared, while most of the QVariant code assume that numbers are dirrectly in the QVariant::Data union Task-number: QTBUG-6602 Reviewed-by: Thierry --- src/corelib/kernel/qvariant.h | 2 +- tests/auto/qvariant/tst_qvariant.cpp | 17 +++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/src/corelib/kernel/qvariant.h b/src/corelib/kernel/qvariant.h index 3c10788..74ff17f 100644 --- a/src/corelib/kernel/qvariant.h +++ b/src/corelib/kernel/qvariant.h @@ -458,7 +458,7 @@ inline void qVariantSetValue(QVariant &v, const T &t) //if possible we reuse the current QVariant private const uint type = qMetaTypeId(reinterpret_cast(0)); QVariant::Private &d = v.data_ptr(); - if (v.isDetached() && (type <= uint(QVariant::Char) || type == d.type)) { + if (v.isDetached() && (type == d.type || (type <= uint(QVariant::Char) && d.type <= uint(QVariant::Char)))) { d.type = type; d.is_null = false; T *old = reinterpret_cast(d.is_shared ? d.data.shared->ptr : &d.data.ptr); diff --git a/tests/auto/qvariant/tst_qvariant.cpp b/tests/auto/qvariant/tst_qvariant.cpp index 3d68a73..ae0131c 100644 --- a/tests/auto/qvariant/tst_qvariant.cpp +++ b/tests/auto/qvariant/tst_qvariant.cpp @@ -272,6 +272,8 @@ private slots: void numericalConvert(); void moreCustomTypes(); void variantInVariant(); + + void colorInteger(); }; Q_DECLARE_METATYPE(QDate) @@ -3388,5 +3390,20 @@ void tst_QVariant::variantInVariant() QCOMPARE(qvariant_cast(var9), var1); } +void tst_QVariant::colorInteger() +{ + QVariant v = QColor(Qt::red); + QCOMPARE(v.type(), QVariant::Color); + QCOMPARE(v.value(), QColor(Qt::red)); + + v.setValue(1000); + QCOMPARE(v.type(), QVariant::Int); + QCOMPARE(v.toInt(), 1000); + + v.setValue(QColor(Qt::yellow)); + QCOMPARE(v.type(), QVariant::Color); + QCOMPARE(v.value(), QColor(Qt::yellow)); +} + QTEST_MAIN(tst_QVariant) #include "tst_qvariant.moc" -- cgit v0.12 From 934d4b9852060b2870f6774cd854331422147d3e Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Tue, 8 Dec 2009 10:50:01 +0100 Subject: Use 64bit for the connectedSignals as QML objects may have lots of signals Do not use quint64 as it would produce lots of useless padding on MSVC 32bit Reviewed-by: Brad --- src/corelib/kernel/qobject.cpp | 6 +++--- src/corelib/kernel/qobject_p.h | 11 ++++++----- tests/auto/qobject/tst_qobject.cpp | 8 ++++---- 3 files changed, 13 insertions(+), 12 deletions(-) diff --git a/src/corelib/kernel/qobject.cpp b/src/corelib/kernel/qobject.cpp index 30cd011..85915c2 100644 --- a/src/corelib/kernel/qobject.cpp +++ b/src/corelib/kernel/qobject.cpp @@ -145,7 +145,7 @@ QObjectPrivate::QObjectPrivate(int version) receiveChildEvents = true; postedEvents = 0; extraData = 0; - connectedSignals = 0; + connectedSignals[0] = connectedSignals[1] = 0; inEventHandler = false; inThreadChangeEvent = false; deleteWatch = 0; @@ -2924,9 +2924,9 @@ bool QMetaObjectPrivate::connect(const QObject *sender, int signal_index, QObjectPrivate *const sender_d = QObjectPrivate::get(s); if (signal_index < 0) { - sender_d->connectedSignals = ~ulong(0); + sender_d->connectedSignals[0] = sender_d->connectedSignals[1] = ~0; } else if (signal_index < (int)sizeof(sender_d->connectedSignals) * 8) { - sender_d->connectedSignals |= ulong(1) << signal_index; + sender_d->connectedSignals[signal_index >> 5] |= (1 << (signal_index & 0x1f)); } return true; diff --git a/src/corelib/kernel/qobject_p.h b/src/corelib/kernel/qobject_p.h index f899c78..d1841be 100644 --- a/src/corelib/kernel/qobject_p.h +++ b/src/corelib/kernel/qobject_p.h @@ -172,7 +172,7 @@ public: } int signalIndex(const char *signalName) const; - inline bool isSignalConnected(int signalIdx) const; + inline bool isSignalConnected(uint signalIdx) const; public: QString objectName; @@ -183,7 +183,7 @@ public: Connection *senders; // linked list of connections connected to this object Sender *currentSender; // object currently activating the object - mutable ulong connectedSignals; + mutable quint32 connectedSignals[2]; #ifdef QT3_SUPPORT QList pendingChildInsertedEvents; @@ -205,6 +205,7 @@ public: int *deleteWatch; }; + /*! \internal Returns true if the signal with index \a signal_index from object \a sender is connected. @@ -213,12 +214,12 @@ public: \a signal_index must be the index returned by QObjectPrivate::signalIndex; */ -inline bool QObjectPrivate::isSignalConnected(int signal_index) const +inline bool QObjectPrivate::isSignalConnected(uint signal_index) const { - return signal_index >= (int)sizeof(connectedSignals) * 8 + return signal_index >= sizeof(connectedSignals) * 8 || qt_signal_spy_callback_set.signal_begin_callback || qt_signal_spy_callback_set.signal_end_callback - || (connectedSignals & (ulong(1) << signal_index)); + || (connectedSignals[signal_index >> 5] & (1 << (signal_index & 0x1f))); } diff --git a/tests/auto/qobject/tst_qobject.cpp b/tests/auto/qobject/tst_qobject.cpp index 67a9c46..a2524aa 100644 --- a/tests/auto/qobject/tst_qobject.cpp +++ b/tests/auto/qobject/tst_qobject.cpp @@ -3058,10 +3058,8 @@ void tst_QObject::isSignalConnected() QVERIFY(!priv->isSignalConnected(priv->signalIndex("sig05()"))); QVERIFY(!priv->isSignalConnected(priv->signalIndex("sig15()"))); QVERIFY(!priv->isSignalConnected(priv->signalIndex("sig29()"))); - if (sizeof(void *) >= 8) { //on 32bit isSignalConnected only works with the first 32 signals - QVERIFY(!priv->isSignalConnected(priv->signalIndex("sig60()"))); - QVERIFY(!priv->isSignalConnected(priv->signalIndex("sig61()"))); - } + QVERIFY(!priv->isSignalConnected(priv->signalIndex("sig60()"))); + QVERIFY(!priv->isSignalConnected(priv->signalIndex("sig61()"))); #endif QObject::connect(&o, SIGNAL(sig00()), &o, SIGNAL(sig69())); @@ -3115,6 +3113,8 @@ void tst_QObject::isSignalConnected() QVERIFY(!priv->isSignalConnected(priv->signalIndex("sig04()"))); QVERIFY(!priv->isSignalConnected(priv->signalIndex("sig21()"))); QVERIFY(!priv->isSignalConnected(priv->signalIndex("sig25()"))); + QVERIFY(!priv->isSignalConnected(priv->signalIndex("sig55()"))); + QVERIFY(!priv->isSignalConnected(priv->signalIndex("sig61()"))); #endif emit o.sig00(); -- cgit v0.12 From bc4077223affd542f5fb24e27a065b7999229654 Mon Sep 17 00:00:00 2001 From: Robert Griebl Date: Wed, 9 Dec 2009 11:27:58 +0100 Subject: Mixed up top/bottom Reviewed-by: trustme --- src/gui/styles/qgtkstyle.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/styles/qgtkstyle.cpp b/src/gui/styles/qgtkstyle.cpp index 097a2b5..e10bb41 100644 --- a/src/gui/styles/qgtkstyle.cpp +++ b/src/gui/styles/qgtkstyle.cpp @@ -3389,7 +3389,7 @@ QRect QGtkStyle::subElementRect(SubElement element, const QStyleOption *option, GtkBorder *border = 0; d->gtk_widget_style_get(gtkButton, "inner-border", &border, NULL); if (border) { - r = option->rect.adjusted(border->left, border->top, -border->right, -border->top); + r = option->rect.adjusted(border->left, border->top, -border->right, -border->bottom); d->gtk_border_free(border); } else { r = option->rect.adjusted(1, 1, -1, -1); -- cgit v0.12 From 6744e241ee41a50b02a76e3e755ec448676589a4 Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Wed, 9 Dec 2009 13:21:23 +0100 Subject: Compile with QT_NO_DEPRECATED MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit uses of QT_DEPRECATED must be protected by #ifdef Task-number: QTBUG-6649 Reviewed-by: João Abecasis --- src/corelib/tools/qregexp.h | 2 ++ src/gui/embedded/qscreen_qws.h | 2 ++ src/gui/image/qimage.h | 6 ++++++ src/gui/image/qpixmap.h | 2 ++ src/gui/painting/qmatrix.h | 2 ++ src/gui/painting/qpaintdevice.h | 2 ++ src/gui/painting/qregion.h | 2 ++ src/gui/widgets/qlcdnumber.h | 3 ++- src/gui/widgets/qprintpreviewwidget.h | 2 ++ tools/assistant/lib/qhelpsearchengine.h | 2 ++ 10 files changed, 24 insertions(+), 1 deletion(-) diff --git a/src/corelib/tools/qregexp.h b/src/corelib/tools/qregexp.h index 2bad40e..8a46b98 100644 --- a/src/corelib/tools/qregexp.h +++ b/src/corelib/tools/qregexp.h @@ -119,7 +119,9 @@ public: #endif int matchedLength() const; #ifndef QT_NO_REGEXP_CAPTURE +#ifdef QT_DEPRECATED QT_DEPRECATED int numCaptures() const; +#endif int captureCount() const; QStringList capturedTexts() const; QStringList capturedTexts(); diff --git a/src/gui/embedded/qscreen_qws.h b/src/gui/embedded/qscreen_qws.h index b3246f9..7ab49fb 100644 --- a/src/gui/embedded/qscreen_qws.h +++ b/src/gui/embedded/qscreen_qws.h @@ -243,7 +243,9 @@ public: int totalSize() const { return mapsize; } QRgb * clut() { return screenclut; } +#ifdef QT_DEPRECATED QT_DEPRECATED int numCols() { return screencols; } +#endif int colorCount() { return screencols; } virtual QSize mapToDevice(const QSize &) const; diff --git a/src/gui/image/qimage.h b/src/gui/image/qimage.h index d8809ef..ce7f450 100644 --- a/src/gui/image/qimage.h +++ b/src/gui/image/qimage.h @@ -165,12 +165,16 @@ public: QRect rect() const; int depth() const; +#ifdef QT_DEPRECATED QT_DEPRECATED int numColors() const; +#endif int colorCount() const; QRgb color(int i) const; void setColor(int i, QRgb c); +#ifdef QT_DEPRECATED QT_DEPRECATED void setNumColors(int); +#endif void setColorCount(int); bool allGray() const; @@ -178,7 +182,9 @@ public: uchar *bits(); const uchar *bits() const; +#ifdef QT_DEPRECATED QT_DEPRECATED int numBytes() const; +#endif int byteCount() const; uchar *scanLine(int); diff --git a/src/gui/image/qpixmap.h b/src/gui/image/qpixmap.h index d95b4ee..e02b0d6 100644 --- a/src/gui/image/qpixmap.h +++ b/src/gui/image/qpixmap.h @@ -185,7 +185,9 @@ public: const uchar *qwsBits() const; int qwsBytesPerLine() const; QRgb *clut() const; +#ifdef QT_DEPRECATED QT_DEPRECATED int numCols() const; +#endif int colorCount() const; #elif defined(Q_WS_MAC) Qt::HANDLE macQDHandle() const; diff --git a/src/gui/painting/qmatrix.h b/src/gui/painting/qmatrix.h index 152b3c9..af48bcb 100644 --- a/src/gui/painting/qmatrix.h +++ b/src/gui/painting/qmatrix.h @@ -102,7 +102,9 @@ public: bool isInvertible() const { return !qFuzzyIsNull(_m11*_m22 - _m12*_m21); } qreal determinant() const { return _m11*_m22 - _m12*_m21; } +#ifdef QT_DEPRECATED QT_DEPRECATED qreal det() const { return _m11*_m22 - _m12*_m21; } +#endif QMatrix inverted(bool *invertible = 0) const; diff --git a/src/gui/painting/qpaintdevice.h b/src/gui/painting/qpaintdevice.h index 9148e4b..0f8191e 100644 --- a/src/gui/painting/qpaintdevice.h +++ b/src/gui/painting/qpaintdevice.h @@ -96,7 +96,9 @@ public: int logicalDpiY() const { return metric(PdmDpiY); } int physicalDpiX() const { return metric(PdmPhysicalDpiX); } int physicalDpiY() const { return metric(PdmPhysicalDpiY); } +#ifdef QT_DEPRECATED QT_DEPRECATED int numColors() const { return metric(PdmNumColors); } +#endif int colorCount() const { return metric(PdmNumColors); } int depth() const { return metric(PdmDepth); } diff --git a/src/gui/painting/qregion.h b/src/gui/painting/qregion.h index 2a1be86..f99fbf6 100644 --- a/src/gui/painting/qregion.h +++ b/src/gui/painting/qregion.h @@ -116,7 +116,9 @@ public: QRect boundingRect() const; QVector rects() const; void setRects(const QRect *rect, int num); +#ifdef QT_DEPRECATED QT_DEPRECATED int numRects() const; +#endif int rectCount() const; const QRegion operator|(const QRegion &r) const; diff --git a/src/gui/widgets/qlcdnumber.h b/src/gui/widgets/qlcdnumber.h index e65637d..b7162cd 100644 --- a/src/gui/widgets/qlcdnumber.h +++ b/src/gui/widgets/qlcdnumber.h @@ -82,9 +82,10 @@ public: }; bool smallDecimalPoint() const; - +#ifdef QT_DEPRECATED QT_DEPRECATED int numDigits() const; QT_DEPRECATED void setNumDigits(int nDigits); +#endif int digitCount() const; void setDigitCount(int nDigits); diff --git a/src/gui/widgets/qprintpreviewwidget.h b/src/gui/widgets/qprintpreviewwidget.h index 08e596d..d8504de 100644 --- a/src/gui/widgets/qprintpreviewwidget.h +++ b/src/gui/widgets/qprintpreviewwidget.h @@ -82,7 +82,9 @@ public: ViewMode viewMode() const; ZoomMode zoomMode() const; int currentPage() const; +#ifdef QT_DEPRECATED QT_DEPRECATED int numPages() const; +#endif int pageCount() const; void setVisible(bool visible); diff --git a/tools/assistant/lib/qhelpsearchengine.h b/tools/assistant/lib/qhelpsearchengine.h index 21f04c5..632ac0b 100644 --- a/tools/assistant/lib/qhelpsearchengine.h +++ b/tools/assistant/lib/qhelpsearchengine.h @@ -86,7 +86,9 @@ public: QHelpSearchQueryWidget* queryWidget(); QHelpSearchResultWidget* resultWidget(); +#ifdef QT_DEPRECATED QT_DEPRECATED int hitsCount() const; +#endif int hitCount() const; typedef QPair SearchHit; -- cgit v0.12 From c4d66e27ea69b84bf280209fc72239132924930d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Trond=20Kjern=C3=A5sen?= Date: Wed, 9 Dec 2009 12:14:58 +0100 Subject: GLES 2 should *not* use a multisampled format by default. This is a platform regression and should never have been there in the first place. Having this as the default format on embedded devices may drop the framerates with as much as 30% on selected HW. Reviewed-by: Tom Cooksey --- src/opengl/qgl.cpp | 3 +-- src/opengl/qgl_p.h | 3 --- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/src/opengl/qgl.cpp b/src/opengl/qgl.cpp index 25285b5..dcf8c00 100644 --- a/src/opengl/qgl.cpp +++ b/src/opengl/qgl.cpp @@ -397,8 +397,7 @@ static inline GLint qgluProject(GLdouble objx, GLdouble objy, GLdouble objz, \i \link setDirectRendering() Direct rendering:\endlink Enabled. \i \link setOverlay() Overlay:\endlink Disabled. \i \link setPlane() Plane:\endlink 0 (i.e., normal plane). - \i \link setSampleBuffers() Multisample buffers:\endlink Enabled on - OpenGL/ES 2.0, disabled on other platforms. + \i \link setSampleBuffers() Multisample buffers:\endlink Disabled. \endlist */ diff --git a/src/opengl/qgl_p.h b/src/opengl/qgl_p.h index 615fb60..8a0b31f 100644 --- a/src/opengl/qgl_p.h +++ b/src/opengl/qgl_p.h @@ -133,9 +133,6 @@ public: : ref(1) { opts = QGL::DoubleBuffer | QGL::DepthBuffer | QGL::Rgba | QGL::DirectRendering | QGL::StencilBuffer; -#if defined(QT_OPENGL_ES_2) - opts |= QGL::SampleBuffers; -#endif pln = 0; depthSize = accumSize = stencilSize = redSize = greenSize = blueSize = alphaSize = -1; numSamples = -1; -- cgit v0.12 From 7fecd890ce50d86120566acc7e71fcac915a671f Mon Sep 17 00:00:00 2001 From: Thierry Bastian Date: Wed, 9 Dec 2009 14:19:33 +0100 Subject: Fixed a regression in dock widget resizing It could happen that they grow much more than the movement of the mouse Task-number: QTBUG-6499 Reviewed-by: gabi --- src/gui/widgets/qdockarealayout.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gui/widgets/qdockarealayout.cpp b/src/gui/widgets/qdockarealayout.cpp index 0a26a77..cf82da0 100644 --- a/src/gui/widgets/qdockarealayout.cpp +++ b/src/gui/widgets/qdockarealayout.cpp @@ -1303,9 +1303,9 @@ QDockAreaLayoutInfo *QDockAreaLayoutInfo::info(const QList &path) index = -index - 1; if (index >= item_list.count()) return this; - if (path.count() == 1 || item_list.at(index).subinfo == 0) + if (path.count() == 1 || item_list[index].subinfo == 0) return this; - return item_list.at(index).subinfo->info(path.mid(1)); + return item_list[index].subinfo->info(path.mid(1)); } QRect QDockAreaLayoutInfo::itemRect(int index) const -- cgit v0.12 From bdb485519d957bb551d5eeae8a866df45a59c647 Mon Sep 17 00:00:00 2001 From: Denis Dzyubenko Date: Wed, 9 Dec 2009 14:35:32 +0100 Subject: Use realpath() only on systems we know it works on. We use realpath(X,0) extension that is defined by the latest POSIX standard and not many systems support it at the moment. For now we limit it to Linux and Symbian. Mac supports it starting with 10.6, and we'll implement it properly for Mac in 4.7. We know that neither *BSD systems nor Solaris do not support it. Reviewed-by: Markus Goetz --- src/corelib/io/qfsfileengine.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/corelib/io/qfsfileengine.cpp b/src/corelib/io/qfsfileengine.cpp index 37b0ea1..e4c4e3f 100644 --- a/src/corelib/io/qfsfileengine.cpp +++ b/src/corelib/io/qfsfileengine.cpp @@ -144,7 +144,7 @@ QString QFSFileEnginePrivate::canonicalized(const QString &path) return path; #endif // Mac OS X 10.5.x doesn't support the realpath(X,0) extenstion we use here. -#if (defined(Q_OS_UNIX) && !defined(Q_OS_MAC)) || defined(Q_OS_SYMBIAN) +#if defined(Q_OS_LINIX) || defined(Q_OS_SYMBIAN) char *ret = realpath(path.toLocal8Bit().constData(), (char*)0); if (ret) { QString canonicalPath = QDir::cleanPath(QString::fromLocal8Bit(ret)); -- cgit v0.12 From 9f3cde38bffb79da82d6248a873a687d37177954 Mon Sep 17 00:00:00 2001 From: Gunnar Sletta Date: Wed, 9 Dec 2009 14:49:15 +0100 Subject: Don't assert on valid math in qbezier --- src/gui/painting/qbezier_p.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/gui/painting/qbezier_p.h b/src/gui/painting/qbezier_p.h index 7dbd0c2..c284871 100644 --- a/src/gui/painting/qbezier_p.h +++ b/src/gui/painting/qbezier_p.h @@ -166,8 +166,6 @@ inline void QBezier::coefficients(qreal t, qreal &a, qreal &b, qreal &c, qreal & inline QPointF QBezier::pointAt(qreal t) const { - Q_ASSERT(t >= 0); - Q_ASSERT(t <= 1); #if 1 qreal a, b, c, d; coefficients(t, a, b, c, d); -- cgit v0.12 From 0c30418556d978f730c33aa3bb066961981ccc9b Mon Sep 17 00:00:00 2001 From: Gunnar Sletta Date: Wed, 9 Dec 2009 15:15:35 +0100 Subject: Fix crash when rotating cleartype text under gl engine. Reviewed-by: Eskil --- src/gui/painting/qtextureglyphcache_p.h | 5 +---- src/gui/text/qfontengine.cpp | 10 ++++++---- src/gui/text/qfontengine_p.h | 4 ++-- src/gui/text/qfontengineglyphcache_p.h | 7 +++++-- src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp | 4 ++-- 5 files changed, 16 insertions(+), 14 deletions(-) diff --git a/src/gui/painting/qtextureglyphcache_p.h b/src/gui/painting/qtextureglyphcache_p.h index 57473d1..bb0c630 100644 --- a/src/gui/painting/qtextureglyphcache_p.h +++ b/src/gui/painting/qtextureglyphcache_p.h @@ -76,7 +76,7 @@ class Q_GUI_EXPORT QTextureGlyphCache : public QFontEngineGlyphCache { public: QTextureGlyphCache(QFontEngineGlyphCache::Type type, const QTransform &matrix) - : QFontEngineGlyphCache(matrix), m_w(0), m_h(0), m_cx(0), m_cy(0), m_type(type) { } + : QFontEngineGlyphCache(matrix, type), m_w(0), m_h(0), m_cx(0), m_cy(0) { } virtual ~QTextureGlyphCache() { } @@ -98,8 +98,6 @@ public: virtual void resizeTextureData(int width, int height) = 0; virtual int glyphMargin() const { return 0; } - QFontEngineGlyphCache::Type cacheType() const { return m_type; } - virtual void fillTexture(const Coord &coord, glyph_t glyph) = 0; inline void createCache(int width, int height) { @@ -121,7 +119,6 @@ protected: int m_h; // image height int m_cx; // current x int m_cy; // current y - QFontEngineGlyphCache::Type m_type; }; diff --git a/src/gui/text/qfontengine.cpp b/src/gui/text/qfontengine.cpp index 27fc3c1..0eadf04 100644 --- a/src/gui/text/qfontengine.cpp +++ b/src/gui/text/qfontengine.cpp @@ -742,14 +742,15 @@ void QFontEngine::expireGlyphCache() } } -void QFontEngine::setGlyphCache(void *key, QFontEngineGlyphCache *data) +void QFontEngine::setGlyphCache(void *key, QFontEngineGlyphCache *data, QFontEngineGlyphCache::Type type) { Q_ASSERT(data); QList items = m_glyphPointerHash.value(key); for (QList::iterator it = items.begin(), end = items.end(); it != end; ++it) { QFontEngineGlyphCache *c = *it; - if (qtransform_equals_no_translate(c->m_transform, data->m_transform)) { + if (qtransform_equals_no_translate(c->m_transform, data->m_transform) + && c->cacheType() == type) { if (c == data) return; items.removeAll(c); @@ -786,13 +787,14 @@ void QFontEngine::setGlyphCache(QFontEngineGlyphCache::Type key, QFontEngineGlyp expireGlyphCache(); } -QFontEngineGlyphCache *QFontEngine::glyphCache(void *key, const QTransform &transform) const +QFontEngineGlyphCache *QFontEngine::glyphCache(void *key, const QTransform &transform, QFontEngineGlyphCache::Type type) const { QList items = m_glyphPointerHash.value(key); for (QList::iterator it = items.begin(), end = items.end(); it != end; ++it) { QFontEngineGlyphCache *c = *it; - if (qtransform_equals_no_translate(c->m_transform, transform)) { + if (qtransform_equals_no_translate(c->m_transform, transform) + && type == c->cacheType()) { m_glyphCacheQueue.removeAll(c); // last used, move it up m_glyphCacheQueue.append(c); return c; diff --git a/src/gui/text/qfontengine_p.h b/src/gui/text/qfontengine_p.h index 728c344..62bff85 100644 --- a/src/gui/text/qfontengine_p.h +++ b/src/gui/text/qfontengine_p.h @@ -218,9 +218,9 @@ public: virtual HB_Error getPointInOutline(HB_Glyph glyph, int flags, hb_uint32 point, HB_Fixed *xpos, HB_Fixed *ypos, hb_uint32 *nPoints); - void setGlyphCache(void *key, QFontEngineGlyphCache *data); + void setGlyphCache(void *key, QFontEngineGlyphCache *data, QFontEngineGlyphCache::Type type); void setGlyphCache(QFontEngineGlyphCache::Type key, QFontEngineGlyphCache *data); - QFontEngineGlyphCache *glyphCache(void *key, const QTransform &transform) const; + QFontEngineGlyphCache *glyphCache(void *key, const QTransform &transform, QFontEngineGlyphCache::Type type) const; QFontEngineGlyphCache *glyphCache(QFontEngineGlyphCache::Type key, const QTransform &transform) const; static const uchar *getCMap(const uchar *table, uint tableSize, bool *isSymbolFont, int *cmapSize); diff --git a/src/gui/text/qfontengineglyphcache_p.h b/src/gui/text/qfontengineglyphcache_p.h index e04f4ac..c6112ba 100644 --- a/src/gui/text/qfontengineglyphcache_p.h +++ b/src/gui/text/qfontengineglyphcache_p.h @@ -75,17 +75,20 @@ QT_BEGIN_NAMESPACE class QFontEngineGlyphCache { public: - QFontEngineGlyphCache(const QTransform &matrix) : m_transform(matrix) { } - enum Type { Raster_RGBMask, Raster_A8, Raster_Mono }; + QFontEngineGlyphCache(const QTransform &matrix, Type type) : m_transform(matrix), m_type(type) { } + virtual ~QFontEngineGlyphCache() { } + Type cacheType() const { return m_type; } + QTransform m_transform; + QFontEngineGlyphCache::Type m_type; }; typedef QHash > GlyphPointerHash; typedef QHash > GlyphIntHash; diff --git a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp index 17af9cb..9f42217 100644 --- a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp +++ b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp @@ -1562,11 +1562,11 @@ void QGL2PaintEngineExPrivate::drawCachedGlyphs(const QPointF &p, QFontEngineGly ti.fontEngine->getGlyphPositions(ti.glyphs, matrix, ti.flags, glyphs, positions); QGLTextureGlyphCache *cache = - (QGLTextureGlyphCache *) ti.fontEngine->glyphCache(ctx, QTransform()); + (QGLTextureGlyphCache *) ti.fontEngine->glyphCache(ctx, QTransform(), glyphType); if (!cache || cache->cacheType() != glyphType) { cache = new QGLTextureGlyphCache(ctx, glyphType, QTransform()); - ti.fontEngine->setGlyphCache(ctx, cache); + ti.fontEngine->setGlyphCache(ctx, cache, glyphType); } cache->setPaintEnginePrivate(this); -- cgit v0.12 From 293db01f907ad8644e8242055521e6b8e7c4dfec Mon Sep 17 00:00:00 2001 From: Alexis Menard Date: Wed, 9 Dec 2009 16:07:13 +0100 Subject: Fix a crash on the focus chain when removing items from the scene. The crash was because of the dangling pointer set on the tabFocusFirst attribute in QGraphicsScene. A child which was the tabFocusFirst was removed from the scene and fixFocusChainBeforeReparenting was setting the new tabFocusFirst pointer to the parent (since in that example it was the focusNext) but later on the parent was removed also from the scene (due to the recursion of removeItem if you call it with the parent : first children, then the parent itself) and fixFocusChainBeforeReparenting was not called again so if you delete the parent then the scene has the dangling pointer set. Task-number:QTBUG-6544 Reviewed-by:janarve --- src/gui/graphicsview/qgraphicsscene.cpp | 11 ++++---- src/gui/graphicsview/qgraphicswidget.cpp | 2 +- src/gui/graphicsview/qgraphicswidget_p.cpp | 4 +-- src/gui/graphicsview/qgraphicswidget_p.h | 2 +- tests/auto/qgraphicswidget/tst_qgraphicswidget.cpp | 32 ++++++++++++++++++++++ 5 files changed, 42 insertions(+), 9 deletions(-) diff --git a/src/gui/graphicsview/qgraphicsscene.cpp b/src/gui/graphicsview/qgraphicsscene.cpp index 27ebb79..2af90b8 100644 --- a/src/gui/graphicsview/qgraphicsscene.cpp +++ b/src/gui/graphicsview/qgraphicsscene.cpp @@ -569,14 +569,10 @@ void QGraphicsScenePrivate::removeItemHelper(QGraphicsItem *item) item->d_ptr->clearSubFocus(); - if (!item->d_ptr->inDestructor && item == tabFocusFirst) { - QGraphicsWidget *widget = static_cast(item); - widget->d_func()->fixFocusChainBeforeReparenting(0, 0); - } - if (item->flags() & QGraphicsItem::ItemSendsScenePositionChanges) unregisterScenePosItem(item); + QGraphicsScene *oldScene = item->d_func()->scene; item->d_func()->scene = 0; //We need to remove all children first because they might use their parent @@ -587,6 +583,11 @@ void QGraphicsScenePrivate::removeItemHelper(QGraphicsItem *item) q->removeItem(item->d_ptr->children.at(i)); } + if (!item->d_ptr->inDestructor && item == tabFocusFirst) { + QGraphicsWidget *widget = static_cast(item); + widget->d_func()->fixFocusChainBeforeReparenting(0, oldScene, 0); + } + // Unregister focus proxy. item->d_ptr->resetFocusProxy(); diff --git a/src/gui/graphicsview/qgraphicswidget.cpp b/src/gui/graphicsview/qgraphicswidget.cpp index fe569f4..8de81c2 100644 --- a/src/gui/graphicsview/qgraphicswidget.cpp +++ b/src/gui/graphicsview/qgraphicswidget.cpp @@ -1054,7 +1054,7 @@ QVariant QGraphicsWidget::itemChange(GraphicsItemChange change, const QVariant & break; case ItemParentChange: { QGraphicsItem *parent = qVariantValue(value); - d->fixFocusChainBeforeReparenting((parent && parent->isWidget()) ? static_cast(parent) : 0); + d->fixFocusChainBeforeReparenting((parent && parent->isWidget()) ? static_cast(parent) : 0, scene()); // Deliver ParentAboutToChange. QEvent event(QEvent::ParentAboutToChange); diff --git a/src/gui/graphicsview/qgraphicswidget_p.cpp b/src/gui/graphicsview/qgraphicswidget_p.cpp index b747a30..5b6490f 100644 --- a/src/gui/graphicsview/qgraphicswidget_p.cpp +++ b/src/gui/graphicsview/qgraphicswidget_p.cpp @@ -743,7 +743,7 @@ bool QGraphicsWidgetPrivate::hasDecoration() const /** * is called after a reparent has taken place to fix up the focus chain(s) */ -void QGraphicsWidgetPrivate::fixFocusChainBeforeReparenting(QGraphicsWidget *newParent, QGraphicsScene *newScene) +void QGraphicsWidgetPrivate::fixFocusChainBeforeReparenting(QGraphicsWidget *newParent, QGraphicsScene *oldScene, QGraphicsScene *newScene) { Q_Q(QGraphicsWidget); @@ -789,7 +789,7 @@ void QGraphicsWidgetPrivate::fixFocusChainBeforeReparenting(QGraphicsWidget *new // update tabFocusFirst for oldScene if the item is going to be removed from oldScene if (newParent) newScene = newParent->scene(); - QGraphicsScene *oldScene = q->scene(); + if (oldScene && newScene != oldScene) oldScene->d_func()->tabFocusFirst = firstOld; diff --git a/src/gui/graphicsview/qgraphicswidget_p.h b/src/gui/graphicsview/qgraphicswidget_p.h index eb53649..65e6962 100644 --- a/src/gui/graphicsview/qgraphicswidget_p.h +++ b/src/gui/graphicsview/qgraphicswidget_p.h @@ -98,7 +98,7 @@ public: mutable qreal *margins; void ensureMargins() const; - void fixFocusChainBeforeReparenting(QGraphicsWidget *newParent, QGraphicsScene *newScene = 0); + void fixFocusChainBeforeReparenting(QGraphicsWidget *newParent, QGraphicsScene *oldScene, QGraphicsScene *newScene = 0); void setLayout_helper(QGraphicsLayout *l); // Layouts diff --git a/tests/auto/qgraphicswidget/tst_qgraphicswidget.cpp b/tests/auto/qgraphicswidget/tst_qgraphicswidget.cpp index 3303df5..a835259 100644 --- a/tests/auto/qgraphicswidget/tst_qgraphicswidget.cpp +++ b/tests/auto/qgraphicswidget/tst_qgraphicswidget.cpp @@ -168,6 +168,7 @@ private slots: void task236127_bspTreeIndexFails(); void task243004_setStyleCrash(); void task250119_shortcutContext(); + void QT_BUG_6544_tabFocusFirstUnsetWhenRemovingItems(); }; @@ -2855,6 +2856,37 @@ void tst_QGraphicsWidget::polishEvent2() QVERIFY(widget->events.contains(QEvent::Polish)); } +void tst_QGraphicsWidget::QT_BUG_6544_tabFocusFirstUnsetWhenRemovingItems() +{ + QGraphicsScene scene; + QGraphicsWidget* parent1 = new QGraphicsWidget; + QGraphicsWidget* child1_0 = new QGraphicsWidget; + QGraphicsWidget* child1_1 = new QGraphicsWidget; + + QGraphicsWidget* parent2 = new QGraphicsWidget; + + // Add the parent and child to the scene. + scene.addItem(parent1); + child1_0->setParentItem(parent1); + child1_1->setParentItem(parent1); + + // Hide and show the child. + child1_0->setParentItem(NULL); + scene.removeItem(child1_0); + + // Remove parent from the scene. + scene.removeItem(parent1); + + delete child1_0; + delete child1_1; + delete parent1; + + // Add an item into the scene. + scene.addItem(parent2); + + //This should not crash +} + QTEST_MAIN(tst_QGraphicsWidget) #include "tst_qgraphicswidget.moc" -- cgit v0.12 From 16de24d638deafb6e985b531fdf0c15691c0b7b4 Mon Sep 17 00:00:00 2001 From: Rhys Weatherley Date: Thu, 10 Dec 2009 09:28:04 +1000 Subject: Recreate VGImage properly in out of memory case If vgCreateImage() runs out of memory, then the drawPixmap() will fail. But previously, it would also prevent future attempts to call vgImageSubData() to populate the data when memory was present. Task-number: QTBUG-6639 Reviewed-by: Sarah Smith --- src/openvg/qpixmapdata_vg.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/openvg/qpixmapdata_vg.cpp b/src/openvg/qpixmapdata_vg.cpp index 5d5fcbf..af6f0f0 100644 --- a/src/openvg/qpixmapdata_vg.cpp +++ b/src/openvg/qpixmapdata_vg.cpp @@ -250,6 +250,10 @@ VGImage QVGPixmapData::toVGImage() if (vgImage == VG_INVALID_HANDLE) { vgImage = vgCreateImage (VG_sARGB_8888_PRE, w, h, VG_IMAGE_QUALITY_FASTER); + + // Bail out if we run out of GPU memory - try again next time. + if (vgImage == VG_INVALID_HANDLE) + return VG_INVALID_HANDLE; } if (!source.isNull() && recreate) { @@ -280,6 +284,10 @@ VGImage QVGPixmapData::toVGImage(qreal opacity) if (vgImageOpacity == VG_INVALID_HANDLE) { vgImageOpacity = vgCreateImage (VG_sARGB_8888_PRE, w, h, VG_IMAGE_QUALITY_FASTER); + + // Bail out if we run out of GPU memory - try again next time. + if (vgImageOpacity == VG_INVALID_HANDLE) + return VG_INVALID_HANDLE; } VGfloat matrix[20] = { 1.0f, 0.0f, 0.0f, 0.0f, -- cgit v0.12 From dd0ecf2c9abab285e14a398b3f901fbc69d48db1 Mon Sep 17 00:00:00 2001 From: Rohan McGovern Date: Thu, 10 Dec 2009 10:16:41 +1000 Subject: Put symbian-specific test inside symbian qmake scope. --- tests/auto/auto.pro | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tests/auto/auto.pro b/tests/auto/auto.pro index 92d29ae..361ae8f 100644 --- a/tests/auto/auto.pro +++ b/tests/auto/auto.pro @@ -442,7 +442,6 @@ SUBDIRS += \ qsharedmemory \ qsidebar \ qsizegrip \ - qsoftkeymanager \ qsqldriver \ qsystemsemaphore \ qtconcurrentfilter \ @@ -477,6 +476,10 @@ embedded:!wince* { SUBDIRS += qtextpiecetable } +symbian { + SUBDIRS += qsoftkeymanager +} + # Enable the tests specific to QtXmlPatterns. If you add a test, remember to # update runQtXmlPatternsTests.sh too. Remember that this file, auto.pro, is # not respected by some test system, they just have a script which loop over -- cgit v0.12 From 94d45cc06dabb8b1f8fc98e9f9b3dfaf49d0c4d7 Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Thu, 10 Dec 2009 14:21:25 +1000 Subject: Fix translation context for qsTr. Use the base of the file name as the translation context. (This was the original behavior before the switch to JSC.) Reviewed-by: Kent Hansen --- src/script/api/qscriptengine.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/script/api/qscriptengine.cpp b/src/script/api/qscriptengine.cpp index b6aa872..1879367 100644 --- a/src/script/api/qscriptengine.cpp +++ b/src/script/api/qscriptengine.cpp @@ -33,6 +33,7 @@ #include "qscriptvalue_p.h" #include "qscriptvalueiterator.h" #include "qscriptclass.h" +#include "qscriptcontextinfo.h" #include "qscriptprogram.h" #include "qscriptprogram_p.h" #include "qdebug.h" @@ -698,9 +699,9 @@ JSC::JSValue JSC_HOST_CALL functionQsTr(JSC::ExecState *exec, JSC::JSObject*, JS return JSC::throwError(exec, JSC::GeneralError, "qsTranslate(): third argument (n) must be a number"); #ifndef QT_NO_QOBJECT QString context; -// ### implement context resolution -// if (ctx->parentContext()) -// context = QFileInfo(ctx->parentContext()->fileName()).baseName(); + QScriptContext *ctx = QScriptEnginePrivate::contextForFrame(exec); + if (ctx && ctx->parentContext()) + context = QFileInfo(QScriptContextInfo(ctx->parentContext()).fileName()).baseName(); #endif QString text(args.at(0).toString(exec)); #ifndef QT_NO_QOBJECT -- cgit v0.12 From c73d4f8b55dbb79b7a2df38d167a7c5ffd4520ce Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Thu, 10 Dec 2009 10:04:36 +0100 Subject: Fix compilation: private headers must be #included with "" The reason is that the private headers don't exist in any of the -I lines, so they need to be found by the preprocessor relative to the source file, which means "". Task-number: QTBUG-6665 Reviewed-by: Trust Me --- src/dbus/qdbusargument_p.h | 2 +- src/dbus/qdbusconnection_p.h | 2 +- src/dbus/qdbusconnectioninterface.cpp | 2 +- src/dbus/qdbuserror.cpp | 2 +- src/dbus/qdbusintegrator_p.h | 2 +- src/dbus/qdbusinterface.cpp | 2 +- src/dbus/qdbusinterface_p.h | 4 ++-- src/dbus/qdbusinternalfilters.cpp | 2 +- src/dbus/qdbusmessage.cpp | 2 +- src/dbus/qdbusmetatype.cpp | 2 +- src/dbus/qdbusutil.cpp | 2 +- src/dbus/qdbusxmlparser_p.h | 2 +- 12 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/dbus/qdbusargument_p.h b/src/dbus/qdbusargument_p.h index 47c5e62..17302b4 100644 --- a/src/dbus/qdbusargument_p.h +++ b/src/dbus/qdbusargument_p.h @@ -54,7 +54,7 @@ // #include -#include +#include "qdbus_symbols_p.h" QT_BEGIN_NAMESPACE diff --git a/src/dbus/qdbusconnection_p.h b/src/dbus/qdbusconnection_p.h index b65e101..d6f7598 100644 --- a/src/dbus/qdbusconnection_p.h +++ b/src/dbus/qdbusconnection_p.h @@ -67,7 +67,7 @@ #include #include -#include +#include "qdbus_symbols_p.h" #include diff --git a/src/dbus/qdbusconnectioninterface.cpp b/src/dbus/qdbusconnectioninterface.cpp index 0f9a67f..ec61859 100644 --- a/src/dbus/qdbusconnectioninterface.cpp +++ b/src/dbus/qdbusconnectioninterface.cpp @@ -49,7 +49,7 @@ #include #include -#include // for the DBUS_* constants +#include "qdbus_symbols_p.h" // for the DBUS_* constants QT_BEGIN_NAMESPACE diff --git a/src/dbus/qdbuserror.cpp b/src/dbus/qdbuserror.cpp index 5c2fa2b..a48b878 100644 --- a/src/dbus/qdbuserror.cpp +++ b/src/dbus/qdbuserror.cpp @@ -44,7 +44,7 @@ #include #include -#include +#include "qdbus_symbols_p.h" #include "qdbusmessage.h" #include "qdbusmessage_p.h" diff --git a/src/dbus/qdbusintegrator_p.h b/src/dbus/qdbusintegrator_p.h index 5b18aca..85c6cb2 100644 --- a/src/dbus/qdbusintegrator_p.h +++ b/src/dbus/qdbusintegrator_p.h @@ -54,7 +54,7 @@ #ifndef QDBUSINTEGRATOR_P_H #define QDBUSINTEGRATOR_P_H -#include +#include "qdbus_symbols_p.h" #include "qcoreevent.h" #include "qeventloop.h" diff --git a/src/dbus/qdbusinterface.cpp b/src/dbus/qdbusinterface.cpp index d0a693f..c05e6a9 100644 --- a/src/dbus/qdbusinterface.cpp +++ b/src/dbus/qdbusinterface.cpp @@ -41,7 +41,7 @@ #include "qdbusinterface.h" -#include +#include "qdbus_symbols_p.h" #include #include diff --git a/src/dbus/qdbusinterface_p.h b/src/dbus/qdbusinterface_p.h index 3d11af1..a601608 100644 --- a/src/dbus/qdbusinterface_p.h +++ b/src/dbus/qdbusinterface_p.h @@ -54,8 +54,8 @@ #ifndef QDBUSINTERFACEPRIVATE_H #define QDBUSINTERFACEPRIVATE_H -#include -#include +#include "qdbusabstractinterface_p.h" +#include "qdbusmetaobject_p.h" #include QT_BEGIN_NAMESPACE diff --git a/src/dbus/qdbusinternalfilters.cpp b/src/dbus/qdbusinternalfilters.cpp index acd04d3..37110c5 100644 --- a/src/dbus/qdbusinternalfilters.cpp +++ b/src/dbus/qdbusinternalfilters.cpp @@ -41,7 +41,7 @@ #include "qdbusconnection_p.h" -#include +#include "qdbus_symbols_p.h" #include #include #include diff --git a/src/dbus/qdbusmessage.cpp b/src/dbus/qdbusmessage.cpp index 4f1950b..a37ba1f 100644 --- a/src/dbus/qdbusmessage.cpp +++ b/src/dbus/qdbusmessage.cpp @@ -44,7 +44,7 @@ #include #include -#include +#include "qdbus_symbols_p.h" #include "qdbusargument_p.h" #include "qdbuserror.h" diff --git a/src/dbus/qdbusmetatype.cpp b/src/dbus/qdbusmetatype.cpp index 237aea3..afa3bbf 100644 --- a/src/dbus/qdbusmetatype.cpp +++ b/src/dbus/qdbusmetatype.cpp @@ -42,7 +42,7 @@ #include "qdbusmetatype.h" #include -#include +#include "qdbus_symbols_p.h" #include #include diff --git a/src/dbus/qdbusutil.cpp b/src/dbus/qdbusutil.cpp index bf5a739..01b1dbd 100644 --- a/src/dbus/qdbusutil.cpp +++ b/src/dbus/qdbusutil.cpp @@ -41,7 +41,7 @@ #include "qdbusutil_p.h" -#include +#include "qdbus_symbols_p.h" #include diff --git a/src/dbus/qdbusxmlparser_p.h b/src/dbus/qdbusxmlparser_p.h index 3dbae1b..1a0523b 100644 --- a/src/dbus/qdbusxmlparser_p.h +++ b/src/dbus/qdbusxmlparser_p.h @@ -56,7 +56,7 @@ #include #include #include -#include +#include "qdbusintrospection_p.h" QT_BEGIN_NAMESPACE -- cgit v0.12 From 2705480b5cd740eee3ed684a26508b0497b00477 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan-Arve=20S=C3=A6ther?= Date: Thu, 10 Dec 2009 09:51:03 +0100 Subject: Doc: Try to explain better when and how the easing curve is applied Maybe not perfect, but it should be *better* at least. Task-number: QTBUG-6623 Reviewed-by: Thierry --- src/corelib/animation/qvariantanimation.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/corelib/animation/qvariantanimation.cpp b/src/corelib/animation/qvariantanimation.cpp index d529f67..bc0d35e 100644 --- a/src/corelib/animation/qvariantanimation.cpp +++ b/src/corelib/animation/qvariantanimation.cpp @@ -373,6 +373,13 @@ QVariantAnimation::~QVariantAnimation() Another example is QEasingCurve::InOutElastic, which provides an elastic effect on the values of the interpolated variant. + QVariantAnimation will use the QEasingCurve::valueForProgress() to + transform the "normalized progress" (currentTime / totalDuration) + of the animation into the effective progress actually + used by the animation. It is this effective progress that will be + the progress when interpolated() is called. Also, the steps in the + keyValues are referring to this effective progress. + The easing curve is used with the interpolator, the interpolated() virtual function, the animation's duration, and iterationCount, to control how the current value changes as the animation progresses. -- cgit v0.12 From f85306467b84cbc300d13aa52e0f5db4b1a2b1e6 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Thu, 10 Dec 2009 10:10:43 +0100 Subject: Fix compilation if QT_NO_DATESTRING is defined. If we have no string parsing in QDateTime, then we use sscanf, so we must include Task-number: QTBUG-6668 Reviewed-by: Markus Goetz --- src/network/access/qnetworkrequest.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/network/access/qnetworkrequest.cpp b/src/network/access/qnetworkrequest.cpp index c91c608..923f2e3 100644 --- a/src/network/access/qnetworkrequest.cpp +++ b/src/network/access/qnetworkrequest.cpp @@ -49,6 +49,9 @@ #include "QtCore/qdatetime.h" #include +#ifndef QT_NO_DATESTRING +# include +#endif QT_BEGIN_NAMESPACE -- cgit v0.12 From ba9ea2b97bdd2329cb479bb7a6aef1bc7cee82d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan-Arve=20S=C3=A6ther?= Date: Thu, 10 Dec 2009 10:26:06 +0100 Subject: Doc: The ctor of of QGraphicsLayout might install the layout. Task-number: QTBUG-6447 --- src/gui/graphicsview/qgraphicslayout.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/gui/graphicsview/qgraphicslayout.cpp b/src/gui/graphicsview/qgraphicslayout.cpp index 2e9a30c..1e426c8 100644 --- a/src/gui/graphicsview/qgraphicslayout.cpp +++ b/src/gui/graphicsview/qgraphicslayout.cpp @@ -148,6 +148,10 @@ QT_BEGIN_NAMESPACE \a parent is passed to QGraphicsLayoutItem's constructor and the QGraphicsLayoutItem's isLayout argument is set to \e true. + + If \a parent is a QGraphicsWidget the layout will be installed + on that widget. (Note that installing a layout will delete the old one + installed.) */ QGraphicsLayout::QGraphicsLayout(QGraphicsLayoutItem *parent) : QGraphicsLayoutItem(*new QGraphicsLayoutPrivate) -- cgit v0.12 From ab5d00edea76d3b1d38d6e7e59159042ec69f2f2 Mon Sep 17 00:00:00 2001 From: Gunnar Sletta Date: Thu, 10 Dec 2009 10:41:53 +0100 Subject: Clean up the QFontEngine glyphcaching code to not crash and be more tidy Reviewed-by: Eskil --- src/gui/painting/qpaintengine_raster.cpp | 4 +- src/gui/text/qfontengine.cpp | 124 ++++----------------- src/gui/text/qfontengine_p.h | 18 +-- .../gl2paintengineex/qpaintengineex_opengl2.cpp | 5 +- 4 files changed, 32 insertions(+), 119 deletions(-) diff --git a/src/gui/painting/qpaintengine_raster.cpp b/src/gui/painting/qpaintengine_raster.cpp index 4a72434..aa3b89e 100644 --- a/src/gui/painting/qpaintengine_raster.cpp +++ b/src/gui/painting/qpaintengine_raster.cpp @@ -3018,10 +3018,10 @@ void QRasterPaintEngine::drawCachedGlyphs(const QPointF &p, const QTextItemInt & QFontEngineGlyphCache::Type glyphType = ti.fontEngine->glyphFormat >= 0 ? QFontEngineGlyphCache::Type(ti.fontEngine->glyphFormat) : d->glyphCacheType; QImageTextureGlyphCache *cache = - (QImageTextureGlyphCache *) ti.fontEngine->glyphCache(glyphType, s->matrix); + (QImageTextureGlyphCache *) ti.fontEngine->glyphCache(0, glyphType, s->matrix); if (!cache) { cache = new QImageTextureGlyphCache(glyphType, s->matrix); - ti.fontEngine->setGlyphCache(glyphType, cache); + ti.fontEngine->setGlyphCache(0, cache); } cache->populate(ti, glyphs, positions); diff --git a/src/gui/text/qfontengine.cpp b/src/gui/text/qfontengine.cpp index 0eadf04..d364025 100644 --- a/src/gui/text/qfontengine.cpp +++ b/src/gui/text/qfontengine.cpp @@ -185,22 +185,11 @@ QFontEngine::QFontEngine() QFontEngine::~QFontEngine() { - for (GlyphPointerHash::const_iterator it = m_glyphPointerHash.constBegin(), - end = m_glyphPointerHash.constEnd(); it != end; ++it) { - for (QList::const_iterator it2 = it.value().constBegin(), - end2 = it.value().constEnd(); it2 != end2; ++it2) { - delete *it2; - } - } - m_glyphPointerHash.clear(); - for (GlyphIntHash::const_iterator it = m_glyphIntHash.constBegin(), - end = m_glyphIntHash.constEnd(); it != end; ++it) { - for (QList::const_iterator it2 = it.value().constBegin(), - end2 = it.value().constEnd(); it2 != end2; ++it2) { - delete *it2; - } + for (QLinkedList::const_iterator it = m_glyphCaches.constBegin(), + end = m_glyphCaches.constEnd(); it != end; ++it) { + delete it->cache; } - m_glyphIntHash.clear(); + m_glyphCaches.clear(); qHBFreeFace(hbFace); } @@ -713,105 +702,30 @@ QByteArray QFontEngine::getSfntTable(uint tag) const return table; } -void QFontEngine::expireGlyphCache() -{ - if (m_glyphCacheQueue.count() > 10) { // hold only 10 caches in memory. - QFontEngineGlyphCache *old = m_glyphCacheQueue.takeFirst(); - // remove the value from either of our hashes - for (GlyphPointerHash::iterator i = m_glyphPointerHash.begin(); i != m_glyphPointerHash.end(); ++i) { - QList list = i.value(); - if (list.removeAll(old)) { - if (list.isEmpty()) - m_glyphPointerHash.remove(i.key()); - else - m_glyphPointerHash.insert(i.key(), list); - break; - } - } - for (GlyphIntHash::iterator i = m_glyphIntHash.begin(); i != m_glyphIntHash.end(); ++i) { - QList list = i.value(); - if (list.removeAll(old)) { - if (list.isEmpty()) - m_glyphIntHash.remove(i.key()); - else - m_glyphIntHash.insert(i.key(), list); - break; - } - } - delete old; - } -} - -void QFontEngine::setGlyphCache(void *key, QFontEngineGlyphCache *data, QFontEngineGlyphCache::Type type) +void QFontEngine::setGlyphCache(void *key, QFontEngineGlyphCache *data) { Q_ASSERT(data); - QList items = m_glyphPointerHash.value(key); - - for (QList::iterator it = items.begin(), end = items.end(); it != end; ++it) { - QFontEngineGlyphCache *c = *it; - if (qtransform_equals_no_translate(c->m_transform, data->m_transform) - && c->cacheType() == type) { - if (c == data) - return; - items.removeAll(c); - delete c; - break; - } - } - items.append(data); - m_glyphPointerHash.insert(key, items); - m_glyphCacheQueue.append(data); - expireGlyphCache(); -} + GlyphCacheEntry entry = { key, data }; + if (m_glyphCaches.contains(entry)) + return; -void QFontEngine::setGlyphCache(QFontEngineGlyphCache::Type key, QFontEngineGlyphCache *data) -{ - Q_ASSERT(data); - QList items = m_glyphIntHash.value(key); - - for (QList::iterator it = items.begin(), end = items.end(); it != end; ++it) { - QFontEngineGlyphCache *c = *it; - if (qtransform_equals_no_translate(c->m_transform, data->m_transform)) { - if (c == data) - return; - items.removeAll(c); - delete c; - break; - } - } - items.append(data); - m_glyphIntHash.insert(key, items); + // Limit the glyph caches to 4. This covers all 90 degree rotations and limits + // memory use when there is continous or random rotation + if (m_glyphCaches.size() == 4) + delete m_glyphCaches.takeLast().cache; - m_glyphCacheQueue.append(data); - expireGlyphCache(); -} + m_glyphCaches.push_front(entry); -QFontEngineGlyphCache *QFontEngine::glyphCache(void *key, const QTransform &transform, QFontEngineGlyphCache::Type type) const -{ - QList items = m_glyphPointerHash.value(key); - - for (QList::iterator it = items.begin(), end = items.end(); it != end; ++it) { - QFontEngineGlyphCache *c = *it; - if (qtransform_equals_no_translate(c->m_transform, transform) - && type == c->cacheType()) { - m_glyphCacheQueue.removeAll(c); // last used, move it up - m_glyphCacheQueue.append(c); - return c; - } - } - return 0; } -QFontEngineGlyphCache *QFontEngine::glyphCache(QFontEngineGlyphCache::Type key, const QTransform &transform) const +QFontEngineGlyphCache *QFontEngine::glyphCache(void *key, QFontEngineGlyphCache::Type type, const QTransform &transform) const { - QList items = m_glyphIntHash.value(key); - - for (QList::iterator it = items.begin(), end = items.end(); it != end; ++it) { - QFontEngineGlyphCache *c = *it; - if (qtransform_equals_no_translate(c->m_transform, transform)) { - m_glyphCacheQueue.removeAll(c); // last used, move it up - m_glyphCacheQueue.append(c); + for (QLinkedList::const_iterator it = m_glyphCaches.constBegin(), end = m_glyphCaches.constEnd(); it != end; ++it) { + QFontEngineGlyphCache *c = it->cache; + if (key == it->context + && type == c->cacheType() + && qtransform_equals_no_translate(c->m_transform, transform)) { return c; } } diff --git a/src/gui/text/qfontengine_p.h b/src/gui/text/qfontengine_p.h index 62bff85..a9883b4 100644 --- a/src/gui/text/qfontengine_p.h +++ b/src/gui/text/qfontengine_p.h @@ -56,6 +56,7 @@ #include "QtCore/qglobal.h" #include "QtCore/qatomic.h" #include +#include #include "private/qtextengine_p.h" #include "private/qfont_p.h" @@ -218,10 +219,8 @@ public: virtual HB_Error getPointInOutline(HB_Glyph glyph, int flags, hb_uint32 point, HB_Fixed *xpos, HB_Fixed *ypos, hb_uint32 *nPoints); - void setGlyphCache(void *key, QFontEngineGlyphCache *data, QFontEngineGlyphCache::Type type); - void setGlyphCache(QFontEngineGlyphCache::Type key, QFontEngineGlyphCache *data); - QFontEngineGlyphCache *glyphCache(void *key, const QTransform &transform, QFontEngineGlyphCache::Type type) const; - QFontEngineGlyphCache *glyphCache(QFontEngineGlyphCache::Type key, const QTransform &transform) const; + void setGlyphCache(void *key, QFontEngineGlyphCache *data); + QFontEngineGlyphCache *glyphCache(void *key, QFontEngineGlyphCache::Type type, const QTransform &transform) const; static const uchar *getCMap(const uchar *table, uint tableSize, bool *isSymbolFont, int *cmapSize); static quint32 getTrueTypeGlyphIndex(const uchar *cmap, uint unicode); @@ -254,12 +253,13 @@ protected: static const QVector &grayPalette(); private: - /// remove old entries from the glyph cache. Helper method for the setGlyphCache ones. - void expireGlyphCache(); + struct GlyphCacheEntry { + void *context; + QFontEngineGlyphCache *cache; + bool operator==(const GlyphCacheEntry &other) { return context == other.context && cache == other.cache; } + }; - GlyphPointerHash m_glyphPointerHash; - GlyphIntHash m_glyphIntHash; - mutable QList m_glyphCacheQueue; + mutable QLinkedList m_glyphCaches; }; inline bool operator ==(const QFontEngine::FaceId &f1, const QFontEngine::FaceId &f2) diff --git a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp index 9f42217..fb9bcb4 100644 --- a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp +++ b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp @@ -1554,7 +1554,6 @@ void QGL2PaintEngineExPrivate::drawCachedGlyphs(const QPointF &p, QFontEngineGly const QTextItemInt &ti) { Q_Q(QGL2PaintEngineEx); - QOpenGL2PaintEngineState *s = q->state(); QVarLengthArray positions; QVarLengthArray glyphs; @@ -1562,11 +1561,11 @@ void QGL2PaintEngineExPrivate::drawCachedGlyphs(const QPointF &p, QFontEngineGly ti.fontEngine->getGlyphPositions(ti.glyphs, matrix, ti.flags, glyphs, positions); QGLTextureGlyphCache *cache = - (QGLTextureGlyphCache *) ti.fontEngine->glyphCache(ctx, QTransform(), glyphType); + (QGLTextureGlyphCache *) ti.fontEngine->glyphCache(ctx, glyphType, QTransform()); if (!cache || cache->cacheType() != glyphType) { cache = new QGLTextureGlyphCache(ctx, glyphType, QTransform()); - ti.fontEngine->setGlyphCache(ctx, cache, glyphType); + ti.fontEngine->setGlyphCache(ctx, cache); } cache->setPaintEnginePrivate(this); -- cgit v0.12 From 16e4047a627d85182d9d9622a839fa51a9650aca Mon Sep 17 00:00:00 2001 From: Denis Dzyubenko Date: Thu, 10 Dec 2009 11:15:28 +0100 Subject: Fixes a qfileinfo autotest. Canonical file paths can begin with slash only on unix platforms. Reviewed-by: Prasanth --- tests/auto/qfileinfo/tst_qfileinfo.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/auto/qfileinfo/tst_qfileinfo.cpp b/tests/auto/qfileinfo/tst_qfileinfo.cpp index cd58fd6..1445f5b 100644 --- a/tests/auto/qfileinfo/tst_qfileinfo.cpp +++ b/tests/auto/qfileinfo/tst_qfileinfo.cpp @@ -513,9 +513,11 @@ void tst_QFileInfo::canonicalFilePath() QFileInfo info("/tmp/../../../../../../../../../../../../../../../../../"); info.canonicalFilePath(); +#if defined(Q_OS_UNIX) && !defined(Q_OS_SYMBIAN) // This used to crash on Mac QFileInfo dontCrash(QLatin1String("/")); QCOMPARE(dontCrash.canonicalFilePath(), QLatin1String("/")); +#endif #ifndef Q_OS_WIN // test symlinks -- cgit v0.12 From bb0ab1d8cf57dd4a7b69c8478c2a40c1cd1782e9 Mon Sep 17 00:00:00 2001 From: Thierry Bastian Date: Thu, 10 Dec 2009 11:27:51 +0100 Subject: Fix spinbox input when seecting the prefix If you were selcting the prefix and entering a digit the cursor position would not be updated correctly Task-number: QTBUG-6670 Reviewed-by: ogoffart --- src/gui/widgets/qabstractspinbox.cpp | 4 +++- tests/auto/qdoublespinbox/tst_qdoublespinbox.cpp | 12 ++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/gui/widgets/qabstractspinbox.cpp b/src/gui/widgets/qabstractspinbox.cpp index a18af4f..c015589 100644 --- a/src/gui/widgets/qabstractspinbox.cpp +++ b/src/gui/widgets/qabstractspinbox.cpp @@ -1856,8 +1856,10 @@ QValidator::State QSpinBoxValidator::validate(QString &input, int &pos) const if (dptr->specialValueText.size() > 0 && input == dptr->specialValueText) return QValidator::Acceptable; - if (!dptr->prefix.isEmpty() && !input.startsWith(dptr->prefix)) + if (!dptr->prefix.isEmpty() && !input.startsWith(dptr->prefix)) { input.prepend(dptr->prefix); + pos += dptr->prefix.length(); + } if (!dptr->suffix.isEmpty() && !input.endsWith(dptr->suffix)) input.append(dptr->suffix); diff --git a/tests/auto/qdoublespinbox/tst_qdoublespinbox.cpp b/tests/auto/qdoublespinbox/tst_qdoublespinbox.cpp index 7f03153..a3f0915 100644 --- a/tests/auto/qdoublespinbox/tst_qdoublespinbox.cpp +++ b/tests/auto/qdoublespinbox/tst_qdoublespinbox.cpp @@ -148,6 +148,7 @@ private slots: void task255471_decimalsValidation(); void taskQTBUG_5008_textFromValueAndValidate(); + void taskQTBUG_6670_selectAllWithPrefix(); public slots: void valueChangedHelper(const QString &); @@ -1084,5 +1085,16 @@ void tst_QDoubleSpinBox::taskQTBUG_5008_textFromValueAndValidate() QCOMPARE(spinbox.text(), spinbox.locale().toString(spinbox.value())); } +void tst_QDoubleSpinBox::taskQTBUG_6670_selectAllWithPrefix() +{ + DoubleSpinBox spin; + spin.setPrefix("$ "); + spin.lineEdit()->selectAll(); + QTest::keyClick(spin.lineEdit(), Qt::Key_1); + QCOMPARE(spin.value(), 1.); + QTest::keyClick(spin.lineEdit(), Qt::Key_2); + QCOMPARE(spin.value(), 12.); +} + QTEST_MAIN(tst_QDoubleSpinBox) #include "tst_qdoublespinbox.moc" -- cgit v0.12 From a2ccf692cdc4113cc90ef12c27ba8c4aa552d81f Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Thu, 10 Dec 2009 11:35:53 +0100 Subject: Fixes internal drag and drop in QListWidget while dropping to the end Task-number: QTBUG-6565 Reviewed-by: Gabriel --- src/gui/itemviews/qlistwidget.cpp | 2 +- tests/auto/qlistwidget/tst_qlistwidget.cpp | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/gui/itemviews/qlistwidget.cpp b/src/gui/itemviews/qlistwidget.cpp index 929d688..0ce0e5e 100644 --- a/src/gui/itemviews/qlistwidget.cpp +++ b/src/gui/itemviews/qlistwidget.cpp @@ -173,7 +173,7 @@ void QListModel::move(int srcRow, int dstRow) { if (srcRow == dstRow || srcRow < 0 || srcRow >= items.count() - || dstRow < 0 || dstRow >= items.count()) + || dstRow < 0 || dstRow > items.count()) return; if (!beginMoveRows(QModelIndex(), srcRow, srcRow, QModelIndex(), dstRow)) diff --git a/tests/auto/qlistwidget/tst_qlistwidget.cpp b/tests/auto/qlistwidget/tst_qlistwidget.cpp index 863c308..e165190 100644 --- a/tests/auto/qlistwidget/tst_qlistwidget.cpp +++ b/tests/auto/qlistwidget/tst_qlistwidget.cpp @@ -862,12 +862,18 @@ void tst_QListWidget::moveItemsPriv_data() QTest::newRow("Empty") << 0 << 0 << 0 << false; QTest::newRow("Overflow src") << 5 << 5 << 2 << false; QTest::newRow("Underflow src") << 5 << -1 << 2 << false; - QTest::newRow("Overflow dst") << 5 << 2 << 5 << false; + QTest::newRow("Overflow dst") << 5 << 2 << 6 << false; QTest::newRow("Underflow dst") << 5 << 2 << -1 << false; QTest::newRow("Same place") << 5 << 2 << 2 << false; QTest::newRow("Up") << 5 << 4 << 2 << true; QTest::newRow("Down") << 5 << 2 << 4 << true; QTest::newRow("QTBUG-6532 assert") << 5 << 0 << 1 << false; + QTest::newRow("QTBUG-6565 to the end") << 5 << 3 << 5 << true; + QTest::newRow("Same place 2") << 2 << 0 << 1 << false; + QTest::newRow("swap") << 2 << 0 << 2 << true; + QTest::newRow("swap2") << 4 << 1 << 3 << true; + QTest::newRow("swap3") << 4 << 3 << 2 << true; + QTest::newRow("swap4") << 2 << 1 << 0 << true; } void tst_QListWidget::moveItemsPriv() -- cgit v0.12 From 4d3839eb99d720393e1386d63fa04c83367bb076 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Thu, 10 Dec 2009 11:29:22 +0100 Subject: Ensure that QProcessEnvironment::operator== doesn't crash Also add an extensive autotest suite for QProcessEnvironment Task-number: QTBUG-6701 Reviewed-by: Markus Goetz --- src/corelib/io/qprocess.cpp | 3 +- tests/auto/auto.pro | 1 + .../qprocessenvironment/qprocessenvironment.pro | 5 + .../tst_qprocessenvironment.cpp | 265 +++++++++++++++++++++ 4 files changed, 273 insertions(+), 1 deletion(-) create mode 100644 tests/auto/qprocessenvironment/qprocessenvironment.pro create mode 100644 tests/auto/qprocessenvironment/tst_qprocessenvironment.cpp diff --git a/src/corelib/io/qprocess.cpp b/src/corelib/io/qprocess.cpp index 37161bc..c78af3c 100644 --- a/src/corelib/io/qprocess.cpp +++ b/src/corelib/io/qprocess.cpp @@ -275,7 +275,7 @@ QProcessEnvironment &QProcessEnvironment::operator=(const QProcessEnvironment &o */ bool QProcessEnvironment::operator==(const QProcessEnvironment &other) const { - return d->hash == other.d->hash; + return d == other.d || (d && other.d && d->hash == other.d->hash); } /*! @@ -334,6 +334,7 @@ bool QProcessEnvironment::contains(const QString &name) const */ void QProcessEnvironment::insert(const QString &name, const QString &value) { + // d detaches from null d->hash.insert(prepareName(name), prepareValue(value)); } diff --git a/tests/auto/auto.pro b/tests/auto/auto.pro index 92d29ae..5041812 100644 --- a/tests/auto/auto.pro +++ b/tests/auto/auto.pro @@ -256,6 +256,7 @@ SUBDIRS += \ qprinter \ qprinterinfo \ qprocess \ + qprocessenvironment \ qprogressbar \ qprogressdialog \ qpropertyanimation \ diff --git a/tests/auto/qprocessenvironment/qprocessenvironment.pro b/tests/auto/qprocessenvironment/qprocessenvironment.pro new file mode 100644 index 0000000..398facc --- /dev/null +++ b/tests/auto/qprocessenvironment/qprocessenvironment.pro @@ -0,0 +1,5 @@ +load(qttest_p4) + +QT = core + +SOURCES += tst_qprocessenvironment.cpp diff --git a/tests/auto/qprocessenvironment/tst_qprocessenvironment.cpp b/tests/auto/qprocessenvironment/tst_qprocessenvironment.cpp new file mode 100644 index 0000000..1cde33c --- /dev/null +++ b/tests/auto/qprocessenvironment/tst_qprocessenvironment.cpp @@ -0,0 +1,265 @@ +/**************************************************************************** +** +** 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 test suite 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 +#include +#include + +// Note: +// in cross-platform tests, ALWAYS use UPPERCASE variable names +// That's because on Windows, the variables are uppercased + +class tst_QProcessEnvironment: public QObject +{ + Q_OBJECT +private slots: + void operator_eq(); + void clearAndIsEmpty(); + void insert(); + void emptyNull(); + void toStringList(); + + void caseSensitivity(); + void systemEnvironment(); + void putenv(); +}; + +void tst_QProcessEnvironment::operator_eq() +{ + QProcessEnvironment e1; + QVERIFY(e1 == e1); + e1.clear(); + QVERIFY(e1 == e1); + + e1 = QProcessEnvironment(); + QProcessEnvironment e2; + QVERIFY(e1 == e2); + + e1.clear(); + QVERIFY(e1 != e2); + + e2.clear(); + + QVERIFY(e1 == e2); +} + +void tst_QProcessEnvironment::clearAndIsEmpty() +{ + QProcessEnvironment e; + e.insert("FOO", "bar"); + QVERIFY(!e.isEmpty()); + e.clear(); + QVERIFY(e.isEmpty()); +} + +void tst_QProcessEnvironment::insert() +{ + QProcessEnvironment e; + e.insert("FOO", "bar"); + QVERIFY(!e.isEmpty()); + QVERIFY(e.contains("FOO")); + QCOMPARE(e.value("FOO"), QString("bar")); + + e.remove("FOO"); + QVERIFY(!e.contains("FOO")); + QVERIFY(e.value("FOO").isNull()); + + e.clear(); + QVERIFY(!e.contains("FOO")); +} + +void tst_QProcessEnvironment::emptyNull() +{ + QProcessEnvironment e; + + e.insert("FOO", ""); + QVERIFY(e.contains("FOO")); + QVERIFY(e.value("FOO").isEmpty()); + QVERIFY(!e.value("FOO").isNull()); + + e.insert("FOO", QString()); + QVERIFY(e.contains("FOO")); + QVERIFY(e.value("FOO").isEmpty()); + // don't test if it's NULL, since we shall not make a guarantee + + e.remove("FOO"); + QVERIFY(!e.contains("FOO")); +} + +void tst_QProcessEnvironment::toStringList() +{ + QProcessEnvironment e; + QVERIFY(e.isEmpty()); + QVERIFY(e.toStringList().isEmpty()); + + e.insert("FOO", "bar"); + QStringList result = e.toStringList(); + QVERIFY(!result.isEmpty()); + QCOMPARE(result.length(), 1); + QCOMPARE(result.at(0), QString("FOO=bar")); + + e.clear(); + e.insert("BAZ", ""); + result = e.toStringList(); + QCOMPARE(result.at(0), QString("BAZ=")); + + e.insert("FOO", "bar"); + e.insert("A", "bc"); + e.insert("HELLO", "World"); + result = e.toStringList(); + QCOMPARE(result.length(), 4); + + // order is not specified, so use contains() + QVERIFY(result.contains("FOO=bar")); + QVERIFY(result.contains("BAZ=")); + QVERIFY(result.contains("A=bc")); + QVERIFY(result.contains("HELLO=World")); +} + +void tst_QProcessEnvironment::caseSensitivity() +{ + QProcessEnvironment e; + e.insert("foo", "bar"); + +#ifdef Q_OS_WIN + // on Windows, it's uppercased + QVERIFY(e.contains("foo")); + QVERIFY(e.contains("FOO")); + QVERIFY(e.contains("FoO")); + + QCOMPARE(e.value("foo"), QString("bar")); + QCOMPARE(e.value("FOO"), QString("bar")); + QCOMPARE(e.value("FoO"), QString("bar")); + + QStringList list = e.toStringList(); + QCOMPARE(list.at(0), QString("FOO=bar")); +#else + // otherwise, it's case sensitive + QVERIFY(e.contains("foo")); + QVERIFY(!e.contains("FOO")); + + e.insert("FOO", "baz"); + QVERIFY(e.contains("FOO")); + QCOMPARE(e.value("FOO"), QString("baz")); + QCOMPARE(e.value("foo"), QString("bar")); + + QStringList list = e.toStringList(); + QVERIFY(list.contains("foo=bar")); + QVERIFY(list.contains("FOO=baz")); +#endif +} + +void tst_QProcessEnvironment::systemEnvironment() +{ + static const char envname[] = "THIS_ENVIRONMENT_VARIABLE_HOPEFULLY_DOESNT_EXIST"; + QByteArray path = qgetenv("PATH"); + QByteArray nonexistant = qgetenv(envname); + QProcessEnvironment system = QProcessEnvironment::systemEnvironment(); + + QVERIFY(nonexistant.isNull()); + +#ifdef Q_WS_WINCE + // Windows CE has no environment + QVERIFY(path.isEmpty()); + QVERIFY(!system.contains("PATH")); + QVERIFY(system.isEmpty()); +#else + // all other system have environments + if (path.isEmpty()) + QFAIL("Could not find the PATH environment variable -- please correct the test environment"); + + QVERIFY(system.contains("PATH")); + QCOMPARE(system.value("PATH"), QString::fromLocal8Bit(path)); + + QVERIFY(!system.contains(envname)); + +# ifdef Q_OS_WIN + // check case-insensitive too + QVERIFY(system.contains("path")); + QCOMPARE(system.value("path"), QString::fromLocal8Bit(path)); + + QVERIFY(!system.contains(QString(envname).toLower())); +# endif +#endif +} + +void tst_QProcessEnvironment::putenv() +{ +#ifdef Q_WS_WINCE + QSKIP("Windows CE has no environment", SkipAll); +#else + static const char envname[] = "WE_RE_SETTING_THIS_ENVIRONMENT_VARIABLE"; + static bool testRan = false; + + if (testRan) + QFAIL("You cannot run this test more than once, since we modify the environment"); + testRan = true; + + QByteArray valBefore = qgetenv(envname); + if (!valBefore.isNull()) + QFAIL("The environment variable we set in the environment is already set! -- please correct the test environment"); + QProcessEnvironment eBefore = QProcessEnvironment::systemEnvironment(); + + qputenv(envname, "Hello, World"); + QByteArray valAfter = qgetenv(envname); + if (valAfter != "Hello, World") + QSKIP("Could not test: qputenv did not do its job", SkipAll); + + QProcessEnvironment eAfter = QProcessEnvironment::systemEnvironment(); + + QVERIFY(!eBefore.contains(envname)); + QVERIFY(eAfter.contains(envname)); + QCOMPARE(eAfter.value(envname), QString("Hello, World")); + +# ifdef Q_OS_WIN + // check case-insensitive too + QString lower = envname; + lower = lower.toLower(); + QVERIFY(!eBefore.contains(lower)); + QVERIFY(eAfter.contains(lower)); + QCOMPARE(eAfter.value(lower), QString("Hello, World")); +# endif +#endif +} + +QTEST_MAIN(tst_QProcessEnvironment) + +#include "tst_qprocessenvironment.moc" -- cgit v0.12 From 6db96dcd4acccbc13161f85adf3164907b7b5cae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Thu, 10 Dec 2009 12:52:10 +0100 Subject: Fix redraw bugs when using graphics effects in device coordinate mode. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit QGraphicsEffect::boundingRectFor() needs the source bounding rect in device coordinates. This patch fixes the documentation to reflect this, and fixes some internal usage of boundingRectFor() to ensure it always gets the device rect of the source. Task-number: QTBUG-5918 Reviewed-by: Bjørn Erik Nilsen --- src/gui/effects/qgraphicseffect.cpp | 14 +++++-- src/gui/graphicsview/qgraphicsitem.cpp | 54 +++++++++++++++++++++----- src/gui/graphicsview/qgraphicsitem_p.h | 2 + src/gui/graphicsview/qgraphicsview.cpp | 26 +++++++++++++ src/gui/graphicsview/qgraphicsview.h | 1 + src/gui/graphicsview/qgraphicsview_p.h | 3 ++ tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp | 9 ++++- 7 files changed, 95 insertions(+), 14 deletions(-) diff --git a/src/gui/effects/qgraphicseffect.cpp b/src/gui/effects/qgraphicseffect.cpp index 239e29c..d6cabaa 100644 --- a/src/gui/effects/qgraphicseffect.cpp +++ b/src/gui/effects/qgraphicseffect.cpp @@ -160,6 +160,10 @@ QRectF QGraphicsEffectSource::boundingRect(Qt::CoordinateSystem system) const /*! Returns the bounding rectangle of the source mapped to the given \a system. + Calling this function with Qt::DeviceCoordinates outside of + QGraphicsEffect::draw() will give undefined results, as there is no device + context available. + \sa draw() */ QRectF QGraphicsEffect::sourceBoundingRect(Qt::CoordinateSystem system) const @@ -348,6 +352,10 @@ QPixmap QGraphicsEffectSource::pixmap(Qt::CoordinateSystem system, QPoint *offse The returned pixmap is clipped to the current painter's device rectangle when \a system is Qt::DeviceCoordinates. + Calling this function with Qt::DeviceCoordinates outside of + QGraphicsEffect::draw() will give undefined results, as there is no device + context available. + \sa draw(), boundingRect() */ QPixmap QGraphicsEffect::sourcePixmap(Qt::CoordinateSystem system, QPoint *offset, QGraphicsEffect::PixmapPadMode mode) const @@ -398,8 +406,8 @@ QGraphicsEffect::~QGraphicsEffect() /*! Returns the effective bounding rectangle for this effect, i.e., the - bounding rectangle of the source, adjusted by any margins applied by - the effect itself. + bounding rectangle of the source in device coordinates, adjusted by + any margins applied by the effect itself. \sa boundingRectFor(), updateBoundingRect() */ @@ -413,7 +421,7 @@ QRectF QGraphicsEffect::boundingRect() const /*! Returns the effective bounding rectangle for this effect, given the - provided \a rect in the source's coordinate space. When writing + provided \a rect in the device coordinates. When writing you own custom effect, you must call updateBoundingRect() whenever any parameters are changed that may cause this this function to return a different value. diff --git a/src/gui/graphicsview/qgraphicsitem.cpp b/src/gui/graphicsview/qgraphicsitem.cpp index 90cc132..8bbe929 100644 --- a/src/gui/graphicsview/qgraphicsitem.cpp +++ b/src/gui/graphicsview/qgraphicsitem.cpp @@ -2584,6 +2584,35 @@ void QGraphicsItem::setGraphicsEffect(QGraphicsEffect *effect) /*! \internal \since 4.6 + Returns the effective bounding rect of the given item space rect. + If the item has no effect, the rect is returned unmodified. + If the item has an effect, the effective rect can be extend beyond the + item's bounding rect, depending on the effect. + + \sa boundingRect() +*/ +QRectF QGraphicsItemPrivate::effectiveBoundingRect(const QRectF &rect) const +{ +#ifndef QT_NO_GRAPHICSEFFECT + Q_Q(const QGraphicsItem); + QGraphicsEffect *effect = graphicsEffect; + if (scene && effect && effect->isEnabled()) { + QRectF sceneRect = q->mapRectToScene(rect); + QRectF sceneEffectRect; + foreach (QGraphicsView *view, scene->views()) { + QRectF deviceRect = view->d_func()->mapRectFromScene(sceneRect); + QRect deviceEffectRect = effect->boundingRectFor(deviceRect).toAlignedRect(); + sceneEffectRect |= view->d_func()->mapRectToScene(deviceEffectRect); + } + return q->mapRectFromScene(sceneEffectRect); + } +#endif //QT_NO_GRAPHICSEFFECT + return rect; +} + +/*! + \internal + \since 4.6 Returns the effective bounding rect of the item. If the item has no effect, this is the same as the item's bounding rect. If the item has an effect, the effective rect can be larger than the item's @@ -2594,16 +2623,19 @@ void QGraphicsItem::setGraphicsEffect(QGraphicsEffect *effect) QRectF QGraphicsItemPrivate::effectiveBoundingRect() const { #ifndef QT_NO_GRAPHICSEFFECT - QGraphicsEffect *effect = graphicsEffect; - QRectF brect = effect && effect->isEnabled() ? effect->boundingRect() : q_ptr->boundingRect(); + Q_Q(const QGraphicsItem); + QRectF brect = effectiveBoundingRect(q_ptr->boundingRect()); if (ancestorFlags & QGraphicsItemPrivate::AncestorClipsChildren) return brect; const QGraphicsItem *effectParent = parent; while (effectParent) { - effect = effectParent->d_ptr->graphicsEffect; - if (effect && effect->isEnabled()) - brect = effect->boundingRectFor(brect); + QGraphicsEffect *effect = effectParent->d_ptr->graphicsEffect; + if (scene && effect && effect->isEnabled()) { + const QRectF brectInParentSpace = q->mapRectToItem(effectParent, brect); + const QRectF effectRectInParentSpace = effectParent->d_ptr->effectiveBoundingRect(brectInParentSpace); + brect = effectParent->mapRectToItem(q, effectRectInParentSpace); + } if (effectParent->d_ptr->ancestorFlags & QGraphicsItemPrivate::AncestorClipsChildren) return brect; effectParent = effectParent->d_ptr->parent; @@ -10649,17 +10681,21 @@ QPixmap QGraphicsItemEffectSourcePrivate::pixmap(Qt::CoordinateSystem system, QP QGraphicsScenePrivate *scened = item->d_ptr->scene->d_func(); const QRectF sourceRect = boundingRect(system); - QRect effectRect; + QRectF effectRectF; if (mode == QGraphicsEffect::PadToEffectiveBoundingRect) { - effectRect = item->graphicsEffect()->boundingRectFor(sourceRect).toAlignedRect(); + effectRectF = item->graphicsEffect()->boundingRectFor(boundingRect(Qt::DeviceCoordinates)); + if (system == Qt::LogicalCoordinates) + effectRectF = info->painter->worldTransform().inverted().mapRect(effectRectF); } else if (mode == QGraphicsEffect::PadToTransparentBorder) { // adjust by 1.5 to account for cosmetic pens - effectRect = sourceRect.adjusted(-1.5, -1.5, 1.5, 1.5).toAlignedRect(); + effectRectF = sourceRect.adjusted(-1.5, -1.5, 1.5, 1.5); } else { - effectRect = sourceRect.toAlignedRect(); + effectRectF = sourceRect; } + QRect effectRect = effectRectF.toAlignedRect(); + if (offset) *offset = effectRect.topLeft(); diff --git a/src/gui/graphicsview/qgraphicsitem_p.h b/src/gui/graphicsview/qgraphicsitem_p.h index 8f9fe54..2d8de65 100644 --- a/src/gui/graphicsview/qgraphicsitem_p.h +++ b/src/gui/graphicsview/qgraphicsitem_p.h @@ -236,6 +236,8 @@ public: QRectF effectiveBoundingRect() const; QRectF sceneEffectiveBoundingRect() const; + QRectF effectiveBoundingRect(const QRectF &rect) const; + virtual void resolveFont(uint inheritedMask) { for (int i = 0; i < children.size(); ++i) diff --git a/src/gui/graphicsview/qgraphicsview.cpp b/src/gui/graphicsview/qgraphicsview.cpp index 3f9f443..ffe64aa 100644 --- a/src/gui/graphicsview/qgraphicsview.cpp +++ b/src/gui/graphicsview/qgraphicsview.cpp @@ -545,6 +545,32 @@ qint64 QGraphicsViewPrivate::verticalScroll() const /*! \internal + + Maps the given rectangle to the scene using QTransform::mapRect() +*/ +QRectF QGraphicsViewPrivate::mapRectToScene(const QRect &rect) const +{ + if (dirtyScroll) + const_cast(this)->updateScroll(); + QRectF scrolled = QRectF(rect.translated(scrollX, scrollY)); + return identityMatrix ? scrolled : matrix.inverted().mapRect(scrolled); +} + + +/*! + \internal + + Maps the given rectangle from the scene using QTransform::mapRect() +*/ +QRectF QGraphicsViewPrivate::mapRectFromScene(const QRectF &rect) const +{ + if (dirtyScroll) + const_cast(this)->updateScroll(); + return (identityMatrix ? rect : matrix.mapRect(rect)).translated(-scrollX, -scrollY); +} + +/*! + \internal */ void QGraphicsViewPrivate::updateScroll() { diff --git a/src/gui/graphicsview/qgraphicsview.h b/src/gui/graphicsview/qgraphicsview.h index 2aed0e6..90576e5 100644 --- a/src/gui/graphicsview/qgraphicsview.h +++ b/src/gui/graphicsview/qgraphicsview.h @@ -278,6 +278,7 @@ private: friend class QGraphicsSceneWidget; friend class QGraphicsScene; friend class QGraphicsScenePrivate; + friend class QGraphicsItemPrivate; }; Q_DECLARE_OPERATORS_FOR_FLAGS(QGraphicsView::CacheMode) diff --git a/src/gui/graphicsview/qgraphicsview_p.h b/src/gui/graphicsview/qgraphicsview_p.h index cd161ad..d4b718e 100644 --- a/src/gui/graphicsview/qgraphicsview_p.h +++ b/src/gui/graphicsview/qgraphicsview_p.h @@ -86,6 +86,9 @@ public: qint64 horizontalScroll() const; qint64 verticalScroll() const; + QRectF mapRectToScene(const QRect &rect) const; + QRectF mapRectFromScene(const QRectF &rect) const; + QPointF mousePressItemPoint; QPointF mousePressScenePoint; QPoint mousePressViewPoint; diff --git a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp index 6266933..3e7a2eb 100644 --- a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp +++ b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp @@ -233,6 +233,7 @@ public: void paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidget *) { hints = painter->renderHints(); + painter->setBrush(brush); painter->drawRect(boundingRect()); ++repaints; } @@ -247,6 +248,7 @@ public: QPainter::RenderHints hints; int repaints; QRectF br; + QBrush brush; }; class tst_QGraphicsItem : public QObject @@ -7646,17 +7648,20 @@ void tst_QGraphicsItem::hitTestGraphicsEffectItem() EventTester *item1 = new EventTester; item1->br = itemBoundingRect; item1->setPos(-200, -200); + item1->brush = Qt::red; EventTester *item2 = new EventTester; item2->br = itemBoundingRect; item2->setFlag(QGraphicsItem::ItemIgnoresTransformations); item2->setParentItem(item1); item2->setPos(200, 200); + item2->brush = Qt::green; EventTester *item3 = new EventTester; item3->br = itemBoundingRect; item3->setParentItem(item2); item3->setPos(80, 80); + item3->brush = Qt::blue; scene.addItem(item1); QTest::qWait(100); @@ -7671,8 +7676,8 @@ void tst_QGraphicsItem::hitTestGraphicsEffectItem() item1->setGraphicsEffect(shadow); QTest::qWait(50); - // Make sure all items are repainted. - QCOMPARE(item1->repaints, 1); + // Make sure all visible items are repainted. + QCOMPARE(item1->repaints, 0); QCOMPARE(item2->repaints, 1); QCOMPARE(item3->repaints, 1); -- cgit v0.12 From bf9456c5a2d8dfe9a35a2175186630cb426858ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Trond=20Kjern=C3=A5sen?= Date: Thu, 10 Dec 2009 17:38:30 +0100 Subject: Optimize our GL extension checks to avoid mallocs. We want to avoid any unnecessary mallocs when checking GL/GLX extensions. The GL extension string can be quite long and contain several hundred extensions. The old code forced one malloc for each extension + 1 extra malloc for the extension string itself when it was copied into the QByteArray. Reviewed-by: Kim --- src/opengl/qgl.cpp | 47 ++++++++++++++++++++++++----------------------- src/opengl/qgl_p.h | 43 +++++++++++++++++++++++++++++++++++++++++++ src/opengl/qgl_x11.cpp | 24 ++++++++++++------------ 3 files changed, 79 insertions(+), 35 deletions(-) diff --git a/src/opengl/qgl.cpp b/src/opengl/qgl.cpp index dcf8c00..b6f8919 100644 --- a/src/opengl/qgl.cpp +++ b/src/opengl/qgl.cpp @@ -4822,38 +4822,39 @@ QGLWidget::QGLWidget(QGLContext *context, QWidget *parent, void QGLExtensions::init_extensions() { - QList extensions = QByteArray(reinterpret_cast(glGetString(GL_EXTENSIONS))).split(' '); - if (extensions.contains("GL_ARB_texture_rectangle")) + QGLExtensionMatcher extensions(reinterpret_cast(glGetString(GL_EXTENSIONS))); + + if (extensions.match("GL_ARB_texture_rectangle")) glExtensions |= TextureRectangle; - if (extensions.contains("GL_ARB_multisample")) + if (extensions.match("GL_ARB_multisample")) glExtensions |= SampleBuffers; - if (extensions.contains("GL_SGIS_generate_mipmap")) + if (extensions.match("GL_SGIS_generate_mipmap")) glExtensions |= GenerateMipmap; - if (extensions.contains("GL_ARB_texture_compression")) + if (extensions.match("GL_ARB_texture_compression")) glExtensions |= TextureCompression; - if (extensions.contains("GL_EXT_texture_compression_s3tc")) + if (extensions.match("GL_EXT_texture_compression_s3tc")) glExtensions |= DDSTextureCompression; - if (extensions.contains("GL_OES_compressed_ETC1_RGB8_texture")) + if (extensions.match("GL_OES_compressed_ETC1_RGB8_texture")) glExtensions |= ETC1TextureCompression; - if (extensions.contains("GL_IMG_texture_compression_pvrtc")) + if (extensions.match("GL_IMG_texture_compression_pvrtc")) glExtensions |= PVRTCTextureCompression; - if (extensions.contains("GL_ARB_fragment_program")) + if (extensions.match("GL_ARB_fragment_program")) glExtensions |= FragmentProgram; - if (extensions.contains("GL_ARB_fragment_shader")) + if (extensions.match("GL_ARB_fragment_shader")) glExtensions |= FragmentShader; - if (extensions.contains("GL_ARB_texture_mirrored_repeat")) + if (extensions.match("GL_ARB_texture_mirrored_repeat")) glExtensions |= MirroredRepeat; - if (extensions.contains("GL_EXT_framebuffer_object")) + if (extensions.match("GL_EXT_framebuffer_object")) glExtensions |= FramebufferObject; - if (extensions.contains("GL_EXT_stencil_two_side")) + if (extensions.match("GL_EXT_stencil_two_side")) glExtensions |= StencilTwoSide; - if (extensions.contains("GL_EXT_stencil_wrap")) + if (extensions.match("GL_EXT_stencil_wrap")) glExtensions |= StencilWrap; - if (extensions.contains("GL_EXT_packed_depth_stencil")) + if (extensions.match("GL_EXT_packed_depth_stencil")) glExtensions |= PackedDepthStencil; - if (extensions.contains("GL_NV_float_buffer")) + if (extensions.match("GL_NV_float_buffer")) glExtensions |= NVFloatBuffer; - if (extensions.contains("GL_ARB_pixel_buffer_object")) + if (extensions.match("GL_ARB_pixel_buffer_object")) glExtensions |= PixelBufferObject; #if defined(QT_OPENGL_ES_2) glExtensions |= FramebufferObject; @@ -4861,26 +4862,26 @@ void QGLExtensions::init_extensions() glExtensions |= FragmentShader; #endif #if defined(QT_OPENGL_ES_1) || defined(QT_OPENGL_ES_1_CL) - if (extensions.contains("GL_OES_framebuffer_object")) + if (extensions.match("GL_OES_framebuffer_object")) glExtensions |= FramebufferObject; #endif #if defined(QT_OPENGL_ES) - if (extensions.contains("GL_OES_packed_depth_stencil")) + if (extensions.match("GL_OES_packed_depth_stencil")) glExtensions |= PackedDepthStencil; #endif - if (extensions.contains("GL_ARB_framebuffer_object")) { + if (extensions.match("GL_ARB_framebuffer_object")) { // ARB_framebuffer_object also includes EXT_framebuffer_blit. glExtensions |= FramebufferObject; glExtensions |= FramebufferBlit; } - if (extensions.contains("GL_EXT_framebuffer_blit")) + if (extensions.match("GL_EXT_framebuffer_blit")) glExtensions |= FramebufferBlit; - if (extensions.contains("GL_ARB_texture_non_power_of_two")) + if (extensions.match("GL_ARB_texture_non_power_of_two")) glExtensions |= NPOTTextures; - if (extensions.contains("GL_EXT_bgra")) + if (extensions.match("GL_EXT_bgra")) glExtensions |= BGRATextureFormat; } diff --git a/src/opengl/qgl_p.h b/src/opengl/qgl_p.h index 8a0b31f..11770d3 100644 --- a/src/opengl/qgl_p.h +++ b/src/opengl/qgl_p.h @@ -610,6 +610,49 @@ private: friend class QGLContextGroup; }; + +// This class can be used to match GL extensions with doing any mallocs. The +// class assumes that the GL extension string ends with a space character, +// which it should do on all conformant platforms. Create the object and pass +// in a pointer to the extension string, then call match() on each extension +// that should be matched. The match() function takes the extension name +// *without* the terminating space character as input. + +class QGLExtensionMatcher +{ +public: + QGLExtensionMatcher(const char *str) + : gl_extensions(str), gl_extensions_length(qstrlen(str)) + {} + + bool match(const char *str) { + int str_length = qstrlen(str); + const char *extensions = gl_extensions; + int extensions_length = gl_extensions_length; + + while (1) { + // the total length that needs to be matched is the str_length + + // the space character that terminates the extension name + if (extensions_length < str_length + 1) + return false; + if (qstrncmp(extensions, str, str_length) == 0 && extensions[str_length] == ' ') + return true; + + int split_pos = 0; + while (split_pos < extensions_length && extensions[split_pos] != ' ') + ++split_pos; + ++split_pos; // added for the terminating space character + extensions += split_pos; + extensions_length -= split_pos; + } + return false; + } + +private: + const char *gl_extensions; + int gl_extensions_length; +}; + QT_END_NAMESPACE #endif // QGL_P_H diff --git a/src/opengl/qgl_x11.cpp b/src/opengl/qgl_x11.cpp index a037282..9c3fc79 100644 --- a/src/opengl/qgl_x11.cpp +++ b/src/opengl/qgl_x11.cpp @@ -343,8 +343,8 @@ void* qglx_getProcAddress(const char* procName) static bool triedResolvingGlxGetProcAddress = false; if (!triedResolvingGlxGetProcAddress) { triedResolvingGlxGetProcAddress = true; - QList glxExt = QByteArray(glXGetClientString(QX11Info::display(), GLX_EXTENSIONS)).split(' '); - if (glxExt.contains("GLX_ARB_get_proc_address")) { + QGLExtensionMatcher extensions(glXGetClientString(QX11Info::display(), GLX_EXTENSIONS)); + if (extensions.match("GLX_ARB_get_proc_address")) { #if defined(Q_OS_LINUX) || defined(Q_OS_BSD4) void *handle = dlopen(NULL, RTLD_LAZY); if (handle) { @@ -523,8 +523,8 @@ bool QGLContext::chooseContext(const QGLContext* shareContext) if (!d->gpm) return false; } - QList glxExt = QByteArray(glXQueryExtensionsString(xinfo->display(), xinfo->screen())).split(' '); - if (glxExt.contains("GLX_SGI_video_sync")) { + QGLExtensionMatcher extensions(glXQueryExtensionsString(xinfo->display(), xinfo->screen())); + if (extensions.match("GLX_SGI_video_sync")) { if (d->glFormat.swapInterval() == -1) d->glFormat.setSwapInterval(0); } else { @@ -630,8 +630,8 @@ void *QGLContext::tryVisual(const QGLFormat& f, int bufDepth) static bool useTranspExt = false; static bool useTranspExtChecked = false; if (f.plane() && !useTranspExtChecked && d->paintDevice) { - QByteArray estr(glXQueryExtensionsString(xinfo->display(), xinfo->screen())); - useTranspExt = estr.contains("GLX_EXT_visual_info"); + QGLExtensionMatcher extensions(glXQueryExtensionsString(xinfo->display(), xinfo->screen())); + useTranspExt = extensions.match("GLX_EXT_visual_info"); //# (A bit simplistic; that could theoretically be a substring) if (useTranspExt) { QByteArray cstr(glXGetClientString(xinfo->display(), GLX_VENDOR)); @@ -875,8 +875,8 @@ void QGLContext::swapBuffers() const static bool resolved = false; if (!resolved) { const QX11Info *xinfo = qt_x11Info(d->paintDevice); - QList glxExt = QByteArray(glXQueryExtensionsString(xinfo->display(), xinfo->screen())).split(' '); - if (glxExt.contains("GLX_SGI_video_sync")) { + QGLExtensionMatcher extensions(glXQueryExtensionsString(xinfo->display(), xinfo->screen())); + if (extensions.match("GLX_SGI_video_sync")) { glXGetVideoSyncSGI = (qt_glXGetVideoSyncSGI)qglx_getProcAddress("glXGetVideoSyncSGI"); glXWaitVideoSyncSGI = (qt_glXWaitVideoSyncSGI)qglx_getProcAddress("glXWaitVideoSyncSGI"); } @@ -1107,8 +1107,8 @@ void *QGLContext::getProcAddress(const QString &proc) const if (resolved && !glXGetProcAddressARB) return 0; if (!glXGetProcAddressARB) { - QList glxExt = QByteArray(glXGetClientString(QX11Info::display(), GLX_EXTENSIONS)).split(' '); - if (glxExt.contains("GLX_ARB_get_proc_address")) { + QGLExtensionMatcher extensions(glXGetClientString(QX11Info::display(), GLX_EXTENSIONS)); + if (extensions.match("GLX_ARB_get_proc_address")) { #if defined(Q_OS_LINUX) || defined(Q_OS_BSD4) void *handle = dlopen(NULL, RTLD_LAZY); if (handle) { @@ -1609,8 +1609,8 @@ static bool qt_resolveTextureFromPixmap(QPaintDevice *paintDevice) return false; // Can't use TFP without NPOT } const QX11Info *xinfo = qt_x11Info(paintDevice); - QList glxExt = QByteArray(glXQueryExtensionsString(xinfo->display(), xinfo->screen())).split(' '); - if (glxExt.contains("GLX_EXT_texture_from_pixmap")) { + QGLExtensionMatcher extensions(glXQueryExtensionsString(xinfo->display(), xinfo->screen())); + if (extensions.match("GLX_EXT_texture_from_pixmap")) { glXBindTexImageEXT = (qt_glXBindTexImageEXT) qglx_getProcAddress("glXBindTexImageEXT"); glXReleaseTexImageEXT = (qt_glXReleaseTexImageEXT) qglx_getProcAddress("glXReleaseTexImageEXT"); } -- cgit v0.12 From 3a8a1f83d60ec16e4c61e2b0a327a5af02917a5a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Thu, 10 Dec 2009 17:22:53 +0100 Subject: Prevented leak of keys in QPixmapCache. Removing a pixmap from the pixmap cache using the new QPixmapCache::Key API left the keys dangling in the QCache's internal QHash. The problem is that the Key is invalidated as soon as the QPixmapCacheEntry is destroyed, thus removing it from the hash failed. Reordering the destruction of the object and the removal of the key in QHash fixes the problem. Reviewed-by: Alexis Reviewed-by: Thiago --- src/corelib/tools/qcache.h | 2 +- src/gui/image/qpixmapcache.cpp | 5 +++++ tests/auto/qpixmapcache/tst_qpixmapcache.cpp | 19 +++++++++++++++++++ 3 files changed, 25 insertions(+), 1 deletion(-) diff --git a/src/corelib/tools/qcache.h b/src/corelib/tools/qcache.h index 46e20b1..ee9523f 100644 --- a/src/corelib/tools/qcache.h +++ b/src/corelib/tools/qcache.h @@ -70,8 +70,8 @@ class QCache if (l == &n) l = n.p; if (f == &n) f = n.n; total -= n.c; - delete n.t; hash.remove(*n.keyPtr); + delete n.t; } inline T *relink(const Key &key) { typename QHash::iterator i = hash.find(key); diff --git a/src/gui/image/qpixmapcache.cpp b/src/gui/image/qpixmapcache.cpp index b0b7d72..b7b29d7 100644 --- a/src/gui/image/qpixmapcache.cpp +++ b/src/gui/image/qpixmapcache.cpp @@ -424,6 +424,11 @@ QPixmapCache::KeyData* QPMCache::getKeyData(QPixmapCache::Key *key) Q_GLOBAL_STATIC(QPMCache, pm_cache) +int Q_AUTOTEST_EXPORT q_QPixmapCache_keyHashSize() +{ + return pm_cache()->size(); +} + QPixmapCacheEntry::~QPixmapCacheEntry() { pm_cache()->releaseKey(key); diff --git a/tests/auto/qpixmapcache/tst_qpixmapcache.cpp b/tests/auto/qpixmapcache/tst_qpixmapcache.cpp index 9775d36..c89a182 100644 --- a/tests/auto/qpixmapcache/tst_qpixmapcache.cpp +++ b/tests/auto/qpixmapcache/tst_qpixmapcache.cpp @@ -70,6 +70,7 @@ private slots: void remove(); void clear(); void pixmapKey(); + void noLeak(); }; static QPixmapCache::KeyData* getPrivate(QPixmapCache::Key &key) @@ -482,5 +483,23 @@ void tst_QPixmapCache::pixmapKey() QVERIFY(!getPrivate(key8)); } +extern int q_QPixmapCache_keyHashSize(); + +void tst_QPixmapCache::noLeak() +{ + QPixmapCache::Key key; + + int oldSize = q_QPixmapCache_keyHashSize(); + for (int i = 0; i < 100; ++i) { + QPixmap pm(128, 128); + pm.fill(Qt::transparent); + key = QPixmapCache::insert(pm); + QPixmapCache::remove(key); + } + int newSize = q_QPixmapCache_keyHashSize(); + + QCOMPARE(oldSize, newSize); +} + QTEST_MAIN(tst_QPixmapCache) #include "tst_qpixmapcache.moc" -- cgit v0.12 From 6c161d6cca6c08843b479c00fffb9c7217aec505 Mon Sep 17 00:00:00 2001 From: Rohan McGovern Date: Thu, 10 Dec 2009 16:39:46 +1000 Subject: Install private headers when configuring Qt with -developer-build. Many Qt autotests require both private symbols and private headers. Private symbols are turned on using -developer-build. However, prior to this commit there was no way to install private headers into the Qt install directory. This is particularly relevant for packaging systems which use `make install' to determine what should be packaged. For example, Qt for Maemo debian packages are effectively unusable for Qt autotests without this commit. Reviewed-by: Michael Goddard --- bin/syncqt | 6 ++++++ src/qt_install.pri | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/bin/syncqt b/bin/syncqt index a14a82d..629e124 100755 --- a/bin/syncqt +++ b/bin/syncqt @@ -666,6 +666,7 @@ foreach (@modules_to_sync) { #information used after the syncing my $pri_install_classes = ""; my $pri_install_files = ""; + my $pri_install_pfiles = ""; my $libcapitals = $lib; $libcapitals =~ y/a-z/A-Z/; @@ -834,6 +835,10 @@ foreach (@modules_to_sync) { $pri_install_files.= "$pri_install_iheader ";; } } + else { + my $pri_install_iheader = fixPaths($iheader, $current_dir); + $pri_install_pfiles.= "$pri_install_iheader ";; + } } print "header created for $iheader ($header_copies)\n" if($header_copies > 0); } @@ -878,6 +883,7 @@ foreach (@modules_to_sync) { my $headers_pri_contents = ""; $headers_pri_contents .= "SYNCQT.HEADER_FILES = $pri_install_files\n"; $headers_pri_contents .= "SYNCQT.HEADER_CLASSES = $pri_install_classes\n"; + $headers_pri_contents .= "SYNCQT.PRIVATE_HEADER_FILES = $pri_install_pfiles\n"; my $headers_pri_file = "$out_basedir/include/$lib/headers.pri"; if(-e "$headers_pri_file") { open HEADERS_PRI_FILE, "<$headers_pri_file"; diff --git a/src/qt_install.pri b/src/qt_install.pri index ebeac8d..5b29942 100644 --- a/src/qt_install.pri +++ b/src/qt_install.pri @@ -30,6 +30,12 @@ qt_install_headers { targ_headers.files = $$INSTALL_HEADERS targ_headers.path = $$[QT_INSTALL_HEADERS]/$$TARGET INSTALLS += targ_headers + + contains(QT_CONFIG,private_tests) { + private_headers.files = $$SYNCQT.PRIVATE_HEADER_FILES + private_headers.path = $$[QT_INSTALL_HEADERS]/$$TARGET/private + INSTALLS += private_headers + } } embedded:equals(TARGET, QtGui) { -- cgit v0.12 From b62c6de3eae005da146a9009f86851a1431b1892 Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Fri, 11 Dec 2009 16:04:24 +1000 Subject: Add benchmark for QtScript translation functions. --- .../benchmarks/qscriptengine/tst_qscriptengine.cpp | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/tests/benchmarks/qscriptengine/tst_qscriptengine.cpp b/tests/benchmarks/qscriptengine/tst_qscriptengine.cpp index 8d5f6e6..1c787e9 100644 --- a/tests/benchmarks/qscriptengine/tst_qscriptengine.cpp +++ b/tests/benchmarks/qscriptengine/tst_qscriptengine.cpp @@ -72,6 +72,8 @@ private slots: void toStringHandle(); void castValueToQreal(); void nativeCall(); + void translation_data(); + void translation(); }; tst_QScriptEngine::tst_QScriptEngine() @@ -259,5 +261,24 @@ void tst_QScriptEngine::nativeCall() } } +void tst_QScriptEngine::translation_data() +{ + QTest::addColumn("text"); + QTest::newRow("no translation") << "\"hello world\""; + QTest::newRow("qsTr") << "qsTr(\"hello world\")"; + QTest::newRow("qsTranslate") << "qsTranslate(\"\", \"hello world\")"; +} + +void tst_QScriptEngine::translation() +{ + QFETCH(QString, text); + QScriptEngine engine; + engine.installTranslatorFunctions(); + + QBENCHMARK { + (void)engine.evaluate(text); + } +} + QTEST_MAIN(tst_QScriptEngine) #include "tst_qscriptengine.moc" -- cgit v0.12 From 343de9228ae65c36c4a9a45297d45cdeb04a8e44 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Fri, 11 Dec 2009 11:06:03 +0100 Subject: Fixed qgraphicseffectsource autotest. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Prevent crashing when asking for a source pixmap in logical coordinates and PadToEffectiveBoundingRect mode. Also, change the expected values for the test that uses LogicalCoordinates and PadToEffectiveBoundingRect mode to reflect that the boundingRectFor() function applies padding in device coordinates (and in this case there is a scale by 2 when drawing the effect). Reviewed-by: Bjørn Erik Nilsen --- src/gui/graphicsview/qgraphicsitem.cpp | 11 ++++++++--- .../auto/qgraphicseffectsource/tst_qgraphicseffectsource.cpp | 2 +- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/gui/graphicsview/qgraphicsitem.cpp b/src/gui/graphicsview/qgraphicsitem.cpp index 8bbe929..c879c5c 100644 --- a/src/gui/graphicsview/qgraphicsitem.cpp +++ b/src/gui/graphicsview/qgraphicsitem.cpp @@ -10684,9 +10684,14 @@ QPixmap QGraphicsItemEffectSourcePrivate::pixmap(Qt::CoordinateSystem system, QP QRectF effectRectF; if (mode == QGraphicsEffect::PadToEffectiveBoundingRect) { - effectRectF = item->graphicsEffect()->boundingRectFor(boundingRect(Qt::DeviceCoordinates)); - if (system == Qt::LogicalCoordinates) - effectRectF = info->painter->worldTransform().inverted().mapRect(effectRectF); + if (info) { + effectRectF = item->graphicsEffect()->boundingRectFor(boundingRect(Qt::DeviceCoordinates)); + if (info && system == Qt::LogicalCoordinates) + effectRectF = info->painter->worldTransform().inverted().mapRect(effectRectF); + } else { + // no choice but to send a logical coordinate bounding rect to boundingRectFor + effectRectF = item->graphicsEffect()->boundingRectFor(sourceRect); + } } else if (mode == QGraphicsEffect::PadToTransparentBorder) { // adjust by 1.5 to account for cosmetic pens effectRectF = sourceRect.adjusted(-1.5, -1.5, 1.5, 1.5); diff --git a/tests/auto/qgraphicseffectsource/tst_qgraphicseffectsource.cpp b/tests/auto/qgraphicseffectsource/tst_qgraphicseffectsource.cpp index 9991ab4..7a0d40a 100644 --- a/tests/auto/qgraphicseffectsource/tst_qgraphicseffectsource.cpp +++ b/tests/auto/qgraphicseffectsource/tst_qgraphicseffectsource.cpp @@ -352,7 +352,7 @@ void tst_QGraphicsEffectSource::pixmapPadding_data() QTest::newRow("log,effectrect") << int(Qt::LogicalCoordinates) << int(QGraphicsEffect::PadToEffectiveBoundingRect) - << QSize(30, 30) << QPoint(-10, -10) + << QSize(20, 20) << QPoint(-5, -5) << 0x00000000u; QTest::newRow("dev,nopad") << int(Qt::DeviceCoordinates) -- cgit v0.12 From 669cb438384f1ceafd4b2ee783b9a52d7110ccf7 Mon Sep 17 00:00:00 2001 From: Anders Ahlen Date: Fri, 11 Dec 2009 12:00:47 +0100 Subject: Document QTextEncoder::fromUnicode as QT3 support member Make deprecated QTextEncoder::fromUnicode ( const QString & uc, int & lenInOut ) documented as QT3 support member Task-number: QTBUG-6614 Merge-request: 399 Reviewed-by: Thiago Macieira --- src/corelib/codecs/qtextcodec.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/corelib/codecs/qtextcodec.h b/src/corelib/codecs/qtextcodec.h index f831700..6170272 100644 --- a/src/corelib/codecs/qtextcodec.h +++ b/src/corelib/codecs/qtextcodec.h @@ -161,7 +161,7 @@ public: QByteArray fromUnicode(const QString& str); QByteArray fromUnicode(const QChar *uc, int len); #ifdef QT3_SUPPORT - QByteArray fromUnicode(const QString& uc, int& lenInOut); + QT3_SUPPORT QByteArray fromUnicode(const QString& uc, int& lenInOut); #endif bool hasFailure() const; private: -- cgit v0.12 From 664c78144754c499d07a95c3914fd34202bf4b98 Mon Sep 17 00:00:00 2001 From: Gunnar Sletta Date: Fri, 11 Dec 2009 12:05:00 +0100 Subject: Initial documentation for the performance characteristics of QPainter. Reviewed-by: Tom --- src/gui/painting/qpainter.cpp | 78 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 78 insertions(+) diff --git a/src/gui/painting/qpainter.cpp b/src/gui/painting/qpainter.cpp index 66bf4f7..13d9a04 100644 --- a/src/gui/painting/qpainter.cpp +++ b/src/gui/painting/qpainter.cpp @@ -1317,6 +1317,84 @@ void QPainterPrivate::updateState(QPainterState *newState) Another workaround is to convert the paths to polygons first and then draw the polygons instead. + \section1 Performance + + QPainter is a rich framework that allows developers to do a great + variety of graphical operations, such as gradients, composition + modes and vector graphcis. And QPainter can do this across a + variety of different hardware and software stack. Naturally the + underlying combination of hardware and software has some + implications for performance, and ensuring that every single + operation is fast in combination with all the various combinations + of composition modes, brushes, clipping, transformation, etc, is + close to an impossible task because of the number of + permutations. As a compromise we have selected a subset of the + QPainter API and backends, were performance is guaranteed to be as + good as we can sensibly get it for the given combination of + hardware and software. + + The backends we focus on as high-performance engines are: + + \list + + \o Raster - This backend implements all rendering in pure software + and is always used to render into QImages. For optimal performance + only use the format types QImage::Format_ARGB32_Premultiplied, + QImage::Format_RGB32 or QImage::Format_RGB16. Any other format, + including QImage::Format_ARGB32, has significantly worse + performance. This engine is also used by default on Windows and on + QWS. It can be used as default graphics system on any + OS/hardware/software combination by passing \c {-graphcissystem + raster} on the command line + + \o OpenGL 2.0 (ES) - This backend is the primary backend for + hardware accellerated graphics. It can be run on desktop machines + and embedded devices supporting the OpenGL 2.0 or OpenGL/ES 2.0 + spesification. This includes most graphics chips produced in the + last couple of years. The engine can be enabled by using QPainter + onto a QGLWidget or by passing \c {-graphicssystem opengl} on the + command line when the underlying system supports it. + + \endlist + + These operations are: + + \list + + \o Simple transformations, meaning translation and scaling, pluss + 0, 90, 180, 270 degree rotations. + + \o \c drawPixmap() in combination with simple transformations and + opacity with non-smooth transformation mode + (\c QPainter::SmoothPixmapTransform not enabled as a render hint); + + \o Text drawing with regular font sizes with simple + transformations with solid colors using no or 8-bit antialiasing. + + \o Rectangle fills with solid color, two-color linear gradients + and simple transforms. + + \o Rectangular clipping with simple transformations and intersect + clip. + + \o Composition Modes \c QPainter::CompositionMode_Source and + QPainter::CompositionMode_SourceOver + + \o Rounded rectangle filling using solid color and two-color + linear gradients fills. + + \o 3x3 patched pixmaps, via qDrawBorderPixmap. + + \endlist + + This list gives an indication of which features to safely use in + an application where performance is critical. For certain setups, + other operations may be fast too, but before making extensive use + of them, it is recommended to benchmark and verify them on the + system where the software will run in the end. There are also + cases where expensive operations are ok to use, for instance when + the result is cached in a QPixmap. + \sa QPaintDevice, QPaintEngine, {QtSvg Module}, {Basic Drawing Example}, {Drawing Utility Functions} */ -- cgit v0.12 From bafc505ea03ff423c02e0380ba6f255e160483a1 Mon Sep 17 00:00:00 2001 From: "Bradley T. Hughes" Date: Fri, 11 Dec 2009 11:35:57 +0100 Subject: Fix tst_QTouchEvent::touchUpdateAndEndNeverPropagate() QGrahpicsItem behaves similarly to QWidget; if the TouchUpdate or TouchEnd event is ignored, then the event sent to the view and scene will also be ignored. Reviewed-by: Trust me --- tests/auto/qtouchevent/tst_qtouchevent.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/auto/qtouchevent/tst_qtouchevent.cpp b/tests/auto/qtouchevent/tst_qtouchevent.cpp index f95a5c6..98af4fb 100644 --- a/tests/auto/qtouchevent/tst_qtouchevent.cpp +++ b/tests/auto/qtouchevent/tst_qtouchevent.cpp @@ -496,7 +496,7 @@ void tst_QTouchEvent::touchUpdateAndEndNeverPropagate() res = QApplication::sendEvent(view.viewport(), &touchUpdateEvent); QVERIFY(res); // the scene accepts the event, since it found an item to send the event to - QVERIFY(touchUpdateEvent.isAccepted()); + QVERIFY(!touchUpdateEvent.isAccepted()); QVERIFY(child.seenTouchUpdate); QVERIFY(!root.seenTouchUpdate); @@ -510,7 +510,7 @@ void tst_QTouchEvent::touchUpdateAndEndNeverPropagate() res = QApplication::sendEvent(view.viewport(), &touchEndEvent); QVERIFY(res); // the scene accepts the event, since it found an item to send the event to - QVERIFY(touchEndEvent.isAccepted()); + QVERIFY(!touchEndEvent.isAccepted()); QVERIFY(child.seenTouchEnd); QVERIFY(!root.seenTouchEnd); } -- cgit v0.12 From 05ba6bad6c0927d22ccf026446dfdb9d85b3f03e Mon Sep 17 00:00:00 2001 From: "Bradley T. Hughes" Date: Fri, 11 Dec 2009 11:38:19 +0100 Subject: Fix crashes when deleting QWidgets and QGraphicsItems in touch event handlers. Use QWeakPointer to bail out early if a widget is deleted while we are delivering/propagating a TouchBegin event. In QGraphicsScene, we need to make sure that we clear the scene's active touch points for items that are removed from the scene. This allows us to detect when an item is removed during TouchBegin event delivery/propagation. Unlike QWidget, propagation continues since we use a hit-test instead of the item's hierarchy for propagation. Task-number: QTBUG-6654 Reviewed-by: bnilsen --- src/gui/graphicsview/qgraphicsscene.cpp | 24 ++- src/gui/kernel/qapplication.cpp | 10 +- tests/auto/qtouchevent/tst_qtouchevent.cpp | 246 ++++++++++++++++++++++++++++- 3 files changed, 274 insertions(+), 6 deletions(-) diff --git a/src/gui/graphicsview/qgraphicsscene.cpp b/src/gui/graphicsview/qgraphicsscene.cpp index 27ebb79..2a53456 100644 --- a/src/gui/graphicsview/qgraphicsscene.cpp +++ b/src/gui/graphicsview/qgraphicsscene.cpp @@ -613,6 +613,19 @@ void QGraphicsScenePrivate::removeItemHelper(QGraphicsItem *item) if (item == lastActivePanel) lastActivePanel = 0; + // Cancel active touches + { + QMap::iterator it = itemForTouchPointId.begin(); + while (it != itemForTouchPointId.end()) { + if (it.value() == item) { + sceneCurrentTouchPoints.remove(it.key()); + it = itemForTouchPointId.erase(it); + } else { + ++it; + } + } + } + // Disable selectionChanged() for individual items ++selectionChanging; int oldSelectedItemsSize = selectedItems.size(); @@ -5679,17 +5692,22 @@ bool QGraphicsScenePrivate::sendTouchBeginEvent(QGraphicsItem *origin, QTouchEve touchEvent->setAccepted(acceptTouchEvents); res = acceptTouchEvents && sendEvent(item, touchEvent); eventAccepted = touchEvent->isAccepted(); - item->d_ptr->acceptedTouchBeginEvent = (res && eventAccepted); + if (itemForTouchPointId.value(touchEvent->touchPoints().first().id()) == 0) { + // item was deleted + item = 0; + } else { + item->d_ptr->acceptedTouchBeginEvent = (res && eventAccepted); + } touchEvent->spont = false; if (res && eventAccepted) { // the first item to accept the TouchBegin gets an implicit grab. for (int i = 0; i < touchEvent->touchPoints().count(); ++i) { const QTouchEvent::TouchPoint &touchPoint = touchEvent->touchPoints().at(i); - itemForTouchPointId[touchPoint.id()] = item; + itemForTouchPointId[touchPoint.id()] = item; // can be zero } break; } - if (item->isPanel()) + if (item && item->isPanel()) break; } diff --git a/src/gui/kernel/qapplication.cpp b/src/gui/kernel/qapplication.cpp index 9f4cd0c..8c63968 100644 --- a/src/gui/kernel/qapplication.cpp +++ b/src/gui/kernel/qapplication.cpp @@ -4092,9 +4092,15 @@ bool QApplication::notify(QObject *receiver, QEvent *e) bool acceptTouchEvents = widget->testAttribute(Qt::WA_AcceptTouchEvents); touchEvent->setWidget(widget); touchEvent->setAccepted(acceptTouchEvents); + QWeakPointer p = widget; res = acceptTouchEvents && d->notify_helper(widget, touchEvent); eventAccepted = touchEvent->isAccepted(); - widget->setAttribute(Qt::WA_WState_AcceptedTouchBeginEvent, res && eventAccepted); + if (p.isNull()) { + // widget was deleted + widget = 0; + } else { + widget->setAttribute(Qt::WA_WState_AcceptedTouchBeginEvent, res && eventAccepted); + } touchEvent->spont = false; if (res && eventAccepted) { // the first widget to accept the TouchBegin gets an implicit grab. @@ -4103,7 +4109,7 @@ bool QApplication::notify(QObject *receiver, QEvent *e) d->widgetForTouchPointId[touchPoint.id()] = widget; } break; - } else if (widget->isWindow() || widget->testAttribute(Qt::WA_NoMousePropagation)) { + } else if (p.isNull() || widget->isWindow() || widget->testAttribute(Qt::WA_NoMousePropagation)) { break; } QPoint offset = widget->pos(); diff --git a/tests/auto/qtouchevent/tst_qtouchevent.cpp b/tests/auto/qtouchevent/tst_qtouchevent.cpp index 98af4fb..da8721c 100644 --- a/tests/auto/qtouchevent/tst_qtouchevent.cpp +++ b/tests/auto/qtouchevent/tst_qtouchevent.cpp @@ -48,6 +48,7 @@ public: QList touchBeginPoints, touchUpdatePoints, touchEndPoints; bool seenTouchBegin, seenTouchUpdate, seenTouchEnd; bool acceptTouchBegin, acceptTouchUpdate, acceptTouchEnd; + bool deleteInTouchBegin, deleteInTouchUpdate, deleteInTouchEnd; tst_QTouchEventWidget() : QWidget() @@ -62,6 +63,7 @@ public: touchEndPoints.clear(); seenTouchBegin = seenTouchUpdate = seenTouchEnd = false; acceptTouchBegin = acceptTouchUpdate = acceptTouchEnd = true; + deleteInTouchBegin = deleteInTouchUpdate = deleteInTouchEnd = false; } bool event(QEvent *event) @@ -74,6 +76,8 @@ public: seenTouchBegin = !seenTouchBegin && !seenTouchUpdate && !seenTouchEnd; touchBeginPoints = static_cast(event)->touchPoints(); event->setAccepted(acceptTouchBegin); + if (deleteInTouchBegin) + delete this; break; case QEvent::TouchUpdate: if (!seenTouchBegin) qWarning("TouchUpdate: have not seen TouchBegin"); @@ -81,6 +85,8 @@ public: seenTouchUpdate = seenTouchBegin && !seenTouchEnd; touchUpdatePoints = static_cast(event)->touchPoints(); event->setAccepted(acceptTouchUpdate); + if (deleteInTouchUpdate) + delete this; break; case QEvent::TouchEnd: if (!seenTouchBegin) qWarning("TouchEnd: have not seen TouchBegin"); @@ -88,6 +94,8 @@ public: seenTouchEnd = seenTouchBegin && !seenTouchEnd; touchEndPoints = static_cast(event)->touchPoints(); event->setAccepted(acceptTouchEnd); + if (deleteInTouchEnd) + delete this; break; default: return QWidget::event(event); @@ -102,13 +110,21 @@ public: QList touchBeginPoints, touchUpdatePoints, touchEndPoints; bool seenTouchBegin, seenTouchUpdate, seenTouchEnd; bool acceptTouchBegin, acceptTouchUpdate, acceptTouchEnd; + bool deleteInTouchBegin, deleteInTouchUpdate, deleteInTouchEnd; + tst_QTouchEventGraphicsItem **weakpointer; tst_QTouchEventGraphicsItem() - : QGraphicsItem() + : QGraphicsItem(), weakpointer(0) { reset(); } + ~tst_QTouchEventGraphicsItem() + { + if (weakpointer) + *weakpointer = 0; + } + void reset() { touchBeginPoints.clear(); @@ -116,6 +132,7 @@ public: touchEndPoints.clear(); seenTouchBegin = seenTouchUpdate = seenTouchEnd = false; acceptTouchBegin = acceptTouchUpdate = acceptTouchEnd = true; + deleteInTouchBegin = deleteInTouchUpdate = deleteInTouchEnd = false; } QRectF boundingRect() const { return QRectF(0, 0, 10, 10); } @@ -131,6 +148,8 @@ public: seenTouchBegin = !seenTouchBegin && !seenTouchUpdate && !seenTouchEnd; touchBeginPoints = static_cast(event)->touchPoints(); event->setAccepted(acceptTouchBegin); + if (deleteInTouchBegin) + delete this; break; case QEvent::TouchUpdate: if (!seenTouchBegin) qWarning("TouchUpdate: have not seen TouchBegin"); @@ -138,6 +157,8 @@ public: seenTouchUpdate = seenTouchBegin && !seenTouchEnd; touchUpdatePoints = static_cast(event)->touchPoints(); event->setAccepted(acceptTouchUpdate); + if (deleteInTouchUpdate) + delete this; break; case QEvent::TouchEnd: if (!seenTouchBegin) qWarning("TouchEnd: have not seen TouchBegin"); @@ -145,6 +166,8 @@ public: seenTouchEnd = seenTouchBegin && !seenTouchEnd; touchEndPoints = static_cast(event)->touchPoints(); event->setAccepted(acceptTouchEnd); + if (deleteInTouchEnd) + delete this; break; default: return QGraphicsItem::sceneEvent(event); @@ -168,6 +191,8 @@ private slots: void basicRawEventTranslation(); void multiPointRawEventTranslationOnTouchScreen(); void multiPointRawEventTranslationOnTouchPad(); + void deleteInEventHandler(); + void deleteInRawEventTranslation(); }; void tst_QTouchEvent::touchDisabledByDefault() @@ -1059,6 +1084,225 @@ void tst_QTouchEvent::multiPointRawEventTranslationOnTouchPad() } } +void tst_QTouchEvent::deleteInEventHandler() +{ + // QWidget + { + QWidget window; + tst_QTouchEventWidget *child1, *child2, *child3; + child1 = new tst_QTouchEventWidget; + child2 = new tst_QTouchEventWidget; + child3 = new tst_QTouchEventWidget; + child1->setParent(&window); + child2->setParent(&window); + child3->setParent(&window); + child1->setAttribute(Qt::WA_AcceptTouchEvents); + child2->setAttribute(Qt::WA_AcceptTouchEvents); + child3->setAttribute(Qt::WA_AcceptTouchEvents); + child1->deleteInTouchBegin = true; + child2->deleteInTouchUpdate = true; + child3->deleteInTouchEnd = true; + + QList touchPoints; + touchPoints.append(QTouchEvent::TouchPoint(0)); + QTouchEvent touchBeginEvent(QEvent::TouchBegin, + QTouchEvent::TouchScreen, + Qt::NoModifier, + Qt::TouchPointPressed, + touchPoints); + QTouchEvent touchUpdateEvent(QEvent::TouchUpdate, + QTouchEvent::TouchScreen, + Qt::NoModifier, + Qt::TouchPointStationary, + touchPoints); + QTouchEvent touchEndEvent(QEvent::TouchEnd, + QTouchEvent::TouchScreen, + Qt::NoModifier, + Qt::TouchPointReleased, + touchPoints); + QWeakPointer p; + bool res; + + touchBeginEvent.ignore(); + p = child1; + res = QApplication::sendEvent(child1, &touchBeginEvent); + // event is handled, but widget should be deleted + QVERIFY(res && touchBeginEvent.isAccepted() && p.isNull()); + + touchBeginEvent.ignore(); + p = child2; + res = QApplication::sendEvent(child2, &touchBeginEvent); + QVERIFY(res && touchBeginEvent.isAccepted() && !p.isNull()); + touchUpdateEvent.ignore(); + res = QApplication::sendEvent(child2, &touchUpdateEvent); + QVERIFY(res && touchUpdateEvent.isAccepted() && p.isNull()); + + touchBeginEvent.ignore(); + p = child3; + res = QApplication::sendEvent(child3, &touchBeginEvent); + QVERIFY(res && touchBeginEvent.isAccepted() && !p.isNull()); + touchUpdateEvent.ignore(); + res = QApplication::sendEvent(child3, &touchUpdateEvent); + QVERIFY(res && touchUpdateEvent.isAccepted() && !p.isNull()); + touchEndEvent.ignore(); + res = QApplication::sendEvent(child3, &touchEndEvent); + QVERIFY(res && touchEndEvent.isAccepted() && p.isNull()); + } + + // QGraphicsView + { + QGraphicsScene scene; + QGraphicsView view(&scene); + tst_QTouchEventGraphicsItem *root, *child1, *child2, *child3; + root = new tst_QTouchEventGraphicsItem; + child1 = new tst_QTouchEventGraphicsItem; + child2 = new tst_QTouchEventGraphicsItem; + child3 = new tst_QTouchEventGraphicsItem; + child1->setParentItem(root); + child2->setParentItem(root); + child3->setParentItem(root); + child1->setZValue(1.); + child2->setZValue(0.); + child3->setZValue(-1.); + child1->setAcceptTouchEvents(true); + child2->setAcceptTouchEvents(true); + child3->setAcceptTouchEvents(true); + child1->deleteInTouchBegin = true; + child2->deleteInTouchUpdate = true; + child3->deleteInTouchEnd = true; + + scene.addItem(root); + view.resize(200, 200); + view.fitInView(scene.sceneRect()); + + QTouchEvent::TouchPoint touchPoint(0); + touchPoint.setState(Qt::TouchPointPressed); + touchPoint.setPos(view.mapFromScene(child1->mapToScene(child1->boundingRect().center()))); + touchPoint.setScreenPos(view.mapToGlobal(touchPoint.pos().toPoint())); + touchPoint.setScenePos(view.mapToScene(touchPoint.pos().toPoint())); + QList touchPoints; + touchPoints.append(touchPoint); + QTouchEvent touchBeginEvent(QEvent::TouchBegin, + QTouchEvent::TouchScreen, + Qt::NoModifier, + Qt::TouchPointPressed, + touchPoints); + touchPoints[0].setState(Qt::TouchPointMoved); + QTouchEvent touchUpdateEvent(QEvent::TouchUpdate, + QTouchEvent::TouchScreen, + Qt::NoModifier, + Qt::TouchPointMoved, + touchPoints); + touchPoints[0].setState(Qt::TouchPointReleased); + QTouchEvent touchEndEvent(QEvent::TouchEnd, + QTouchEvent::TouchScreen, + Qt::NoModifier, + Qt::TouchPointReleased, + touchPoints); + bool res; + + child1->weakpointer = &child1; + touchBeginEvent.ignore(); + res = QApplication::sendEvent(view.viewport(), &touchBeginEvent); + QVERIFY(res && touchBeginEvent.isAccepted() && !child1); + touchUpdateEvent.ignore(); + res = QApplication::sendEvent(view.viewport(), &touchUpdateEvent); + QVERIFY(res && touchUpdateEvent.isAccepted() && !child1); + touchEndEvent.ignore(); + res = QApplication::sendEvent(view.viewport(), &touchEndEvent); + QVERIFY(res && touchUpdateEvent.isAccepted() && !child1); + + child2->weakpointer = &child2; + touchBeginEvent.ignore(); + res = QApplication::sendEvent(view.viewport(), &touchBeginEvent); + QVERIFY(res && touchBeginEvent.isAccepted() && child2); + touchUpdateEvent.ignore(); + res = QApplication::sendEvent(view.viewport(), &touchUpdateEvent); + QVERIFY(res && !touchUpdateEvent.isAccepted() && !child2); + touchEndEvent.ignore(); + res = QApplication::sendEvent(view.viewport(), &touchEndEvent); + QVERIFY(res && !touchUpdateEvent.isAccepted() && !child2); + + child3->weakpointer = &child3; + res = QApplication::sendEvent(view.viewport(), &touchBeginEvent); + QVERIFY(res && touchBeginEvent.isAccepted() && child3); + res = QApplication::sendEvent(view.viewport(), &touchUpdateEvent); + QVERIFY(res && !touchUpdateEvent.isAccepted() && child3); + res = QApplication::sendEvent(view.viewport(), &touchEndEvent); + QVERIFY(res && !touchEndEvent.isAccepted() && !child3); + + delete root; + } +} + +void tst_QTouchEvent::deleteInRawEventTranslation() +{ + tst_QTouchEventWidget touchWidget; + touchWidget.setAttribute(Qt::WA_AcceptTouchEvents); + touchWidget.setGeometry(100, 100, 300, 300); + + tst_QTouchEventWidget *leftWidget = new tst_QTouchEventWidget; + leftWidget->setParent(&touchWidget); + leftWidget->setAttribute(Qt::WA_AcceptTouchEvents); + leftWidget->setGeometry(0, 100, 100, 100); + leftWidget->deleteInTouchBegin = true; + leftWidget->show(); + + tst_QTouchEventWidget *centerWidget = new tst_QTouchEventWidget; + centerWidget->setParent(&touchWidget); + centerWidget->setAttribute(Qt::WA_AcceptTouchEvents); + centerWidget->setGeometry(100, 100, 100, 100); + centerWidget->deleteInTouchUpdate = true; + centerWidget->show(); + + tst_QTouchEventWidget *rightWidget = new tst_QTouchEventWidget; + rightWidget->setParent(&touchWidget); + rightWidget->setAttribute(Qt::WA_AcceptTouchEvents); + rightWidget->setGeometry(200, 100, 100, 100); + rightWidget->deleteInTouchEnd = true; + rightWidget->show(); + + QPointF leftPos = leftWidget->rect().center(); + QPointF centerPos = centerWidget->rect().center(); + QPointF rightPos = rightWidget->rect().center(); + QPointF leftScreenPos = leftWidget->mapToGlobal(leftPos.toPoint()); + QPointF centerScreenPos = centerWidget->mapToGlobal(centerPos.toPoint()); + QPointF rightScreenPos = rightWidget->mapToGlobal(rightPos.toPoint()); + QRectF screenGeometry = qApp->desktop()->screenGeometry(&touchWidget); + + QWeakPointer pl = leftWidget, pc = centerWidget, pr = rightWidget; + + QList rawTouchPoints; + rawTouchPoints.append(QTouchEvent::TouchPoint(0)); + rawTouchPoints.append(QTouchEvent::TouchPoint(1)); + rawTouchPoints.append(QTouchEvent::TouchPoint(2)); + rawTouchPoints[0].setState(Qt::TouchPointPressed); + rawTouchPoints[0].setScreenPos(leftScreenPos); + rawTouchPoints[0].setNormalizedPos(normalized(rawTouchPoints[0].pos(), screenGeometry)); + rawTouchPoints[1].setState(Qt::TouchPointPressed); + rawTouchPoints[1].setScreenPos(centerScreenPos); + rawTouchPoints[1].setNormalizedPos(normalized(rawTouchPoints[1].pos(), screenGeometry)); + rawTouchPoints[2].setState(Qt::TouchPointPressed); + rawTouchPoints[2].setScreenPos(rightScreenPos); + rawTouchPoints[2].setNormalizedPos(normalized(rawTouchPoints[2].pos(), screenGeometry)); + + // generate begin events on all widgets, the left widget should die + qt_translateRawTouchEvent(&touchWidget, QTouchEvent::TouchScreen, rawTouchPoints); + QVERIFY(pl.isNull() && !pc.isNull() && !pr.isNull()); + + // generate update events on all widget, the center widget should die + rawTouchPoints[0].setState(Qt::TouchPointMoved); + rawTouchPoints[1].setState(Qt::TouchPointMoved); + rawTouchPoints[2].setState(Qt::TouchPointMoved); + qt_translateRawTouchEvent(&touchWidget, QTouchEvent::TouchScreen, rawTouchPoints); + + // generate end events on all widget, the right widget should die + rawTouchPoints[0].setState(Qt::TouchPointReleased); + rawTouchPoints[1].setState(Qt::TouchPointReleased); + rawTouchPoints[2].setState(Qt::TouchPointReleased); + qt_translateRawTouchEvent(&touchWidget, QTouchEvent::TouchScreen, rawTouchPoints); +} + QTEST_MAIN(tst_QTouchEvent) #include "tst_qtouchevent.moc" -- cgit v0.12 From d8b7b7278987462791488f756edd26842d059074 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Fri, 11 Dec 2009 14:23:34 +0100 Subject: Fixed invalid read in QCache::unlink after recent change. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We need to store a pointer to the object in order to delete it later, since the node containing the pointer will be deleted when removing it from the hash. Reviewed-by: Jan-Arve Sæther --- src/corelib/tools/qcache.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/corelib/tools/qcache.h b/src/corelib/tools/qcache.h index ee9523f..086a52f 100644 --- a/src/corelib/tools/qcache.h +++ b/src/corelib/tools/qcache.h @@ -70,8 +70,9 @@ class QCache if (l == &n) l = n.p; if (f == &n) f = n.n; total -= n.c; + T *object = n.t; hash.remove(*n.keyPtr); - delete n.t; + delete object; } inline T *relink(const Key &key) { typename QHash::iterator i = hash.find(key); -- cgit v0.12 From 9aa60dfdf5b4837b9ceb15d8fcbc96f37dce7b5a Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Fri, 11 Dec 2009 15:19:30 +0100 Subject: Check if the timeout expired during the time update in qt_safe_select It can happen that select(2) returns -1 with EINTR, but the time remaining was too small for us to update the time. Our own processing (plus the syscall to clock_gettime(2)) leads us past the timeout, so we get a negative timeval. Task-number: QTBUG-6755 Reviewed-by: Bradley T. Hughes --- src/corelib/kernel/qcore_unix.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/corelib/kernel/qcore_unix.cpp b/src/corelib/kernel/qcore_unix.cpp index 5885591..d0dc7be 100644 --- a/src/corelib/kernel/qcore_unix.cpp +++ b/src/corelib/kernel/qcore_unix.cpp @@ -129,7 +129,7 @@ static inline bool time_update(struct timeval *tv, const struct timeval &start, // clock source is monotonic, so we can recalculate how much timeout is left struct timeval now = qt_gettime(); *tv = timeout + start - now; - return true; + return tv->tv_sec >= 0; } int qt_safe_select(int nfds, fd_set *fdread, fd_set *fdwrite, fd_set *fdexcept, @@ -154,7 +154,8 @@ int qt_safe_select(int nfds, fd_set *fdread, fd_set *fdwrite, fd_set *fdexcept, // recalculate the timeout if (!time_update(&timeout, start, *orig_timeout)) { - // clock reset, fake timeout error + // timeout during update + // or clock reset, fake timeout error return 0; } } -- cgit v0.12 From 0fecf4184e888b202766210b235fde09a81c5257 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan-Arve=20S=C3=A6ther?= Date: Fri, 11 Dec 2009 15:36:13 +0100 Subject: Add a simple check for a common wrong usage to avoid infinite recursion Reviewed-by: Alexis --- src/gui/graphicsview/qgraphicsanchorlayout.cpp | 23 ++++++++++++---------- src/gui/graphicsview/qgraphicsanchorlayout_p.cpp | 7 +++++++ .../tst_qgraphicsanchorlayout.cpp | 20 +++++++++++++++++++ 3 files changed, 40 insertions(+), 10 deletions(-) diff --git a/src/gui/graphicsview/qgraphicsanchorlayout.cpp b/src/gui/graphicsview/qgraphicsanchorlayout.cpp index 6718a28..f504c54 100644 --- a/src/gui/graphicsview/qgraphicsanchorlayout.cpp +++ b/src/gui/graphicsview/qgraphicsanchorlayout.cpp @@ -321,14 +321,14 @@ void QGraphicsAnchorLayout::addCornerAnchors(QGraphicsLayoutItem *firstItem, // Horizontal anchor Qt::AnchorPoint firstEdge = (firstCorner & 1 ? Qt::AnchorRight: Qt::AnchorLeft); Qt::AnchorPoint secondEdge = (secondCorner & 1 ? Qt::AnchorRight: Qt::AnchorLeft); - d->addAnchor(firstItem, firstEdge, secondItem, secondEdge); + if (d->addAnchor(firstItem, firstEdge, secondItem, secondEdge)) { + // Vertical anchor + firstEdge = (firstCorner & 2 ? Qt::AnchorBottom: Qt::AnchorTop); + secondEdge = (secondCorner & 2 ? Qt::AnchorBottom: Qt::AnchorTop); + d->addAnchor(firstItem, firstEdge, secondItem, secondEdge); - // Vertical anchor - firstEdge = (firstCorner & 2 ? Qt::AnchorBottom: Qt::AnchorTop); - secondEdge = (secondCorner & 2 ? Qt::AnchorBottom: Qt::AnchorTop); - d->addAnchor(firstItem, firstEdge, secondItem, secondEdge); - - invalidate(); + invalidate(); + } } /*! @@ -351,11 +351,14 @@ void QGraphicsAnchorLayout::addAnchors(QGraphicsLayoutItem *firstItem, QGraphicsLayoutItem *secondItem, Qt::Orientations orientations) { + bool ok = true; if (orientations & Qt::Horizontal) { - addAnchor(secondItem, Qt::AnchorLeft, firstItem, Qt::AnchorLeft); - addAnchor(firstItem, Qt::AnchorRight, secondItem, Qt::AnchorRight); + // Currently, if the first is ok, then the rest of the calls should be ok + ok = addAnchor(secondItem, Qt::AnchorLeft, firstItem, Qt::AnchorLeft) != 0; + if (ok) + addAnchor(firstItem, Qt::AnchorRight, secondItem, Qt::AnchorRight); } - if (orientations & Qt::Vertical) { + if (orientations & Qt::Vertical && ok) { addAnchor(secondItem, Qt::AnchorTop, firstItem, Qt::AnchorTop); addAnchor(firstItem, Qt::AnchorBottom, secondItem, Qt::AnchorBottom); } diff --git a/src/gui/graphicsview/qgraphicsanchorlayout_p.cpp b/src/gui/graphicsview/qgraphicsanchorlayout_p.cpp index 03ed63d..1dc6873 100644 --- a/src/gui/graphicsview/qgraphicsanchorlayout_p.cpp +++ b/src/gui/graphicsview/qgraphicsanchorlayout_p.cpp @@ -1666,6 +1666,13 @@ QGraphicsAnchor *QGraphicsAnchorLayoutPrivate::addAnchor(QGraphicsLayoutItem *fi return 0; } + const QGraphicsLayoutItem *parentWidget = q->parentLayoutItem(); + if (firstItem == parentWidget || secondItem == parentWidget) { + qWarning("QGraphicsAnchorLayout::addAnchor(): " + "You cannot add the parent of the layout to the layout."); + return 0; + } + // In QGraphicsAnchorLayout, items are represented in its internal // graph as four anchors that connect: // - Left -> HCenter diff --git a/tests/auto/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp b/tests/auto/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp index 6e78522..1cb9f0d 100644 --- a/tests/auto/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp +++ b/tests/auto/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp @@ -90,6 +90,7 @@ private slots: void parallelToHalfLayout(); void globalSpacing(); void graphicsAnchorHandling(); + void invalidHierarchyCheck(); }; class RectWidget : public QGraphicsWidget @@ -2058,5 +2059,24 @@ void tst_QGraphicsAnchorLayout::graphicsAnchorHandling() delete a; } +void tst_QGraphicsAnchorLayout::invalidHierarchyCheck() +{ + QGraphicsWidget window(0, Qt::Window); + QGraphicsAnchorLayout *l = new QGraphicsAnchorLayout; + window.setLayout(l); + + QCOMPARE(l->count(), 0); + QTest::ignoreMessage(QtWarningMsg, "QGraphicsAnchorLayout::addAnchor(): " + "You cannot add the parent of the layout to the layout."); + QVERIFY(!l->addAnchor(l, Qt::AnchorLeft, &window, Qt::AnchorLeft)); + QTest::ignoreMessage(QtWarningMsg, "QGraphicsAnchorLayout::addAnchor(): " + "You cannot add the parent of the layout to the layout."); + l->addAnchors(l, &window); + QTest::ignoreMessage(QtWarningMsg, "QGraphicsAnchorLayout::addAnchor(): " + "You cannot add the parent of the layout to the layout."); + l->addCornerAnchors(l, Qt::TopLeftCorner, &window, Qt::TopLeftCorner); + QCOMPARE(l->count(), 0); +} + QTEST_MAIN(tst_QGraphicsAnchorLayout) #include "tst_qgraphicsanchorlayout.moc" -- cgit v0.12 From 6a1cff7c47e1f47161f765ba2f7094b55aaa13c5 Mon Sep 17 00:00:00 2001 From: Yoann Lopes Date: Fri, 11 Dec 2009 16:41:00 +0100 Subject: Fixes Graphicsitem transformation problems when grouping/ungrouping. New transformation properties added in 4.6, such as rotation or transformOriginPoint were not taken into account in addTogroup and removeFromGroup. Autotest and manual test included. Task-number: QTBUG-5071 Reviewed-by: bnilsen --- src/gui/graphicsview/qgraphicsitem.cpp | 46 ++- tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp | 30 ++ tests/manual/qgraphicsitemgroup/customitem.cpp | 107 +++++++ tests/manual/qgraphicsitemgroup/customitem.h | 77 +++++ tests/manual/qgraphicsitemgroup/main.cpp | 51 ++++ .../qgraphicsitemgroup/qgraphicsitemgroup.pro | 8 + tests/manual/qgraphicsitemgroup/widget.cpp | 260 +++++++++++++++++ tests/manual/qgraphicsitemgroup/widget.h | 93 ++++++ tests/manual/qgraphicsitemgroup/widget.ui | 319 +++++++++++++++++++++ 9 files changed, 989 insertions(+), 2 deletions(-) create mode 100644 tests/manual/qgraphicsitemgroup/customitem.cpp create mode 100644 tests/manual/qgraphicsitemgroup/customitem.h create mode 100644 tests/manual/qgraphicsitemgroup/main.cpp create mode 100644 tests/manual/qgraphicsitemgroup/qgraphicsitemgroup.pro create mode 100644 tests/manual/qgraphicsitemgroup/widget.cpp create mode 100644 tests/manual/qgraphicsitemgroup/widget.h create mode 100644 tests/manual/qgraphicsitemgroup/widget.ui diff --git a/src/gui/graphicsview/qgraphicsitem.cpp b/src/gui/graphicsview/qgraphicsitem.cpp index c879c5c..d955f16 100644 --- a/src/gui/graphicsview/qgraphicsitem.cpp +++ b/src/gui/graphicsview/qgraphicsitem.cpp @@ -10537,6 +10537,20 @@ void QGraphicsItemGroup::addToGroup(QGraphicsItem *item) if (!item->pos().isNull()) newItemTransform *= QTransform::fromTranslate(-item->x(), -item->y()); + // removing additional transformations properties applied with itemTransform() + QPointF origin = item->transformOriginPoint(); + QMatrix4x4 m; + QList transformList = item->transformations(); + for (int i = 0; i < transformList.size(); ++i) + transformList.at(i)->applyTo(&m); + newItemTransform *= m.toTransform().inverted(); + newItemTransform.translate(origin.x(), origin.y()); + newItemTransform.rotate(-item->rotation()); + newItemTransform.scale(1/item->scale(), 1/item->scale()); + newItemTransform.translate(-origin.x(), -origin.y()); + + // ### Expensive, we could maybe use dirtySceneTransform bit for optimization + item->setTransform(newItemTransform); item->d_func()->setIsMemberOfGroup(true); prepareGeometryChange(); @@ -10561,11 +10575,39 @@ void QGraphicsItemGroup::removeFromGroup(QGraphicsItem *item) } QGraphicsItem *newParent = d_ptr->parent; + + // COMBINE + bool ok; + QTransform itemTransform; + if (newParent) + itemTransform = item->itemTransform(newParent, &ok); + else + itemTransform = item->sceneTransform(); + QPointF oldPos = item->mapToItem(newParent, 0, 0); item->setParentItem(newParent); - // ### This function should remap the item's matrix to keep the item's - // transformation unchanged relative to the scene. item->setPos(oldPos); + + // removing position from translation component of the new transform + if (!item->pos().isNull()) + itemTransform *= QTransform::fromTranslate(-item->x(), -item->y()); + + // removing additional transformations properties applied + // with itemTransform() or sceneTransform() + QPointF origin = item->transformOriginPoint(); + QMatrix4x4 m; + QList transformList = item->transformations(); + for (int i = 0; i < transformList.size(); ++i) + transformList.at(i)->applyTo(&m); + itemTransform *= m.toTransform().inverted(); + itemTransform.translate(origin.x(), origin.y()); + itemTransform.rotate(-item->rotation()); + itemTransform.scale(1 / item->scale(), 1 / item->scale()); + itemTransform.translate(-origin.x(), -origin.y()); + + // ### Expensive, we could maybe use dirtySceneTransform bit for optimization + + item->setTransform(itemTransform); item->d_func()->setIsMemberOfGroup(item->group() != 0); // ### Quite expensive. But removeFromGroup() isn't called very often. diff --git a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp index 3e7a2eb..a4931ab 100644 --- a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp +++ b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp @@ -318,6 +318,7 @@ private slots: void childrenBoundingRect3(); void group(); void setGroup(); + void setGroup2(); void nestedGroups(); void warpChildrenIntoGroup(); void removeFromGroup(); @@ -3345,6 +3346,35 @@ void tst_QGraphicsItem::setGroup() QCOMPARE(rect->parentItem(), (QGraphicsItem *)0); } +void tst_QGraphicsItem::setGroup2() +{ + QGraphicsScene scene; + QGraphicsItemGroup group; + scene.addItem(&group); + + QGraphicsRectItem *rect = scene.addRect(50,50,50,50,Qt::NoPen,Qt::black); + rect->setTransformOriginPoint(50,50); + rect->setRotation(45); + rect->setScale(1.5); + rect->translate(20,20); + group.translate(-30,-40); + group.setRotation(180); + group.setScale(0.5); + + QTransform oldSceneTransform = rect->sceneTransform(); + rect->setGroup(&group); + QCOMPARE(rect->sceneTransform(), oldSceneTransform); + + group.setRotation(20); + group.setScale(2); + rect->setRotation(90); + rect->setScale(0.8); + + oldSceneTransform = rect->sceneTransform(); + rect->setGroup(0); + QCOMPARE(rect->sceneTransform(), oldSceneTransform); +} + void tst_QGraphicsItem::nestedGroups() { QGraphicsItemGroup *group1 = new QGraphicsItemGroup; diff --git a/tests/manual/qgraphicsitemgroup/customitem.cpp b/tests/manual/qgraphicsitemgroup/customitem.cpp new file mode 100644 index 0000000..16da0c5 --- /dev/null +++ b/tests/manual/qgraphicsitemgroup/customitem.cpp @@ -0,0 +1,107 @@ +/**************************************************************************** +** +** 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 test suite 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 "customitem.h" + +#include +#include +#include + +QList CustomScene::selectedCustomGroups() const +{ + QList all = selectedItems(); + QList groups; + + foreach (QGraphicsItem *item, all) { + CustomGroup* group = dynamic_cast(item); + if (group) + groups.append(group); + } + + return groups; +} + +QList CustomScene::selectedCustomItems() const +{ + QList all = selectedItems(); + QList items; + + foreach (QGraphicsItem *item, all) { + CustomItem* citem = dynamic_cast(item); + if (citem) + items.append(citem); + } + + return items; +} + +CustomGroup::CustomGroup() : + QGraphicsItemGroup() +{ + setFlag(QGraphicsItem::ItemIsMovable); + setFlag(QGraphicsItem::ItemIsSelectable); +} + +void CustomGroup::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) +{ + if (option->state & QStyle::State_Selected) + painter->setOpacity(1.); + else + painter->setOpacity(0.2); + + painter->setPen(QPen(QColor(100, 100, 100), 2, Qt::DashLine)); + painter->drawRect(boundingRect().adjusted(-2, -2, 2, 2)); +} + +QRectF CustomGroup::boundingRect() const +{ + return QGraphicsItemGroup::boundingRect().adjusted(-4, -4, 4 ,4); +} + +CustomItem::CustomItem(qreal x, qreal y, qreal width, qreal height, const QBrush &brush) : + QGraphicsRectItem(x, y, width, height) +{ + setFlag(QGraphicsItem::ItemIsMovable); + setFlag(QGraphicsItem::ItemIsSelectable); + setBrush(brush); + setPen(Qt::NoPen); + setTransformOriginPoint(boundingRect().center()); +} diff --git a/tests/manual/qgraphicsitemgroup/customitem.h b/tests/manual/qgraphicsitemgroup/customitem.h new file mode 100644 index 0000000..387c8ce --- /dev/null +++ b/tests/manual/qgraphicsitemgroup/customitem.h @@ -0,0 +1,77 @@ +/**************************************************************************** +** +** 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 test suite 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$ +** +****************************************************************************/ + +#ifndef CUSTOMITEM_H +#define CUSTOMITEM_H + +#include +#include +#include + +class CustomGroup : public QGraphicsItemGroup +{ +public: + CustomGroup(); + virtual ~CustomGroup() { } + +protected: + virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget); + virtual QRectF boundingRect() const; +}; + +class CustomItem : public QGraphicsRectItem +{ +public: + CustomItem(qreal x, qreal y, qreal width, qreal height, const QBrush & brush = QBrush()); + virtual ~CustomItem() { } +}; + +class CustomScene : public QGraphicsScene +{ + Q_OBJECT +public: + CustomScene() : QGraphicsScene() { } + + QList selectedCustomItems() const; + QList selectedCustomGroups() const; +}; + +#endif // CUSTOMITEM_H diff --git a/tests/manual/qgraphicsitemgroup/main.cpp b/tests/manual/qgraphicsitemgroup/main.cpp new file mode 100644 index 0000000..e7a6e11 --- /dev/null +++ b/tests/manual/qgraphicsitemgroup/main.cpp @@ -0,0 +1,51 @@ +/**************************************************************************** +** +** 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 test suite 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 +#include "widget.h" + +int main(int argc, char *argv[]) +{ + QApplication a(argc, argv); + Widget w; + w.show(); + return a.exec(); +} diff --git a/tests/manual/qgraphicsitemgroup/qgraphicsitemgroup.pro b/tests/manual/qgraphicsitemgroup/qgraphicsitemgroup.pro new file mode 100644 index 0000000..6676a2e --- /dev/null +++ b/tests/manual/qgraphicsitemgroup/qgraphicsitemgroup.pro @@ -0,0 +1,8 @@ +TARGET = qgraphicsitemgroup +TEMPLATE = app +SOURCES += main.cpp \ + widget.cpp \ + customitem.cpp +HEADERS += widget.h \ + customitem.h +FORMS += widget.ui diff --git a/tests/manual/qgraphicsitemgroup/widget.cpp b/tests/manual/qgraphicsitemgroup/widget.cpp new file mode 100644 index 0000000..23bee3f --- /dev/null +++ b/tests/manual/qgraphicsitemgroup/widget.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 test suite 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 "widget.h" +#include "ui_widget.h" +#include +#include + +Widget::Widget(QWidget *parent) : + QWidget(parent), + ui(new Ui::Widget), + previousSelectionCount(0) +{ + ui->setupUi(this); + + effect = new QGraphicsOpacityEffect; + effect->setOpacity(0.3); + ui->groupBox->setGraphicsEffect(effect); + + fadeIn = new QPropertyAnimation(effect, "opacity"); + fadeIn->setDuration(200); + fadeIn->setStartValue(0.3); + fadeIn->setEndValue(1.); + + fadeOut = new QPropertyAnimation(effect, "opacity"); + fadeOut->setDuration(200); + fadeOut->setStartValue(1.); + fadeOut->setEndValue(0.3); + + scene = new CustomScene; + scene->setSceneRect(-250,-250,500,500); + ui->view->setScene(scene); + scene->setBackgroundBrush(Qt::white); + ui->view->setInteractive(true); + ui->view->setDragMode(QGraphicsView::RubberBandDrag); + ui->view->setViewportUpdateMode(QGraphicsView::FullViewportUpdate); + ui->view->setRenderHints( QPainter::SmoothPixmapTransform | + QPainter::TextAntialiasing | + QPainter::Antialiasing ); + + rectBlue = new CustomItem(-100, -100, 50, 50, QColor(80, 80, 200)); + scene->addItem(rectBlue); + rectGreen = new CustomItem(100, -100, 50, 50, QColor(80, 200, 80)); + scene->addItem(rectGreen); + rectRed = new CustomItem(-100, 100, 50, 50, QColor(200, 80, 80)); + scene->addItem(rectRed); + rectYellow = new CustomItem(100, 100, 50, 50, QColor(200, 200, 20)); + scene->addItem(rectYellow); + + connect(scene, SIGNAL(selectionChanged()), this, SLOT(onSceneSelectionChanged())); +} + +Widget::~Widget() +{ + delete ui; + delete fadeIn; + delete fadeOut; +} + +void Widget::on_rotate_valueChanged(int value) +{ + if (scene->selectedItems().count() != 1) + return; + + QGraphicsItem *item = scene->selectedItems().at(0); + item->setRotation(value); + ui->rotateItem->setValue(checkedItem()->rotation()); +} + +void Widget::on_scale_valueChanged(int value) +{ + if (scene->selectedItems().count() != 1) + return; + + QGraphicsItem *item = scene->selectedItems().at(0); + item->setScale(value / 10.); + ui->scaleItem->setValue(checkedItem()->scale() * 10); +} + +void Widget::on_rotateItem_valueChanged(int value) +{ + if (!scene->selectedItems().empty() && scene->selectedItems().at(0) == checkedItem()) + ui->rotate->setValue(value); + else + checkedItem()->setRotation(value); +} + +void Widget::on_scaleItem_valueChanged(int value) +{ + if (!scene->selectedItems().empty() && scene->selectedItems().at(0) == checkedItem()) + ui->scale->setValue(value); + else + checkedItem()->setScale(value / 10.); +} + +void Widget::on_group_clicked() +{ + QList all = scene->selectedItems(); + if (all.size() < 2) + return; + + QList items = scene->selectedCustomItems(); + QList groups = scene->selectedCustomGroups(); + + if (groups.size() == 1) { + foreach (CustomItem *item, items) { + item->setSelected(false); + groups[0]->addToGroup(item); + } + + return; + } + + CustomGroup* group = new CustomGroup; + scene->addItem(group); + foreach (QGraphicsItem *item, all) { + item->setSelected(false); + group->addToGroup(item); + } + group->setSelected(true); + + updateUngroupButton(); +} + +void Widget::on_dismantle_clicked() +{ + QList groups = scene->selectedCustomGroups(); + + foreach (CustomGroup *group, groups) { + foreach (QGraphicsItem *item, group->childItems()) + group->removeFromGroup(item); + + delete group; + } + + updateUngroupButton(); +} + +void Widget::on_merge_clicked() +{ + QList groups = scene->selectedCustomGroups(); + if (groups.size() < 2) + return; + + CustomGroup *newBigGroup = groups.takeFirst(); + foreach (CustomGroup *group, groups) { + foreach (QGraphicsItem *item, group->childItems()) + item->setGroup(newBigGroup); + + delete group; + } +} + +void Widget::onSceneSelectionChanged() +{ + QList all = scene->selectedItems(); + QList groups = scene->selectedCustomGroups(); + + if (all.empty() && all.count() != previousSelectionCount) { + fadeOut->start(); + } else if (previousSelectionCount == 0) { + fadeIn->start(); + } + + if (all.count() == 1) { + QGraphicsItem *item = all.at(0); + ui->rotate->setValue(item->rotation()); + ui->scale->setValue(item->scale() * 10); + } else { + ui->rotate->setValue(ui->rotate->minimum()); + ui->scale->setValue(ui->scale->minimum()); + } + + ui->rotate->setEnabled(all.size() == 1); + ui->scale->setEnabled(all.size() == 1); + ui->group->setEnabled(all.size() > 1); + ui->dismantle->setEnabled(!groups.empty()); + ui->merge->setEnabled(groups.size() > 1); + + previousSelectionCount = all.size(); + + updateUngroupButton(); +} + +void Widget::on_ungroup_clicked() +{ + QGraphicsItemGroup *oldGroup = checkedItem()->group(); + checkedItem()->setGroup(0); + if (oldGroup && oldGroup->childItems().empty()) + delete oldGroup; + + updateUngroupButton(); +} + +void Widget::updateUngroupButton() +{ + ui->ungroup->setEnabled(checkedItem()->group() != 0); +} + +CustomItem * Widget::checkedItem() const +{ + CustomItem *item; + + if (ui->blue->isChecked()) + item = rectBlue; + else if (ui->red->isChecked()) + item = rectRed; + else if (ui->green->isChecked()) + item = rectGreen; + else if (ui->yellow->isChecked()) + item = rectYellow; + + return item; +} + +void Widget::on_buttonGroup_buttonClicked() +{ + ui->rotateItem->setValue(checkedItem()->rotation()); + ui->scaleItem->setValue(checkedItem()->scale() * 10); + + updateUngroupButton(); +} diff --git a/tests/manual/qgraphicsitemgroup/widget.h b/tests/manual/qgraphicsitemgroup/widget.h new file mode 100644 index 0000000..affc436 --- /dev/null +++ b/tests/manual/qgraphicsitemgroup/widget.h @@ -0,0 +1,93 @@ +/**************************************************************************** +** +** 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 test suite 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$ +** +****************************************************************************/ + +#ifndef WIDGET_H +#define WIDGET_H + +#include "customitem.h" + +#include +#include +#include + +namespace Ui { + class Widget; +} + +class QGraphicsOpacityEffect; +class QPropertyAnimation; + +class Widget : public QWidget +{ + Q_OBJECT +public: + Widget(QWidget *parent = 0); + ~Widget(); + +protected Q_SLOTS: + void on_rotate_valueChanged(int value); + void on_scale_valueChanged(int value); + void on_rotateItem_valueChanged(int value); + void on_scaleItem_valueChanged(int value); + void on_group_clicked(); + void on_dismantle_clicked(); + void on_merge_clicked(); + void onSceneSelectionChanged(); + void on_ungroup_clicked(); + void on_buttonGroup_buttonClicked(); + +private: + void updateUngroupButton(); + CustomItem * checkedItem() const; + + Ui::Widget *ui; + CustomScene *scene; + CustomItem *rectBlue; + CustomItem *rectRed; + CustomItem *rectGreen; + CustomItem *rectYellow; + QGraphicsOpacityEffect* effect; + QPropertyAnimation *fadeIn; + QPropertyAnimation *fadeOut; + int previousSelectionCount; +}; + +#endif // WIDGET_H diff --git a/tests/manual/qgraphicsitemgroup/widget.ui b/tests/manual/qgraphicsitemgroup/widget.ui new file mode 100644 index 0000000..7e3a4df --- /dev/null +++ b/tests/manual/qgraphicsitemgroup/widget.ui @@ -0,0 +1,319 @@ + + + Widget + + + + 0 + 0 + 782 + 695 + + + + Widget + + + + + + + + Items + + + + + + + + + + Blue + + + true + + + buttonGroup + + + + + + + Red + + + buttonGroup + + + + + + + Green + + + buttonGroup + + + + + + + Yellow + + + buttonGroup + + + + + + + + + + + Rotate + + + + + + + true + + + + 120 + 0 + + + + 360 + + + Qt::Horizontal + + + + + + + Scale + + + + + + + true + + + + 120 + 0 + + + + 5 + + + 30 + + + 10 + + + Qt::Horizontal + + + + + + + + + + + false + + + Ungroup + + + + + + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 50 + 20 + + + + + + + + true + + + + 300 + 164 + + + + + 300 + 164 + + + + Selection + + + + + + + + false + + + Rotate + + + + + + + false + + + + 120 + 0 + + + + 360 + + + Qt::Horizontal + + + + + + + false + + + Scale + + + + + + + false + + + + 120 + 0 + + + + 5 + + + 30 + + + 10 + + + Qt::Horizontal + + + + + + + + + + + false + + + Group + + + + + + + false + + + Merge Groups + + + + + + + false + + + Dismantle Group + + + + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + + + + + + + + -- cgit v0.12 From 4e9063d7a8fc79d1cfee71d2c889877264d44086 Mon Sep 17 00:00:00 2001 From: Thierry Bastian Date: Fri, 11 Dec 2009 17:10:18 +0100 Subject: Itemviews: we needed to call ensurePolishedwhen asking for sizehints Reviewed-by: Pierre Rossi --- src/gui/itemviews/qabstractitemview.cpp | 4 ++++ src/gui/itemviews/qtreeview.cpp | 1 + 2 files changed, 5 insertions(+) diff --git a/src/gui/itemviews/qabstractitemview.cpp b/src/gui/itemviews/qabstractitemview.cpp index de6e6cb..4a450b7 100644 --- a/src/gui/itemviews/qabstractitemview.cpp +++ b/src/gui/itemviews/qabstractitemview.cpp @@ -2867,6 +2867,8 @@ int QAbstractItemView::sizeHintForRow(int row) const if (row < 0 || row >= d->model->rowCount() || !model()) return -1; + ensurePolished(); + QStyleOptionViewItemV4 option = d->viewOptionsV4(); int height = 0; int colCount = d->model->columnCount(d->root); @@ -2896,6 +2898,8 @@ int QAbstractItemView::sizeHintForColumn(int column) const if (column < 0 || column >= d->model->columnCount() || !model()) return -1; + ensurePolished(); + QStyleOptionViewItemV4 option = d->viewOptionsV4(); int width = 0; int rows = d->model->rowCount(d->root); diff --git a/src/gui/itemviews/qtreeview.cpp b/src/gui/itemviews/qtreeview.cpp index 3ad9fbb..bcf9cfb 100644 --- a/src/gui/itemviews/qtreeview.cpp +++ b/src/gui/itemviews/qtreeview.cpp @@ -2774,6 +2774,7 @@ int QTreeView::sizeHintForColumn(int column) const d->executePostedLayout(); if (d->viewItems.isEmpty()) return -1; + ensurePolished(); int w = 0; QStyleOptionViewItemV4 option = d->viewOptionsV4(); const QVector viewItems = d->viewItems; -- cgit v0.12 From f555e06c3e8eee7cc67218331562c11ad77ec9c4 Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Thu, 10 Dec 2009 15:33:21 +0100 Subject: Add missing benchmark to the benchmarks.pro This does not add the benchmark that runs too slowly. Reviewed-by: jasplin --- tests/benchmarks/benchmarks.pro | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/tests/benchmarks/benchmarks.pro b/tests/benchmarks/benchmarks.pro index 9170039..bffa009 100644 --- a/tests/benchmarks/benchmarks.pro +++ b/tests/benchmarks/benchmarks.pro @@ -20,6 +20,24 @@ SUBDIRS = containers-associative \ qregion \ qvariant \ qwidget \ - qtwidgets + qtwidgets \ + qapplication \ + qdir \ + qdiriterator \ + qgraphicsanchorlayout \ + qgraphicsitem \ + qgraphicswidget \ + qmetaobject \ + qpixmapcache \ + qquaternion \ + qscriptclass \ + qscriptengine \ + qscriptvalue \ + qstringbuilder \ + qstylesheetstyle \ + qsvgrenderer \ + qtableview + + contains(QT_CONFIG, opengl): SUBDIRS += opengl -- cgit v0.12 From c15c9cd2356eaeba33a5f8e62a90b0aeb45284e1 Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Fri, 11 Dec 2009 17:18:54 +0100 Subject: Fixes cursor blinking in the QComboBox when it becomes editable while having the focus. The lineedit has the focus because it becomes focusproxy of the QComboBox. But the focusInEvent is not called because the combobox has already the focus when setFocusProxy is called. Workaround that in the show event. Task-number: QTBUG-1949 Reviewed-by: Thierry --- src/gui/widgets/qlineedit.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/gui/widgets/qlineedit.cpp b/src/gui/widgets/qlineedit.cpp index 2c1acdb..15dcda2 100644 --- a/src/gui/widgets/qlineedit.cpp +++ b/src/gui/widgets/qlineedit.cpp @@ -1445,6 +1445,16 @@ bool QLineEdit::event(QEvent * e) d->control->processEvent(e); } else if (e->type() == QEvent::KeyRelease) { d->control->setCursorBlinkPeriod(QApplication::cursorFlashTime()); + } else if (e->type() == QEvent::Show) { + //In order to get the cursor blinking if QComboBox::setEditable is called when the combobox has focus + if (hasFocus()) { + d->control->setCursorBlinkPeriod(QApplication::cursorFlashTime()); + QStyleOptionFrameV2 opt; + initStyleOption(&opt); + if ((!hasSelectedText() && d->control->preeditAreaText().isEmpty()) + || style()->styleHint(QStyle::SH_BlinkCursorWhenTextSelected, &opt, this)) + d->setCursorVisible(true); + } } #ifdef QT_KEYPAD_NAVIGATION -- cgit v0.12 From 4879551f72a377e0816164ce1762eb646839f4a6 Mon Sep 17 00:00:00 2001 From: Rohan McGovern Date: Mon, 14 Dec 2009 14:46:52 +1000 Subject: OpenVG .def file updates. --- src/s60installs/eabi/QtGuiu.def | 41 ++++++++++++++++++++++++++++++++++++++ src/s60installs/eabi/QtOpenVGu.def | 8 ++++++-- 2 files changed, 47 insertions(+), 2 deletions(-) diff --git a/src/s60installs/eabi/QtGuiu.def b/src/s60installs/eabi/QtGuiu.def index 429ca79..bfad2e7 100644 --- a/src/s60installs/eabi/QtGuiu.def +++ b/src/s60installs/eabi/QtGuiu.def @@ -11741,4 +11741,45 @@ EXPORTS _ZN11QVectorPathD2Ev @ 11740 NONAME _ZNK11QVectorPath12addCacheDataEP14QPaintEngineExPvPFvS1_S2_E @ 11741 NONAME _ZNK20QGraphicsItemPrivate20discardUpdateRequestEbbb @ 11742 NONAME + _ZN11QEglContext10extensionsEv @ 11743 NONAME + _ZN11QEglContext10getDisplayEP12QPaintDevice @ 11744 NONAME + _ZN11QEglContext10waitClientEv @ 11745 NONAME + _ZN11QEglContext10waitNativeEv @ 11746 NONAME + _ZN11QEglContext11doneCurrentEv @ 11747 NONAME + _ZN11QEglContext11errorStringEi @ 11748 NONAME + _ZN11QEglContext11makeCurrentEi @ 11749 NONAME + _ZN11QEglContext11openDisplayEP12QPaintDevice @ 11750 NONAME + _ZN11QEglContext11swapBuffersEi @ 11751 NONAME + _ZN11QEglContext12chooseConfigERK14QEglPropertiesN4QEgl16PixelFormatMatchE @ 11752 NONAME + _ZN11QEglContext12hasExtensionEPKc @ 11753 NONAME + _ZN11QEglContext13createContextEPS_PK14QEglProperties @ 11754 NONAME + _ZN11QEglContext13createSurfaceEP12QPaintDevicePK14QEglProperties @ 11755 NONAME + _ZN11QEglContext14currentContextEN4QEgl3APIE @ 11756 NONAME + _ZN11QEglContext14defaultDisplayEP12QPaintDevice @ 11757 NONAME + _ZN11QEglContext14destroySurfaceEi @ 11758 NONAME + _ZN11QEglContext14dumpAllConfigsEv @ 11759 NONAME + _ZN11QEglContext15lazyDoneCurrentEv @ 11760 NONAME + _ZN11QEglContext17setCurrentContextEN4QEgl3APIEPS_ @ 11761 NONAME + _ZN11QEglContext7destroyEv @ 11762 NONAME + _ZN11QEglContextC1Ev @ 11763 NONAME + _ZN11QEglContextC2Ev @ 11764 NONAME + _ZN11QEglContextD1Ev @ 11765 NONAME + _ZN11QEglContextD2Ev @ 11766 NONAME + _ZN14QEglProperties11removeValueEi @ 11767 NONAME + _ZN14QEglProperties14dumpAllConfigsEv @ 11768 NONAME + _ZN14QEglProperties14setPixelFormatEN6QImage6FormatE @ 11769 NONAME + _ZN14QEglProperties17setRenderableTypeEN4QEgl3APIE @ 11770 NONAME + _ZN14QEglProperties19reduceConfigurationEv @ 11771 NONAME + _ZN14QEglProperties20setPaintDeviceFormatEP12QPaintDevice @ 11772 NONAME + _ZN14QEglProperties8setValueEii @ 11773 NONAME + _ZN14QEglPropertiesC1Ei @ 11774 NONAME + _ZN14QEglPropertiesC1Ev @ 11775 NONAME + _ZN14QEglPropertiesC2Ei @ 11776 NONAME + _ZN14QEglPropertiesC2Ev @ 11777 NONAME + _ZNK11QEglContext12configAttribEiPi @ 11778 NONAME + _ZNK11QEglContext16configPropertiesEi @ 11779 NONAME + _ZNK11QEglContext7isValidEv @ 11780 NONAME + _ZNK11QEglContext9isCurrentEv @ 11781 NONAME + _ZNK14QEglProperties5valueEi @ 11782 NONAME + _ZNK14QEglProperties8toStringEv @ 11783 NONAME diff --git a/src/s60installs/eabi/QtOpenVGu.def b/src/s60installs/eabi/QtOpenVGu.def index 8458983..7526632 100644 --- a/src/s60installs/eabi/QtOpenVGu.def +++ b/src/s60installs/eabi/QtOpenVGu.def @@ -1,8 +1,8 @@ EXPORTS _Z16qPixmapToVGImageRK7QPixmap @ 1 NONAME - _Z20qt_vg_create_contextP12QPaintDevice @ 2 NONAME + _Z20qt_vg_create_contextP12QPaintDevice @ 2 NONAME ABSENT _Z20qt_vg_shared_surfacev @ 3 NONAME - _Z21qt_vg_destroy_contextP11QEglContext @ 4 NONAME + _Z21qt_vg_destroy_contextP11QEglContext @ 4 NONAME ABSENT _Z24qt_vg_image_to_vg_formatN6QImage6FormatE @ 5 NONAME _Z25qt_vg_config_to_vg_formatP11QEglContext @ 6 NONAME _Z25qt_vg_create_paint_enginev @ 7 NONAME @@ -169,4 +169,8 @@ EXPORTS _ZThn8_NK16QVGWindowSurface6metricEN12QPaintDevice17PaintDeviceMetricE @ 168 NONAME _ZN14QVGPaintEngine10fillRegionERK7QRegionRK6QColorRK5QSize @ 169 NONAME _ZN20QVGCompositionHelper10blitWindowEmRK5QSizeRK5QRectRK6QPointi @ 170 NONAME + _Z20qt_vg_create_contextP12QPaintDevicei @ 171 NONAME + _Z21qt_vg_destroy_contextP11QEglContexti @ 172 NONAME + _ZN13QVGPixmapData22destroyImageAndContextEv @ 173 NONAME + _ZN13QVGPixmapData9hibernateEv @ 174 NONAME -- cgit v0.12 From 006b48d5f998d0beba9431a7688c928f0f5f9ad6 Mon Sep 17 00:00:00 2001 From: Gunnar Sletta Date: Mon, 14 Dec 2009 09:11:36 +0100 Subject: Fixed spelling in docs --- src/gui/painting/qpainter.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/gui/painting/qpainter.cpp b/src/gui/painting/qpainter.cpp index 13d9a04..33496a9 100644 --- a/src/gui/painting/qpainter.cpp +++ b/src/gui/painting/qpainter.cpp @@ -1321,8 +1321,8 @@ void QPainterPrivate::updateState(QPainterState *newState) QPainter is a rich framework that allows developers to do a great variety of graphical operations, such as gradients, composition - modes and vector graphcis. And QPainter can do this across a - variety of different hardware and software stack. Naturally the + modes and vector graphics. And QPainter can do this across a + variety of different hardware and software stacks. Naturally the underlying combination of hardware and software has some implications for performance, and ensuring that every single operation is fast in combination with all the various combinations @@ -1344,13 +1344,13 @@ void QPainterPrivate::updateState(QPainterState *newState) including QImage::Format_ARGB32, has significantly worse performance. This engine is also used by default on Windows and on QWS. It can be used as default graphics system on any - OS/hardware/software combination by passing \c {-graphcissystem + OS/hardware/software combination by passing \c {-graphicssystem raster} on the command line \o OpenGL 2.0 (ES) - This backend is the primary backend for - hardware accellerated graphics. It can be run on desktop machines + hardware accelerated graphics. It can be run on desktop machines and embedded devices supporting the OpenGL 2.0 or OpenGL/ES 2.0 - spesification. This includes most graphics chips produced in the + specification. This includes most graphics chips produced in the last couple of years. The engine can be enabled by using QPainter onto a QGLWidget or by passing \c {-graphicssystem opengl} on the command line when the underlying system supports it. @@ -1366,7 +1366,7 @@ void QPainterPrivate::updateState(QPainterState *newState) \o \c drawPixmap() in combination with simple transformations and opacity with non-smooth transformation mode - (\c QPainter::SmoothPixmapTransform not enabled as a render hint); + (\c QPainter::SmoothPixmapTransform not enabled as a render hint). \o Text drawing with regular font sizes with simple transformations with solid colors using no or 8-bit antialiasing. -- cgit v0.12 From 76213ac8028079a9933548625bd917f49862f4c1 Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Mon, 14 Dec 2009 10:31:21 +0100 Subject: Fix warning in public header qcache.h:73: warning: declaration of 'object' shadows a member of this Spotted by compilerwarnings autotest Reviewed-by: Thiago --- src/corelib/tools/qcache.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/corelib/tools/qcache.h b/src/corelib/tools/qcache.h index 086a52f..66f9f73 100644 --- a/src/corelib/tools/qcache.h +++ b/src/corelib/tools/qcache.h @@ -70,9 +70,9 @@ class QCache if (l == &n) l = n.p; if (f == &n) f = n.n; total -= n.c; - T *object = n.t; + T *obj = n.t; hash.remove(*n.keyPtr); - delete object; + delete obj; } inline T *relink(const Key &key) { typename QHash::iterator i = hash.find(key); -- cgit v0.12 From 8b46b4cc0e1df56d40535b381986eb455806c589 Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Mon, 14 Dec 2009 10:51:25 +0100 Subject: Stabilize test --- tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp | 1 + tests/auto/qsharedmemory/tst_qsharedmemory.cpp | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp index a4931ab..03a587a 100644 --- a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp +++ b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp @@ -1354,6 +1354,7 @@ void tst_QGraphicsItem::selected() view.setFixedSize(250, 250); view.show(); + QTest::qWaitForWindowShown(&view); qApp->processEvents(); qApp->processEvents(); diff --git a/tests/auto/qsharedmemory/tst_qsharedmemory.cpp b/tests/auto/qsharedmemory/tst_qsharedmemory.cpp index f72b6f7..4148594 100644 --- a/tests/auto/qsharedmemory/tst_qsharedmemory.cpp +++ b/tests/auto/qsharedmemory/tst_qsharedmemory.cpp @@ -756,12 +756,12 @@ void tst_QSharedMemory::simpleProcessProducerConsumer() ++failedProcesses; } - producer.waitForFinished(5000); + QVERIFY(producer.waitForFinished(5000)); bool consumerFailed = false; while (!consumers.isEmpty()) { - consumers.first()->waitForFinished(2000); + QVERIFY(consumers.first()->waitForFinished(3000)); if (consumers.first()->state() == QProcess::Running || consumers.first()->exitStatus() != QProcess::NormalExit || consumers.first()->exitCode() != 0) { -- cgit v0.12 From 08da5b53b6f4564057b99bf9076ec350b4ebeb35 Mon Sep 17 00:00:00 2001 From: Gunnar Sletta Date: Mon, 14 Dec 2009 13:11:20 +0100 Subject: Added vg to the performance section of the QPainter docs --- src/gui/painting/qpainter.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/gui/painting/qpainter.cpp b/src/gui/painting/qpainter.cpp index 33496a9..8ed126f 100644 --- a/src/gui/painting/qpainter.cpp +++ b/src/gui/painting/qpainter.cpp @@ -1355,6 +1355,12 @@ void QPainterPrivate::updateState(QPainterState *newState) onto a QGLWidget or by passing \c {-graphicssystem opengl} on the command line when the underlying system supports it. + \o OpenVG - This backend implements the Khronos standard for 2D + and Vector Graphics. It is primarily for embedded devices with + hardware support for OpenVG. The engine can be enabled by + passing \c {-graphicssystem openvg} on the command line when + the underlying system supports it. + \endlist These operations are: -- cgit v0.12 From 0295f8da10d6c920511d09f9e506b8bed8c444c3 Mon Sep 17 00:00:00 2001 From: David Faure Date: Tue, 6 Oct 2009 21:39:02 +0200 Subject: Determine QPrinterInfo's supportedPaperSizes on demand. The paper size determination requires a cupsGetPPD(), which can be a slow HTTP download. So doing it on demand makes QPrinterInfo::defaultPrinter() much faster, because it doesn't actually need the paper sizes at all. Before this fix, it was requesting the PPD file of every known CUPS printer, every time it was called. My battery of unittests for code that uses QPrinter went from 19 minutes when the cups print server is switched off, to 13 seconds! This fix also removes some code duplication, which is always nice. Task-number: 232664, QTBUG-3033 Reviewed-by: Trond --- src/gui/painting/qprinterinfo_unix.cpp | 50 ++++++++++++++++++++-------------- 1 file changed, 29 insertions(+), 21 deletions(-) diff --git a/src/gui/painting/qprinterinfo_unix.cpp b/src/gui/painting/qprinterinfo_unix.cpp index 6684ff7..930785b 100644 --- a/src/gui/painting/qprinterinfo_unix.cpp +++ b/src/gui/painting/qprinterinfo_unix.cpp @@ -75,7 +75,9 @@ private: QString m_name; bool m_isNull; bool m_default; - QList m_paperSizes; + mutable bool m_mustGetPaperSizes; + mutable QList m_paperSizes; + int m_cupsPrinterIndex; QPrinterInfo* q_ptr; }; @@ -838,16 +840,7 @@ QList QPrinterInfo::availablePrinters() list.append(QPrinterInfo(printerName)); if (cupsPrinters[i].is_default) list[i].d_ptr->m_default = true; - // Find paper sizes. - cups.setCurrentPrinter(i); - const ppd_option_t* sizes = cups.pageSizes(); - if (sizes) { - for (int j = 0; j < sizes->num_choices; ++j) { - list[i].d_ptr->m_paperSizes.append( - QPrinterInfoPrivate::string2PaperSize( - QLatin1String(sizes->choices[j].choice))); - } - } + list[i].d_ptr->m_cupsPrinterIndex = i; } } else { #endif @@ -909,16 +902,7 @@ QPrinterInfo::QPrinterInfo(const QPrinter& printer) if (printerName == printer.printerName()) { if (cupsPrinters[i].is_default) d->m_default = true; - // Find paper sizes. - cups.setCurrentPrinter(i); - const ppd_option_t* sizes = cups.pageSizes(); - if (sizes) { - for (int j = 0; j < sizes->num_choices; ++j) { - d->m_paperSizes.append( - QPrinterInfoPrivate::string2PaperSize( - QLatin1String(sizes->choices[j].choice))); - } - } + d->m_cupsPrinterIndex = i; return; } } @@ -983,6 +967,26 @@ bool QPrinterInfo::isDefault() const QList< QPrinter::PaperSize> QPrinterInfo::supportedPaperSizes() const { const Q_D(QPrinterInfo); + if (d->m_mustGetPaperSizes) { + d->m_mustGetPaperSizes = false; + +#if !defined(QT_NO_CUPS) && !defined(QT_NO_LIBRARY) + QCUPSSupport cups; + if (QCUPSSupport::isAvailable()) { + // Find paper sizes from CUPS. + cups.setCurrentPrinter(d->m_cupsPrinterIndex); + const ppd_option_t* sizes = cups.pageSizes(); + if (sizes) { + for (int j = 0; j < sizes->num_choices; ++j) { + d->m_paperSizes.append( + QPrinterInfoPrivate::string2PaperSize( + QLatin1String(sizes->choices[j].choice))); + } + } + } +#endif + + } return d->m_paperSizes; } @@ -993,6 +997,8 @@ QPrinterInfoPrivate::QPrinterInfoPrivate() { m_isNull = true; m_default = false; + m_mustGetPaperSizes = true; + m_cupsPrinterIndex = 0; q_ptr = 0; } @@ -1001,6 +1007,8 @@ QPrinterInfoPrivate::QPrinterInfoPrivate(const QString& name) m_name = name; m_isNull = false; m_default = false; + m_mustGetPaperSizes = true; + m_cupsPrinterIndex = 0; q_ptr = 0; } -- cgit v0.12 From 504d6d4ac0d782c1fbca1f2dc1e8425dac773113 Mon Sep 17 00:00:00 2001 From: Rohan McGovern Date: Tue, 15 Dec 2009 11:59:56 +1000 Subject: Fixed compile for S60 (.def file updates). More private API changes, and mark QEgl symbols as ABSENT so compilation is not broken when OpenVG is disabled. --- src/s60installs/eabi/QtGuiu.def | 92 +++++++++++++++++++++-------------------- 1 file changed, 47 insertions(+), 45 deletions(-) diff --git a/src/s60installs/eabi/QtGuiu.def b/src/s60installs/eabi/QtGuiu.def index bfad2e7..b6862e5 100644 --- a/src/s60installs/eabi/QtGuiu.def +++ b/src/s60installs/eabi/QtGuiu.def @@ -698,13 +698,13 @@ EXPORTS _ZN11QFontDialogD2Ev @ 697 NONAME _ZN11QFontEngine11boundingBoxEjRK10QTransform @ 698 NONAME _ZN11QFontEngine11grayPaletteEv @ 699 NONAME - _ZN11QFontEngine13setGlyphCacheEN21QFontEngineGlyphCache4TypeEPS0_ @ 700 NONAME + _ZN11QFontEngine13setGlyphCacheEN21QFontEngineGlyphCache4TypeEPS0_ @ 700 NONAME ABSENT _ZN11QFontEngine13setGlyphCacheEPvP21QFontEngineGlyphCache @ 701 NONAME _ZN11QFontEngine15addGlyphsToPathEPjP11QFixedPointiP12QPainterPath6QFlagsIN9QTextItem10RenderFlagEE @ 702 NONAME _ZN11QFontEngine16addOutlineToPathEffRK12QGlyphLayoutP12QPainterPath6QFlagsIN9QTextItem10RenderFlagEE @ 703 NONAME _ZN11QFontEngine16alphaMapForGlyphEj @ 704 NONAME _ZN11QFontEngine16alphaMapForGlyphEjRK10QTransform @ 705 NONAME - _ZN11QFontEngine16expireGlyphCacheEv @ 706 NONAME + _ZN11QFontEngine16expireGlyphCacheEv @ 706 NONAME ABSENT _ZN11QFontEngine16getUnscaledGlyphEjP12QPainterPathP15glyph_metrics_t @ 707 NONAME _ZN11QFontEngine16loadKerningPairsE6QFixed @ 708 NONAME _ZN11QFontEngine16tightBoundingBoxERK12QGlyphLayout @ 709 NONAME @@ -7615,8 +7615,8 @@ EXPORTS _ZNK11QFontDialog11currentFontEv @ 7614 NONAME _ZNK11QFontDialog12selectedFontEv @ 7615 NONAME _ZNK11QFontDialog7optionsEv @ 7616 NONAME - _ZNK11QFontEngine10glyphCacheEN21QFontEngineGlyphCache4TypeERK10QTransform @ 7617 NONAME - _ZNK11QFontEngine10glyphCacheEPvRK10QTransform @ 7618 NONAME + _ZNK11QFontEngine10glyphCacheEN21QFontEngineGlyphCache4TypeERK10QTransform @ 7617 NONAME ABSENT + _ZNK11QFontEngine10glyphCacheEPvRK10QTransform @ 7618 NONAME ABSENT _ZNK11QFontEngine10glyphCountEv @ 7619 NONAME _ZNK11QFontEngine10propertiesEv @ 7620 NONAME _ZNK11QFontEngine12getSfntTableEj @ 7621 NONAME @@ -11741,45 +11741,47 @@ EXPORTS _ZN11QVectorPathD2Ev @ 11740 NONAME _ZNK11QVectorPath12addCacheDataEP14QPaintEngineExPvPFvS1_S2_E @ 11741 NONAME _ZNK20QGraphicsItemPrivate20discardUpdateRequestEbbb @ 11742 NONAME - _ZN11QEglContext10extensionsEv @ 11743 NONAME - _ZN11QEglContext10getDisplayEP12QPaintDevice @ 11744 NONAME - _ZN11QEglContext10waitClientEv @ 11745 NONAME - _ZN11QEglContext10waitNativeEv @ 11746 NONAME - _ZN11QEglContext11doneCurrentEv @ 11747 NONAME - _ZN11QEglContext11errorStringEi @ 11748 NONAME - _ZN11QEglContext11makeCurrentEi @ 11749 NONAME - _ZN11QEglContext11openDisplayEP12QPaintDevice @ 11750 NONAME - _ZN11QEglContext11swapBuffersEi @ 11751 NONAME - _ZN11QEglContext12chooseConfigERK14QEglPropertiesN4QEgl16PixelFormatMatchE @ 11752 NONAME - _ZN11QEglContext12hasExtensionEPKc @ 11753 NONAME - _ZN11QEglContext13createContextEPS_PK14QEglProperties @ 11754 NONAME - _ZN11QEglContext13createSurfaceEP12QPaintDevicePK14QEglProperties @ 11755 NONAME - _ZN11QEglContext14currentContextEN4QEgl3APIE @ 11756 NONAME - _ZN11QEglContext14defaultDisplayEP12QPaintDevice @ 11757 NONAME - _ZN11QEglContext14destroySurfaceEi @ 11758 NONAME - _ZN11QEglContext14dumpAllConfigsEv @ 11759 NONAME - _ZN11QEglContext15lazyDoneCurrentEv @ 11760 NONAME - _ZN11QEglContext17setCurrentContextEN4QEgl3APIEPS_ @ 11761 NONAME - _ZN11QEglContext7destroyEv @ 11762 NONAME - _ZN11QEglContextC1Ev @ 11763 NONAME - _ZN11QEglContextC2Ev @ 11764 NONAME - _ZN11QEglContextD1Ev @ 11765 NONAME - _ZN11QEglContextD2Ev @ 11766 NONAME - _ZN14QEglProperties11removeValueEi @ 11767 NONAME - _ZN14QEglProperties14dumpAllConfigsEv @ 11768 NONAME - _ZN14QEglProperties14setPixelFormatEN6QImage6FormatE @ 11769 NONAME - _ZN14QEglProperties17setRenderableTypeEN4QEgl3APIE @ 11770 NONAME - _ZN14QEglProperties19reduceConfigurationEv @ 11771 NONAME - _ZN14QEglProperties20setPaintDeviceFormatEP12QPaintDevice @ 11772 NONAME - _ZN14QEglProperties8setValueEii @ 11773 NONAME - _ZN14QEglPropertiesC1Ei @ 11774 NONAME - _ZN14QEglPropertiesC1Ev @ 11775 NONAME - _ZN14QEglPropertiesC2Ei @ 11776 NONAME - _ZN14QEglPropertiesC2Ev @ 11777 NONAME - _ZNK11QEglContext12configAttribEiPi @ 11778 NONAME - _ZNK11QEglContext16configPropertiesEi @ 11779 NONAME - _ZNK11QEglContext7isValidEv @ 11780 NONAME - _ZNK11QEglContext9isCurrentEv @ 11781 NONAME - _ZNK14QEglProperties5valueEi @ 11782 NONAME - _ZNK14QEglProperties8toStringEv @ 11783 NONAME + _ZN11QEglContext10extensionsEv @ 11743 NONAME ABSENT + _ZN11QEglContext10getDisplayEP12QPaintDevice @ 11744 NONAME ABSENT + _ZN11QEglContext10waitClientEv @ 11745 NONAME ABSENT + _ZN11QEglContext10waitNativeEv @ 11746 NONAME ABSENT + _ZN11QEglContext11doneCurrentEv @ 11747 NONAME ABSENT + _ZN11QEglContext11errorStringEi @ 11748 NONAME ABSENT + _ZN11QEglContext11makeCurrentEi @ 11749 NONAME ABSENT + _ZN11QEglContext11openDisplayEP12QPaintDevice @ 11750 NONAME ABSENT + _ZN11QEglContext11swapBuffersEi @ 11751 NONAME ABSENT + _ZN11QEglContext12chooseConfigERK14QEglPropertiesN4QEgl16PixelFormatMatchE @ 11752 NONAME ABSENT + _ZN11QEglContext12hasExtensionEPKc @ 11753 NONAME ABSENT + _ZN11QEglContext13createContextEPS_PK14QEglProperties @ 11754 NONAME ABSENT + _ZN11QEglContext13createSurfaceEP12QPaintDevicePK14QEglProperties @ 11755 NONAME ABSENT + _ZN11QEglContext14currentContextEN4QEgl3APIE @ 11756 NONAME ABSENT + _ZN11QEglContext14defaultDisplayEP12QPaintDevice @ 11757 NONAME ABSENT + _ZN11QEglContext14destroySurfaceEi @ 11758 NONAME ABSENT + _ZN11QEglContext14dumpAllConfigsEv @ 11759 NONAME ABSENT + _ZN11QEglContext15lazyDoneCurrentEv @ 11760 NONAME ABSENT + _ZN11QEglContext17setCurrentContextEN4QEgl3APIEPS_ @ 11761 NONAME ABSENT + _ZN11QEglContext7destroyEv @ 11762 NONAME ABSENT + _ZN11QEglContextC1Ev @ 11763 NONAME ABSENT + _ZN11QEglContextC2Ev @ 11764 NONAME ABSENT + _ZN11QEglContextD1Ev @ 11765 NONAME ABSENT + _ZN11QEglContextD2Ev @ 11766 NONAME ABSENT + _ZN14QEglProperties11removeValueEi @ 11767 NONAME ABSENT + _ZN14QEglProperties14dumpAllConfigsEv @ 11768 NONAME ABSENT + _ZN14QEglProperties14setPixelFormatEN6QImage6FormatE @ 11769 NONAME ABSENT + _ZN14QEglProperties17setRenderableTypeEN4QEgl3APIE @ 11770 NONAME ABSENT + _ZN14QEglProperties19reduceConfigurationEv @ 11771 NONAME ABSENT + _ZN14QEglProperties20setPaintDeviceFormatEP12QPaintDevice @ 11772 NONAME ABSENT + _ZN14QEglProperties8setValueEii @ 11773 NONAME ABSENT + _ZN14QEglPropertiesC1Ei @ 11774 NONAME ABSENT + _ZN14QEglPropertiesC1Ev @ 11775 NONAME ABSENT + _ZN14QEglPropertiesC2Ei @ 11776 NONAME ABSENT + _ZN14QEglPropertiesC2Ev @ 11777 NONAME ABSENT + _ZNK11QEglContext12configAttribEiPi @ 11778 NONAME ABSENT + _ZNK11QEglContext16configPropertiesEi @ 11779 NONAME ABSENT + _ZNK11QEglContext7isValidEv @ 11780 NONAME ABSENT + _ZNK11QEglContext9isCurrentEv @ 11781 NONAME ABSENT + _ZNK14QEglProperties5valueEi @ 11782 NONAME ABSENT + _ZNK14QEglProperties8toStringEv @ 11783 NONAME ABSENT + _ZNK11QFontEngine10glyphCacheEPvN21QFontEngineGlyphCache4TypeERK10QTransform @ 11784 NONAME + _ZNK20QGraphicsItemPrivate21effectiveBoundingRectERK6QRectF @ 11785 NONAME -- cgit v0.12 From 1a867a3c692e375565618532b8ca686dab7e7d5e Mon Sep 17 00:00:00 2001 From: Rohan McGovern Date: Tue, 15 Dec 2009 18:54:43 +1000 Subject: def file maintenance. --- src/s60installs/bwins/QtCoreu.def | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/s60installs/bwins/QtCoreu.def b/src/s60installs/bwins/QtCoreu.def index 49c4361..fe752c8 100644 --- a/src/s60installs/bwins/QtCoreu.def +++ b/src/s60installs/bwins/QtCoreu.def @@ -2264,7 +2264,7 @@ EXPORTS ?isSequential@QIODevice@@UBE_NXZ @ 2263 NONAME ; bool QIODevice::isSequential(void) const ?isSequential@QIODevicePrivate@@QBE_NXZ @ 2264 NONAME ; bool QIODevicePrivate::isSequential(void) const ?isSequential@QProcess@@UBE_NXZ @ 2265 NONAME ; bool QProcess::isSequential(void) const - ?isSignalConnected@QObjectPrivate@@QBE_NH@Z @ 2266 NONAME ; bool QObjectPrivate::isSignalConnected(int) const + ?isSignalConnected@QObjectPrivate@@QBE_NI@Z @ 2266 NONAME ; bool QObjectPrivate::isSignalConnected(unsigned int) const ?isSimpleText@QString@@QBE_NXZ @ 2267 NONAME ; bool QString::isSimpleText(void) const ?isSingleShot@QTimer@@QBE_NXZ @ 2268 NONAME ; bool QTimer::isSingleShot(void) const ?isSpace@QChar@@QBE_NXZ @ 2269 NONAME ; bool QChar::isSpace(void) const -- cgit v0.12