From 1b6c1054c1ad8f99665ceaa958da01b1383a3e34 Mon Sep 17 00:00:00 2001 From: Janne Anttila Date: Wed, 2 Dec 2009 10:19:41 +0200 Subject: Fixed "illegal empty declaration" warning from \tools\xmlpatterns The following warning was reported by Symbian compilers: tools\xmlpatterns\main.cpp:83: warning: illegal empty declaration Reviewed-by: TrustMe --- tools/xmlpatterns/main.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/xmlpatterns/main.cpp b/tools/xmlpatterns/main.cpp index a930b70..604523b 100644 --- a/tools/xmlpatterns/main.cpp +++ b/tools/xmlpatterns/main.cpp @@ -80,14 +80,14 @@ QT_USE_NAMESPACE Represents the name and value found in "-param name=value". */ typedef QPair Parameter; -Q_DECLARE_METATYPE(Parameter); +Q_DECLARE_METATYPE(Parameter) /*! \internal \since 4.4 For the -output switch. */ -Q_DECLARE_METATYPE(QIODevice *); +Q_DECLARE_METATYPE(QIODevice *) /*! \class PatternistApplicationParser -- cgit v0.12 From 7c70e69511817127aa4691339af4a6aa07c1502a Mon Sep 17 00:00:00 2001 From: Janne Anttila Date: Wed, 2 Dec 2009 12:40:50 +0200 Subject: Fixed crash on Symbian when using QProgressDialog::setCancelButton(0). The crash occured since d->cancelAction is child of d->cancelButton, which is essentially same as d->cancel pointer. Due to parent/child relationship, deleting d->cancel deleted also chilren including cancelAction. Then explicitly deleting already deleted d->cancelAction (dangling pointer) caused KERN-EXEC 3 crash. There is no need to delete d->cancelAction since it is deleted via parent/child relationship. Task-number: QTBUG-6109 Reviewed-by: Miikka Heikkinen --- src/gui/dialogs/qprogressdialog.cpp | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/gui/dialogs/qprogressdialog.cpp b/src/gui/dialogs/qprogressdialog.cpp index f5024bb..98b15e9 100644 --- a/src/gui/dialogs/qprogressdialog.cpp +++ b/src/gui/dialogs/qprogressdialog.cpp @@ -424,10 +424,6 @@ void QProgressDialog::setCancelButton(QPushButton *cancelButton) { Q_D(QProgressDialog); delete d->cancel; -#ifdef QT_SOFTKEYS_ENABLED - delete d->cancelAction; - d->cancelAction = 0; -#endif d->cancel = cancelButton; if (cancelButton) { if (cancelButton->parentWidget() == this) { -- cgit v0.12 From 855d2702ffff37452ff3bc0e1576d1d17fdb76c2 Mon Sep 17 00:00:00 2001 From: Janne Anttila Date: Wed, 2 Dec 2009 15:08:53 +0200 Subject: Fixed softkey merging/traversing over window boundaries. If current dialog implementation had parent and no softkeys set, the dialog got softkeys from parent. This commit changes the behaviour so that softkeys are not traversed over window boundaries. Also added autotest for the bug report. Task-number: QTBUG-6163 Reviewed-by: Jason Barron --- src/gui/kernel/qsoftkeymanager.cpp | 2 +- tests/auto/qsoftkeymanager/tst_qsoftkeymanager.cpp | 62 ++++++++++++++++++++++ 2 files changed, 63 insertions(+), 1 deletion(-) diff --git a/src/gui/kernel/qsoftkeymanager.cpp b/src/gui/kernel/qsoftkeymanager.cpp index 775d773..1acc9b3 100644 --- a/src/gui/kernel/qsoftkeymanager.cpp +++ b/src/gui/kernel/qsoftkeymanager.cpp @@ -190,7 +190,7 @@ bool QSoftKeyManager::event(QEvent *e) } QWidget *parent = source->parentWidget(); - if (parent && softKeys.isEmpty()) + if (parent && softKeys.isEmpty() && !source->isWindow()) source = parent; else break; diff --git a/tests/auto/qsoftkeymanager/tst_qsoftkeymanager.cpp b/tests/auto/qsoftkeymanager/tst_qsoftkeymanager.cpp index 87e0533..f923739 100644 --- a/tests/auto/qsoftkeymanager/tst_qsoftkeymanager.cpp +++ b/tests/auto/qsoftkeymanager/tst_qsoftkeymanager.cpp @@ -73,6 +73,7 @@ private slots: void updateSoftKeysCompressed(); void handleCommand(); void checkSoftkeyEnableStates(); + void noMergingOverWindowBoundary(); private: // utils inline void simulateSymbianCommand(int command) @@ -235,5 +236,66 @@ void tst_QSoftKeyManager::checkSoftkeyEnableStates() QCOMPARE(spy1.count(), 5); } +/* + This tests that the softkeys are not merged over window boundaries. I.e. dialogs + don't get softkeys of base widget by default - QTBUG-6163. +*/ +void tst_QSoftKeyManager::noMergingOverWindowBoundary() +{ + // Create base window against which the dialog softkeys will ve verified + QWidget base; + + QAction* baseLeft = new QAction(tr("BaseLeft"), &base); + baseLeft->setSoftKeyRole(QAction::PositiveSoftKey); + base.addAction(baseLeft); + + QAction* baseRight = new QAction(tr("BaseRight"), &base); + baseRight->setSoftKeyRole(QAction::NegativeSoftKey); + base.addAction(baseRight); + + base.showMaximized(); + QApplication::processEvents(); + + QSignalSpy baseLeftSpy(baseLeft, SIGNAL(triggered())); + QSignalSpy baseRightSpy(baseRight, SIGNAL(triggered())); + + //Verify that both base softkeys emit triggered signals + simulateSymbianCommand(s60CommandStart); + simulateSymbianCommand(s60CommandStart + 1); + + QCOMPARE(baseLeftSpy.count(), 1); + QCOMPARE(baseRightSpy.count(), 1); + baseLeftSpy.clear(); + baseRightSpy.clear(); + + // Verify that no softkey merging when using dialog without parent + QDialog dlg; + dlg.show(); + + QApplication::processEvents(); + + simulateSymbianCommand(s60CommandStart); + simulateSymbianCommand(s60CommandStart + 1); + + QCOMPARE(baseLeftSpy.count(), 0); + QCOMPARE(baseRightSpy.count(), 0); + + // Ensure base view has focus again + dlg.hide(); + base.showMaximized(); + + // Verify that no softkey merging when using dialog with parent + QDialog dlg2(&base); + dlg2.show(); + + QApplication::processEvents(); + + simulateSymbianCommand(s60CommandStart); + simulateSymbianCommand(s60CommandStart + 1); + + QCOMPARE(baseLeftSpy.count(), 0); + QCOMPARE(baseRightSpy.count(), 0); +} + QTEST_MAIN(tst_QSoftKeyManager) #include "tst_qsoftkeymanager.moc" -- cgit v0.12 From ccde429536ba29dceb1576b6b981a812b0b846fc Mon Sep 17 00:00:00 2001 From: Yoann Lopes Date: Wed, 2 Dec 2009 15:31:09 +0100 Subject: Fixes transformation problems with QGraphicsProxyWidget. In the paintEvent of the widget used in a QGraphicsProxyWidget, the worldMatrix was wrongly used by the painter instead of the deviceMatrix. Similar problem in the WindowsXP Style, the worldMatrix was used instead of the deviceMatrix for determining if the widget is transformed (reviewed by eblomfel). Task-number: QTBUG-5939 Reviewed-by: bnilsen Reviewed-by: Eskil Abrahamsen Blomfeldt --- src/gui/painting/qpainter.cpp | 2 +- src/gui/styles/qwindowsxpstyle.cpp | 3 +- tests/auto/qpainter/tst_qpainter.cpp | 58 +++++++++++++++++++++++++++++++++++- 3 files changed, 59 insertions(+), 4 deletions(-) diff --git a/src/gui/painting/qpainter.cpp b/src/gui/painting/qpainter.cpp index 443c9c5..30f8c9e 100644 --- a/src/gui/painting/qpainter.cpp +++ b/src/gui/painting/qpainter.cpp @@ -284,7 +284,7 @@ bool QPainterPrivate::attachPainterPrivate(QPainter *q, QPaintDevice *pdev) // Update matrix. if (q->d_ptr->state->WxF) { - q->d_ptr->state->redirectionMatrix *= q->d_ptr->state->worldMatrix; + q->d_ptr->state->redirectionMatrix = q->d_ptr->state->matrix; q->d_ptr->state->redirectionMatrix.translate(-offset.x(), -offset.y()); q->d_ptr->state->worldMatrix = QTransform(); q->d_ptr->state->WxF = false; diff --git a/src/gui/styles/qwindowsxpstyle.cpp b/src/gui/styles/qwindowsxpstyle.cpp index fe7f5d7..0767083 100644 --- a/src/gui/styles/qwindowsxpstyle.cpp +++ b/src/gui/styles/qwindowsxpstyle.cpp @@ -623,8 +623,7 @@ void QWindowsXPStylePrivate::drawBackground(XPThemeData &themeData) painter->save(); - QMatrix m = painter->matrix(); - bool complexXForm = m.m11() != 1.0 || m.m22() != 1.0 || m.m12() != 0.0 || m.m21() != 0.0; + bool complexXForm = painter->deviceTransform().type() > QTransform::TxTranslate; bool translucentToplevel = false; QPaintDevice *pdev = painter->device(); diff --git a/tests/auto/qpainter/tst_qpainter.cpp b/tests/auto/qpainter/tst_qpainter.cpp index 8b71349..67d1972 100644 --- a/tests/auto/qpainter/tst_qpainter.cpp +++ b/tests/auto/qpainter/tst_qpainter.cpp @@ -41,7 +41,7 @@ #include - +#include "../../shared/util.h" #include #include @@ -67,6 +67,11 @@ #include +#include +#include +#include +#include + #if defined(Q_OS_SYMBIAN) # define SRCDIR "." #endif @@ -244,6 +249,8 @@ private slots: void setPenColorOnImage(); void setPenColorOnPixmap(); + void QTBUG5939_attachPainterPrivate(); + private: void fillData(); void setPenColor(QPainter& p); @@ -4404,6 +4411,55 @@ void tst_QPainter::setPenColorOnPixmap() setPenColor(p); } +class TestProxy : public QGraphicsProxyWidget +{ +public: + TestProxy() : QGraphicsProxyWidget() {} + void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) + { + QGraphicsProxyWidget::paint(painter, option, widget); + deviceTransform = painter->deviceTransform(); + } + QTransform deviceTransform; +}; + +class TestWidget : public QWidget +{ +Q_OBJECT +public: + TestWidget() : QWidget(), painted(false) {} + void paintEvent(QPaintEvent *) + { + QPainter p(this); + deviceTransform = p.deviceTransform(); + worldTransform = p.worldTransform(); + painted = true; + } + QTransform deviceTransform; + QTransform worldTransform; + bool painted; +}; + +void tst_QPainter::QTBUG5939_attachPainterPrivate() +{ + QWidget *w = new QWidget(); + QGraphicsScene *scene = new QGraphicsScene(); + QGraphicsView *view = new QGraphicsView(scene, w); + view->move(50 ,50); + TestProxy *proxy = new TestProxy(); + TestWidget *widget = new TestWidget(); + proxy->setWidget(widget); + scene->addItem(proxy); + proxy->rotate(45); + w->resize(scene->sceneRect().size().toSize()); + + w->show(); + QTRY_VERIFY(widget->painted); + + QVERIFY(widget->worldTransform.isIdentity()); + QCOMPARE(widget->deviceTransform, proxy->deviceTransform); +} + QTEST_MAIN(tst_QPainter) #include "tst_qpainter.moc" -- cgit v0.12 From bc49609893d79dc12af459dad8750530da37e5ec Mon Sep 17 00:00:00 2001 From: Aleksandar Sasha Babic Date: Wed, 2 Dec 2009 15:26:21 +0100 Subject: qreal-ization Adding more wrapper math related functions. This should enable us to have more control over which calls are actually made. Don't worry too much for some "if" statements, the compiler is smart enough to make direct calls to specific math functions. Task-number: QTBUG-4894 Reviewed-by: axis --- src/corelib/kernel/qmath.h | 57 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) diff --git a/src/corelib/kernel/qmath.h b/src/corelib/kernel/qmath.h index a9e4378..820f424 100644 --- a/src/corelib/kernel/qmath.h +++ b/src/corelib/kernel/qmath.h @@ -76,6 +76,16 @@ inline int qFloor(qreal v) return int(floor(v)); } +inline qreal qFabs(qreal v) +{ +#ifdef QT_USE_MATH_H_FLOATS + if(sizeof(qreal) == sizeof(float)) + return fabsf(float(v)); + else +#endif + return fabs(v); +} + inline qreal qSin(qreal v) { #ifdef QT_USE_MATH_H_FLOATS @@ -96,6 +106,16 @@ inline qreal qCos(qreal v) return cos(v); } +inline qreal qTan(qreal v) +{ +#ifdef QT_USE_MATH_H_FLOATS + if (sizeof(qreal) == sizeof(float)) + return tanf(float(v)); + else +#endif + return tan(v); +} + inline qreal qAcos(qreal v) { #ifdef QT_USE_MATH_H_FLOATS @@ -106,6 +126,36 @@ inline qreal qAcos(qreal v) return acos(v); } +inline qreal qAsin(qreal v) +{ +#ifdef QT_USE_MATH_H_FLOATS + if (sizeof(qreal) == sizeof(float)) + return asinf(float(v)); + else +#endif + return asin(v); +} + +inline qreal qAtan(qreal v) +{ +#ifdef QT_USE_MATH_H_FLOATS + if(sizeof(qreal) == sizeof(float)) + return atanf(float(v)); + else +#endif + return atan(v); +} + +inline qreal qAtan2(qreal x, qreal y) +{ +#ifdef QT_USE_MATH_H_FLOATS + if(sizeof(qreal) == sizeof(float)) + return atan2f(float(x), float(y)); + else +#endif + return atan2(x, y); +} + inline qreal qSqrt(qreal v) { #ifdef QT_USE_MATH_H_FLOATS @@ -126,6 +176,13 @@ inline qreal qLn(qreal v) return log(v); } +inline qreal qExp(qreal v) +{ + // only one signature + // exists, exp(double) + return exp(v); +} + inline qreal qPow(qreal x, qreal y) { #ifdef QT_USE_MATH_H_FLOATS -- cgit v0.12 From ac94288ba71722981894fc7577b781aa76d5f7de Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Wed, 2 Dec 2009 16:27:00 +0100 Subject: Fix tst_QSystemLock::processes Paths were not correct --- tests/auto/qsharedmemory/qsystemlock/tst_qsystemlock.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/auto/qsharedmemory/qsystemlock/tst_qsystemlock.cpp b/tests/auto/qsharedmemory/qsystemlock/tst_qsystemlock.cpp index 35f05d1..518cdbf 100644 --- a/tests/auto/qsharedmemory/qsystemlock/tst_qsystemlock.cpp +++ b/tests/auto/qsharedmemory/qsystemlock/tst_qsystemlock.cpp @@ -202,9 +202,9 @@ void tst_QSystemLock::processes() QStringList scripts; for (int i = 0; i < readOnly; ++i) - scripts.append(QFileInfo(SRCDIR "lackey/scripts/ systemlock_read.js").absoluteFilePath() ); + scripts.append(QFileInfo(SRCDIR "/../lackey/scripts/systemlock_read.js").absoluteFilePath() ); for (int i = 0; i < readWrite; ++i) - scripts.append(QFileInfo(SRCDIR "lackey/scripts/systemlock_readwrite.js").absoluteFilePath()); + scripts.append(QFileInfo(SRCDIR "/../lackey/scripts/systemlock_readwrite.js").absoluteFilePath()); QList consumers; unsigned int failedProcesses = 0; @@ -213,8 +213,8 @@ void tst_QSystemLock::processes() QStringList arguments = QStringList() << scripts.at(i); QProcess *p = new QProcess; p->setProcessChannelMode(QProcess::ForwardedChannels); - - p->start(QFileInfo(SRCDIR "lackey/lackey").absoluteFilePath(), arguments); + + p->start("../lackey/lackey", arguments); // test, if the process could be started. if (p->waitForStarted(2000)) -- cgit v0.12 From 78b2e552cca92859b2c126751ca5fc6fd83dd5cf Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Wed, 2 Dec 2009 19:10:26 +0100 Subject: Stabilize tests on X11 --- tests/auto/qdoublespinbox/tst_qdoublespinbox.cpp | 9 ++++++--- tests/auto/qlineedit/tst_qlineedit.cpp | 1 + tests/auto/qlistview/tst_qlistview.cpp | 4 +++- tests/auto/qspinbox/tst_qspinbox.cpp | 5 ++++- 4 files changed, 14 insertions(+), 5 deletions(-) diff --git a/tests/auto/qdoublespinbox/tst_qdoublespinbox.cpp b/tests/auto/qdoublespinbox/tst_qdoublespinbox.cpp index 157c39d..7f03153 100644 --- a/tests/auto/qdoublespinbox/tst_qdoublespinbox.cpp +++ b/tests/auto/qdoublespinbox/tst_qdoublespinbox.cpp @@ -1065,17 +1065,20 @@ void tst_QDoubleSpinBox::taskQTBUG_5008_textFromValueAndValidate() //we use the French delimiters here QString textFromValue (double value) const - { + { return locale().toString(value); } } spinbox; spinbox.show(); spinbox.activateWindow(); spinbox.setFocus(); + QApplication::setActiveWindow(&spinbox); QTest::qWaitForWindowShown(&spinbox); - QCOMPARE(spinbox.text(), spinbox.locale().toString(spinbox.value())); + QTRY_VERIFY(spinbox.hasFocus()); + QTRY_COMPARE(static_cast(&spinbox), QApplication::activeWindow()); + QCOMPARE(spinbox.text(), spinbox.locale().toString(spinbox.value())); spinbox.lineEdit()->setCursorPosition(2); //just after the first thousand separator - QTest::keyClick(0, Qt::Key_0); // let's insert a 0 + QTest::keyClick(0, Qt::Key_0); // let's insert a 0 QCOMPARE(spinbox.value(), 10000.); spinbox.clearFocus(); //make sure the value is correctly formatted QCOMPARE(spinbox.text(), spinbox.locale().toString(spinbox.value())); diff --git a/tests/auto/qlineedit/tst_qlineedit.cpp b/tests/auto/qlineedit/tst_qlineedit.cpp index 79d1b3a..8b8078b 100644 --- a/tests/auto/qlineedit/tst_qlineedit.cpp +++ b/tests/auto/qlineedit/tst_qlineedit.cpp @@ -3360,6 +3360,7 @@ void tst_QLineEdit::task174640_editingFinished() QApplication::setActiveWindow(&mw); mw.activateWindow(); QTest::qWaitForWindowShown(&mw); + QTRY_COMPARE(&mw, QApplication::activeWindow()); QSignalSpy editingFinishedSpy(le1, SIGNAL(editingFinished())); diff --git a/tests/auto/qlistview/tst_qlistview.cpp b/tests/auto/qlistview/tst_qlistview.cpp index 24a553f..98001c8 100644 --- a/tests/auto/qlistview/tst_qlistview.cpp +++ b/tests/auto/qlistview/tst_qlistview.cpp @@ -1787,8 +1787,10 @@ void tst_QListView::task262152_setModelColumnNavigate() view.setModelColumn(1); view.show(); + QApplication::setActiveWindow(&view); QTest::qWaitForWindowShown(&view); - QTest::qWait(120); + QTest::qWait(30); + QTRY_COMPARE(static_cast(&view), QApplication::activeWindow()); QTest::keyClick(&view, Qt::Key_Down); QTest::qWait(30); QTRY_COMPARE(view.currentIndex(), model.index(1,1)); diff --git a/tests/auto/qspinbox/tst_qspinbox.cpp b/tests/auto/qspinbox/tst_qspinbox.cpp index cd65135..e5e63a0 100644 --- a/tests/auto/qspinbox/tst_qspinbox.cpp +++ b/tests/auto/qspinbox/tst_qspinbox.cpp @@ -1025,7 +1025,7 @@ void tst_QSpinBox::taskQTBUG_5008_textFromValueAndValidate() //we use the French delimiters here QString textFromValue (int value) const - { + { return locale().toString(value); } @@ -1033,7 +1033,10 @@ void tst_QSpinBox::taskQTBUG_5008_textFromValueAndValidate() spinbox.show(); spinbox.activateWindow(); spinbox.setFocus(); + QApplication::setActiveWindow(&spinbox); QTest::qWaitForWindowShown(&spinbox); + QTRY_VERIFY(spinbox.hasFocus()); + QTRY_COMPARE(static_cast(&spinbox), QApplication::activeWindow()); QCOMPARE(spinbox.text(), spinbox.locale().toString(spinbox.value())); spinbox.lineEdit()->setCursorPosition(2); //just after the first thousand separator QTest::keyClick(0, Qt::Key_0); // let's insert a 0 -- cgit v0.12 From ae2c3a96519ede274bd3a67566f007b1cba24ff8 Mon Sep 17 00:00:00 2001 From: Gabriel de Dietrich Date: Wed, 2 Dec 2009 12:42:38 +0100 Subject: QCompleter wouldn't emit highlighted() and activated() signals Completion was checked before sending the textEdited() signal from QLineEdit. The behaviour has been reverted as in 4.5. Reviewed-by: aalpert Task-number: QTBUG-6386 --- src/gui/widgets/qlineedit_p.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/gui/widgets/qlineedit_p.cpp b/src/gui/widgets/qlineedit_p.cpp index d03c003..4437fef 100644 --- a/src/gui/widgets/qlineedit_p.cpp +++ b/src/gui/widgets/qlineedit_p.cpp @@ -103,12 +103,12 @@ void QLineEditPrivate::_q_handleWindowActivate() void QLineEditPrivate::_q_textEdited(const QString &text) { Q_Q(QLineEdit); + emit q->textEdited(text); #ifndef QT_NO_COMPLETER - if (control->completer() && - control->completer()->completionMode() != QCompleter::InlineCompletion) + if (control->completer() + && control->completer()->completionMode() != QCompleter::InlineCompletion) control->complete(-1); // update the popup on cut/paste/del #endif - emit q->textEdited(text); } void QLineEditPrivate::_q_cursorPositionChanged(int from, int to) -- cgit v0.12 From 5cab18e5e3946b0dc14d678c8a317522d25e3003 Mon Sep 17 00:00:00 2001 From: Alexis Menard Date: Thu, 3 Dec 2009 10:54:58 +0100 Subject: Add extra auto-test for topLevel list corruption. Adding auto-tests make QA people happy. Reviewed-by:TrustMe --- tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp | 36 ++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp b/tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp index a8017ff..38abc3d 100644 --- a/tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp +++ b/tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp @@ -4211,6 +4211,42 @@ void tst_QGraphicsScene::siblingIndexAlwaysValid() //If there are in the list that's bad, we crash... QVERIFY(!QGraphicsScenePrivate::get(&scene)->topLevelItems.contains(static_cast(child))); + //Other case + QGraphicsScene scene2; + // works with bsp tree index + scene2.setItemIndexMethod(QGraphicsScene::NoIndex); + + QGraphicsView view2(&scene2); + + // first add the blue rect + QGraphicsRectItem* const item1 = new QGraphicsRectItem(QRect( 10, 10, 10, 10 )); + item1->setPen(QColor(Qt::blue)); + item1->setBrush(Qt::blue); + scene2.addItem(item1); + + // then add the red rect + QGraphicsRectItem* const item2 = new QGraphicsRectItem(5, 5, 10, 10); + item2->setPen(QColor(Qt::red)); + item2->setBrush(Qt::red); + scene2.addItem(item2); + + // now the blue one is visible on top of the red one -> swap them (important for the bug) + item1->setZValue(1.0); + item2->setZValue(0.0); + + view2.show(); + + // handle events as a real life app would do + QApplication::processEvents(); + + // now delete the red rect + delete item2; + + // handle events as a real life app would do + QApplication::processEvents(); + + //We should not crash + } void tst_QGraphicsScene::taskQTBUG_5904_crashWithDeviceCoordinateCache() -- cgit v0.12 From 2263a796ac6fc84002ff075eb6cbc67e0ec27802 Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Thu, 3 Dec 2009 17:20:03 +0100 Subject: Fixes broken selection with Shift and extended selection ItemAt() is in viewport coordinate. Pressed index is in coordinate relative to the whole view (regression since Qt 4.5) Reviewed-by: thierry Task-number: QTBUG-6407 --- src/gui/itemviews/qabstractitemview.cpp | 4 +-- .../qabstractitemview/tst_qabstractitemview.cpp | 42 ++++++++++++++++++++++ 2 files changed, 44 insertions(+), 2 deletions(-) diff --git a/src/gui/itemviews/qabstractitemview.cpp b/src/gui/itemviews/qabstractitemview.cpp index acfeff8..de6e6cb 100644 --- a/src/gui/itemviews/qabstractitemview.cpp +++ b/src/gui/itemviews/qabstractitemview.cpp @@ -1625,7 +1625,7 @@ void QAbstractItemView::mousePressEvent(QMouseEvent *event) QPoint offset = d->offset(); if ((command & QItemSelectionModel::Current) == 0) d->pressedPosition = pos + offset; - else if (!indexAt(d->pressedPosition).isValid()) + else if (!indexAt(d->pressedPosition - offset).isValid()) d->pressedPosition = visualRect(currentIndex()).center() + offset; if (edit(index, NoEditTriggers, event)) @@ -2195,7 +2195,7 @@ void QAbstractItemView::keyPressEvent(QKeyEvent *event) // note that we don't check if the new current index is enabled because moveCursor() makes sure it is if (command & QItemSelectionModel::Current) { d->selectionModel->setCurrentIndex(newCurrent, QItemSelectionModel::NoUpdate); - if (!indexAt(d->pressedPosition).isValid()) + if (!indexAt(d->pressedPosition - d->offset()).isValid()) d->pressedPosition = visualRect(oldCurrent).center() + d->offset(); QRect rect(d->pressedPosition - d->offset(), visualRect(newCurrent).center()); setSelection(rect, command); diff --git a/tests/auto/qabstractitemview/tst_qabstractitemview.cpp b/tests/auto/qabstractitemview/tst_qabstractitemview.cpp index db840f4..6479829 100644 --- a/tests/auto/qabstractitemview/tst_qabstractitemview.cpp +++ b/tests/auto/qabstractitemview/tst_qabstractitemview.cpp @@ -46,6 +46,7 @@ #include #include #include +#include #include #include #include @@ -224,6 +225,7 @@ private slots: void shiftArrowSelectionAfterScrolling(); void shiftSelectionAfterRubberbandSelection(); void ctrlRubberbandSelection(); + void QTBUG6407_extendedSelection(); }; class MyAbstractItemDelegate : public QAbstractItemDelegate @@ -1433,5 +1435,45 @@ void tst_QAbstractItemView::ctrlRubberbandSelection() QVERIFY(selected.contains(index2)); } +void tst_QAbstractItemView::QTBUG6407_extendedSelection() +{ + QListWidget view; + view.setSelectionMode(QAbstractItemView::ExtendedSelection); + for(int i = 0; i < 50; ++i) + view.addItem(QString::number(i)); + + view.resize(200,200); + + view.show(); + QApplication::setActiveWindow(&view); + QTest::qWaitForWindowShown(&view); + QTRY_COMPARE(static_cast(&view), QApplication::activeWindow()); + + view.verticalScrollBar()->setValue(view.verticalScrollBar()->maximum()); + QTest::qWait(20); + + QModelIndex index49 = view.model()->index(49,0); + QPoint p = view.visualRect(index49).center(); + QVERIFY(view.viewport()->rect().contains(p)); + QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, p); + QCOMPARE(view.currentIndex(), index49); + QCOMPARE(view.selectedItems().count(), 1); + + QModelIndex index47 = view.model()->index(47,0); + p = view.visualRect(index47).center(); + QVERIFY(view.viewport()->rect().contains(p)); + QTest::mouseClick(view.viewport(), Qt::LeftButton, Qt::ShiftModifier, p); + QCOMPARE(view.currentIndex(), index47); + QCOMPARE(view.selectedItems().count(), 3); //49, 48, 47; + + QModelIndex index44 = view.model()->index(44,0); + p = view.visualRect(index44).center(); + QVERIFY(view.viewport()->rect().contains(p)); + QTest::mouseClick(view.viewport(), Qt::LeftButton, Qt::ShiftModifier, p); + QCOMPARE(view.currentIndex(), index44); + QCOMPARE(view.selectedItems().count(), 6); //49 .. 44; + +} + QTEST_MAIN(tst_QAbstractItemView) #include "tst_qabstractitemview.moc" -- cgit v0.12 From 0ced23b6af63c42b04977faf94deb3ff0a57ff4e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan-Arve=20S=C3=A6ther?= Date: Thu, 3 Dec 2009 21:35:20 +0100 Subject: Some doc fixes - Remove a lie. - When referring to the size of an anchor, refer to it consistently as 'spacing' instead of magnitude. --- src/gui/graphicsview/qgraphicsanchorlayout.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gui/graphicsview/qgraphicsanchorlayout.cpp b/src/gui/graphicsview/qgraphicsanchorlayout.cpp index 686096c..6718a28 100644 --- a/src/gui/graphicsview/qgraphicsanchorlayout.cpp +++ b/src/gui/graphicsview/qgraphicsanchorlayout.cpp @@ -158,7 +158,7 @@ QGraphicsAnchor::~QGraphicsAnchor() \property QGraphicsAnchor::sizePolicy \brief the size policy for the QGraphicsAnchor. - By setting the size policy on an anchor you can configure how the item can resize itself + By setting the size policy on an anchor you can configure how the anchor can resize itself from its preferred spacing. For instance, if the anchor has the size policy QSizePolicy::Minimum, the spacing is the minimum size of the anchor. However, its size can grow up to the anchors maximum size. If the default size policy is QSizePolicy::Fixed, @@ -247,7 +247,7 @@ QGraphicsAnchorLayout::~QGraphicsAnchorLayout() /*! Creates an anchor between the edge \a firstEdge of item \a firstItem and the edge \a secondEdge - of item \a secondItem. The magnitude of the anchor is picked up from the style. Anchors + of item \a secondItem. The spacing of the anchor is picked up from the style. Anchors between a layout edge and an item edge will have a size of 0. If there is already an anchor between the edges, the the new anchor will replace the old one. -- cgit v0.12 From 108ab335537d20bc74aa9115d46cf91243223c4e Mon Sep 17 00:00:00 2001 From: Rhys Weatherley Date: Fri, 4 Dec 2009 17:03:41 +1000 Subject: Better check for EGL extension strings The previous code might have failed if the desired extension name was a prefix of another name: "EGL_foo" member of "EGL_foo_bar". This change introduces a more precise check. Task-number: QTBUG-6454 Reviewed-by: Sarah Smith --- src/gui/egl/qegl.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/gui/egl/qegl.cpp b/src/gui/egl/qegl.cpp index cf28dc4..6ee4bfc 100644 --- a/src/gui/egl/qegl.cpp +++ b/src/gui/egl/qegl.cpp @@ -429,7 +429,10 @@ QString QEglContext::extensions() bool QEglContext::hasExtension(const char* extensionName) { - return extensions().contains(QLatin1String(extensionName)); + QList extensions = + QByteArray(reinterpret_cast + (eglQueryString(QEglContext::defaultDisplay(0), EGL_EXTENSIONS))).split(' '); + return extensions.contains(extensionName); } QEglContext *QEglContext::currentContext(QEgl::API api) -- cgit v0.12 From c0b81480b2909b18ac15bdd124a562ae005c2f41 Mon Sep 17 00:00:00 2001 From: Rhys Weatherley Date: Fri, 4 Dec 2009 17:17:00 +1000 Subject: Rebind window surface fbo after native GL rendering If the user called QGLFramebufferObject::bind()/release() during a beginNativePainting() callout, the release() would reset the context's fbo to zero, not the actual window surface fbo. Task-number: QTBUG-6204 Reviewed-by: Tom --- src/opengl/qgl.cpp | 1 + src/opengl/qgl_p.h | 1 + src/opengl/qglframebufferobject.cpp | 4 ++-- src/opengl/qglpaintdevice.cpp | 10 ++++++++++ 4 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/opengl/qgl.cpp b/src/opengl/qgl.cpp index 5ada125..94b8aa5 100644 --- a/src/opengl/qgl.cpp +++ b/src/opengl/qgl.cpp @@ -1495,6 +1495,7 @@ void QGLContextPrivate::init(QPaintDevice *dev, const QGLFormat &format) version_flags_cached = false; version_flags = QGLFormat::OpenGL_Version_None; current_fbo = 0; + default_fbo = 0; active_engine = 0; } diff --git a/src/opengl/qgl_p.h b/src/opengl/qgl_p.h index 8e472e5..ab72c9c 100644 --- a/src/opengl/qgl_p.h +++ b/src/opengl/qgl_p.h @@ -328,6 +328,7 @@ public: GLint max_texture_size; GLuint current_fbo; + GLuint default_fbo; QPaintEngine *active_engine; static inline QGLContextGroup *contextGroup(const QGLContext *ctx) { return ctx->d_ptr->group; } diff --git a/src/opengl/qglframebufferobject.cpp b/src/opengl/qglframebufferobject.cpp index d79283e..d0297c9 100644 --- a/src/opengl/qglframebufferobject.cpp +++ b/src/opengl/qglframebufferobject.cpp @@ -899,8 +899,8 @@ bool QGLFramebufferObject::release() #endif if (current) { - current->d_ptr->current_fbo = 0; - glBindFramebuffer(GL_FRAMEBUFFER_EXT, 0); + current->d_ptr->current_fbo = current->d_ptr->default_fbo; + glBindFramebuffer(GL_FRAMEBUFFER_EXT, current->d_ptr->default_fbo); } return true; diff --git a/src/opengl/qglpaintdevice.cpp b/src/opengl/qglpaintdevice.cpp index 2867de5..bcd90a5 100644 --- a/src/opengl/qglpaintdevice.cpp +++ b/src/opengl/qglpaintdevice.cpp @@ -89,6 +89,12 @@ void QGLPaintDevice::beginPaint() ctx->d_ptr->current_fbo = m_thisFBO; glBindFramebuffer(GL_FRAMEBUFFER_EXT, m_thisFBO); } + + // Set the default fbo for the context to m_thisFBO so that + // if some raw GL code between beginNativePainting() and + // endNativePainting() calls QGLFramebufferObject::release(), + // painting will revert to the window surface's fbo. + ctx->d_ptr->default_fbo = m_thisFBO; } void QGLPaintDevice::ensureActiveTarget() @@ -101,6 +107,8 @@ void QGLPaintDevice::ensureActiveTarget() ctx->d_ptr->current_fbo = m_thisFBO; glBindFramebuffer(GL_FRAMEBUFFER_EXT, m_thisFBO); } + + ctx->d_ptr->default_fbo = m_thisFBO; } void QGLPaintDevice::endPaint() @@ -111,6 +119,8 @@ void QGLPaintDevice::endPaint() ctx->d_ptr->current_fbo = m_previousFBO; glBindFramebuffer(GL_FRAMEBUFFER_EXT, m_previousFBO); } + + ctx->d_ptr->default_fbo = 0; } QGLFormat QGLPaintDevice::format() const -- cgit v0.12