From a76c8424dab298c2fa36226f47bf7ac6f7e4014a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Trond=20Kjern=C3=A5sen?= Date: Mon, 1 Mar 2010 15:28:36 +0100 Subject: Fixed qDrawPixmaps() to draw on integer coordinates on Mac OS X. This is the 4.7 port of d04f5336f769d9e5d2f9105e1da4a7d23ea91795. Task-number: related to QTBUG-8455 Reviewed-by: Kim --- src/gui/painting/qpainter.cpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/gui/painting/qpainter.cpp b/src/gui/painting/qpainter.cpp index dc96c17..9d83718 100644 --- a/src/gui/painting/qpainter.cpp +++ b/src/gui/painting/qpainter.cpp @@ -8933,8 +8933,15 @@ void QPainter::drawPixmapFragments(const Fragment *fragments, int fragmentCount, for (int i = 0; i < fragmentCount; ++i) { QTransform transform = oldTransform; - transform.translate(fragments[i].x, fragments[i].y); - transform.rotate(fragments[i].rotation); + qreal xOffset = 0; + qreal yOffset = 0; + if (fragments[i].rotation == 0) { + xOffset = fragments[i].x; + yOffset = fragments[i].y; + } else { + transform.translate(fragments[i].x, fragments[i].y); + transform.rotate(fragments[i].rotation); + } setOpacity(oldOpacity * fragments[i].opacity); setTransform(transform); @@ -8942,7 +8949,7 @@ void QPainter::drawPixmapFragments(const Fragment *fragments, int fragmentCount, qreal h = fragments[i].scaleY * fragments[i].height; QRectF sourceRect(fragments[i].sourceLeft, fragments[i].sourceTop, fragments[i].width, fragments[i].height); - drawPixmap(QRectF(-0.5 * w, -0.5 * h, w, h), pixmap, sourceRect); + drawPixmap(QRectF(-0.5 * w + xOffset, -0.5 * h + yOffset, w, h), pixmap, sourceRect); } setOpacity(oldOpacity); -- cgit v0.12 From 31f2d97e28dff1a72511ab1ef7737e5f78d4cf66 Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Mon, 1 Mar 2010 12:40:33 +0100 Subject: QMetaObject::invokeMethod: print a warning if the method is not found. Also adapt QTestLib not to call invokeMethod on unexisting method to avoid warnings Task-number: QTBUG-7331 Reviewed-by: Brad --- src/corelib/kernel/qmetaobject.cpp | 5 ++++- src/testlib/qtestcase.cpp | 28 +++++++++++++++++++++------- tests/auto/qmetaobject/tst_qmetaobject.cpp | 13 +++++++++++++ 3 files changed, 38 insertions(+), 8 deletions(-) diff --git a/src/corelib/kernel/qmetaobject.cpp b/src/corelib/kernel/qmetaobject.cpp index be1b2ae..ecffe99 100644 --- a/src/corelib/kernel/qmetaobject.cpp +++ b/src/corelib/kernel/qmetaobject.cpp @@ -1137,8 +1137,11 @@ bool QMetaObject::invokeMethod(QObject *obj, idx = obj->metaObject()->indexOfMethod(norm.constData()); } - if (idx < 0 || idx >= obj->metaObject()->methodCount()) + if (idx < 0 || idx >= obj->metaObject()->methodCount()) { + qWarning("QMetaObject::invokeMethod: No such method %s::%s", + obj->metaObject()->className(), sig.constData()); return false; + } QMetaMethod method = obj->metaObject()->method(idx); return method.invoke(obj, type, ret, val0, val1, val2, val3, val4, val5, val6, val7, val8, val9); diff --git a/src/testlib/qtestcase.cpp b/src/testlib/qtestcase.cpp index 5c9dd55..4590f17 100644 --- a/src/testlib/qtestcase.cpp +++ b/src/testlib/qtestcase.cpp @@ -877,6 +877,19 @@ int qt_snprintf(char *str, int size, const char *format, ...) return res; } +/*! \internal + Invoke a method of the object without generating warning if the method does not exist + */ +static void invokeMethod(QObject *obj, const char *methodName) +{ + const QMetaObject *metaObject = obj->metaObject(); + int funcIndex = metaObject->indexOfMethod(methodName); + if (funcIndex >= 0) { + QMetaMethod method = metaObject->method(funcIndex); + method.invoke(obj, Qt::DirectConnection); + } +} + bool Q_TESTLIB_EXPORT defaultKeyVerbose() { if (keyVerbose == -1) { @@ -1213,7 +1226,7 @@ static void qInvokeTestMethodDataEntry(char *slot) bool invokeOk; do { QTestResult::setCurrentTestLocation(QTestResult::InitFunc); - QMetaObject::invokeMethod(QTest::currentTestObject, "init"); + invokeMethod(QTest::currentTestObject, "init()"); if (QTestResult::skipCurrentTest()) break; @@ -1233,7 +1246,7 @@ static void qInvokeTestMethodDataEntry(char *slot) QTestResult::addFailure("Unable to execute slot", __FILE__, __LINE__); QTestResult::setCurrentTestLocation(QTestResult::CleanupFunc); - QMetaObject::invokeMethod(QTest::currentTestObject, "cleanup"); + invokeMethod(QTest::currentTestObject, "cleanup()"); QTestResult::setCurrentTestLocation(QTestResult::NoWhere); // If this test method has a benchmark, repeat until all measurements are @@ -1300,8 +1313,9 @@ static bool qInvokeTestMethod(const char *slotName, const char *data=0) if (curGlobalDataIndex == 0) { QTestResult::setCurrentTestLocation(QTestResult::DataFunc); - QTest::qt_snprintf(member, 512, "%s_data", slot); - QMetaObject::invokeMethod(QTest::currentTestObject, member, Qt::DirectConnection); + QTest::qt_snprintf(member, 512, "%s_data()", slot); + invokeMethod(QTest::currentTestObject, member); + // if we encounter a SkipAll in the _data slot, we skip the whole // testfunction, no matter how much global data exists if (QTestResult::skipCurrentTest()) { @@ -1466,11 +1480,11 @@ static void qInvokeTestMethods(QObject *testObject) QTestResult::setCurrentTestFunction("initTestCase"); QTestResult::setCurrentTestLocation(QTestResult::DataFunc); QTestTable::globalTestTable(); - QMetaObject::invokeMethod(testObject, "initTestCase_data", Qt::DirectConnection); + invokeMethod(testObject, "initTestCase_data()"); if (!QTestResult::skipCurrentTest() && !QTest::currentTestFailed()) { QTestResult::setCurrentTestLocation(QTestResult::InitFunc); - QMetaObject::invokeMethod(testObject, "initTestCase"); + invokeMethod(testObject, "initTestCase()"); // finishedCurrentTestFunction() resets QTestResult::testFailed(), so use a local copy. const bool previousFailed = QTestResult::testFailed(); @@ -1498,7 +1512,7 @@ static void qInvokeTestMethods(QObject *testObject) QTestResult::setSkipCurrentTest(false); QTestResult::setCurrentTestFunction("cleanupTestCase"); - QMetaObject::invokeMethod(testObject, "cleanupTestCase"); + invokeMethod(testObject, "cleanupTestCase()"); } QTestResult::finishedCurrentTestFunction(); QTestResult::setCurrentTestFunction(0); diff --git a/tests/auto/qmetaobject/tst_qmetaobject.cpp b/tests/auto/qmetaobject/tst_qmetaobject.cpp index 15b6204..bd54975 100644 --- a/tests/auto/qmetaobject/tst_qmetaobject.cpp +++ b/tests/auto/qmetaobject/tst_qmetaobject.cpp @@ -513,6 +513,19 @@ void tst_QMetaObject::invokeMetaMember() QVERIFY(QMetaObject::invokeMethod(&obj, "sig1", Q_RETURN_ARG(QString, exp), Q_ARG(QString, "hehe"))); QCOMPARE(exp, QString("yessir")); QCOMPARE(obj.slotResult, QString("sl1:hehe")); + + QTest::ignoreMessage(QtWarningMsg, "QMetaObject::invokeMethod: No such method QtTestObject::doesNotExist()"); + QVERIFY(!QMetaObject::invokeMethod(&obj, "doesNotExist")); + QTest::ignoreMessage(QtWarningMsg, "QMetaObject::invokeMethod: No such method QtTestObject::sl1(QString)(QString)"); + QVERIFY(!QMetaObject::invokeMethod(&obj, "sl1(QString)", Q_ARG(QString, "arg"))); + QTest::ignoreMessage(QtWarningMsg, "QMetaObject::invokeMethod: No such method QtTestObject::sl3(QString)"); + QVERIFY(!QMetaObject::invokeMethod(&obj, "sl3", Q_ARG(QString, "arg"))); + QTest::ignoreMessage(QtWarningMsg, "QMetaObject::invokeMethod: No such method QtTestObject::sl1(QString,QString,QString)"); + QVERIFY(!QMetaObject::invokeMethod(&obj, "sl1", Q_ARG(QString, "arg"), Q_ARG(QString, "arg"), Q_ARG(QString, "arg"))); + + //should not have changed since last test. + QCOMPARE(exp, QString("yessir")); + QCOMPARE(obj.slotResult, QString("sl1:hehe")); } void tst_QMetaObject::invokeQueuedMetaMember() -- cgit v0.12 From 83c37c2cdf7adf2604e1e6012a9e0e6e67d97d6b Mon Sep 17 00:00:00 2001 From: Thierry Bastian Date: Mon, 1 Mar 2010 17:31:44 +0100 Subject: removed dead code Reviewed-by: denis --- src/gui/kernel/qcursor_mac.mm | 33 ++++++++++++--------------------- 1 file changed, 12 insertions(+), 21 deletions(-) diff --git a/src/gui/kernel/qcursor_mac.mm b/src/gui/kernel/qcursor_mac.mm index cfebf60..03e38b0 100644 --- a/src/gui/kernel/qcursor_mac.mm +++ b/src/gui/kernel/qcursor_mac.mm @@ -114,27 +114,18 @@ void qt_mac_set_cursor(const QCursor *c, const QPoint &) } c->handle(); //force the cursor to get loaded, if it's not - if(1 || currentCursor != c->d) { - if(currentCursor && currentCursor->type == QCursorData::TYPE_ThemeCursor - && currentCursor->curs.tc.anim) - currentCursor->curs.tc.anim->stop(); - QMacCocoaAutoReleasePool pool; - if(c->d->type == QCursorData::TYPE_ImageCursor) { - [static_cast(c->d->curs.cp.nscursor) set]; - } else if(c->d->type == QCursorData::TYPE_ThemeCursor) { -#ifdef QT_MAC_USE_COCOA - if (c->d->curs.cp.nscursor == 0) - [[NSCursor arrowCursor] set]; - [static_cast(c->d->curs.cp.nscursor) set]; -#else - if(SetAnimatedThemeCursor(c->d->curs.tc.curs, 0) == themeBadCursorIndexErr) { - SetThemeCursor(c->d->curs.tc.curs); - } else { - if(!c->d->curs.tc.anim) - c->d->curs.tc.anim = new QMacAnimateCursor; - c->d->curs.tc.anim->start(c->d->curs.tc.curs); - } -#endif + if(currentCursor && currentCursor->type == QCursorData::TYPE_ThemeCursor + && currentCursor->curs.tc.anim) + currentCursor->curs.tc.anim->stop(); + if(c->d->type == QCursorData::TYPE_ImageCursor) { + [static_cast(c->d->curs.cp.nscursor) set]; + } else if(c->d->type == QCursorData::TYPE_ThemeCursor) { + if(SetAnimatedThemeCursor(c->d->curs.tc.curs, 0) == themeBadCursorIndexErr) { + SetThemeCursor(c->d->curs.tc.curs); + } else { + if(!c->d->curs.tc.anim) + c->d->curs.tc.anim = new QMacAnimateCursor; + c->d->curs.tc.anim->start(c->d->curs.tc.curs); } } currentCursor = c->d; -- cgit v0.12