From dd478a4b829921c9dfeb23110177a30f32eca5af Mon Sep 17 00:00:00 2001 From: Bill King Date: Tue, 20 Apr 2010 12:07:22 +1000 Subject: Fix sqlite driver doesn't return error message RAISE by a trigger. Task-number: QTBUG-7988 Reviewed-by: Justin McPherson --- src/sql/drivers/sqlite/qsql_sqlite.cpp | 1 + tests/auto/qsqlquery/tst_qsqlquery.cpp | 27 +++++++++++++++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/src/sql/drivers/sqlite/qsql_sqlite.cpp b/src/sql/drivers/sqlite/qsql_sqlite.cpp index d3be304..9b9d30b 100644 --- a/src/sql/drivers/sqlite/qsql_sqlite.cpp +++ b/src/sql/drivers/sqlite/qsql_sqlite.cpp @@ -259,6 +259,7 @@ bool QSQLiteResultPrivate::fetchNext(QSqlCachedResult::ValueCache &values, int i q->setAt(QSql::AfterLastRow); sqlite3_reset(stmt); return false; + case SQLITE_CONSTRAINT: case SQLITE_ERROR: // SQLITE_ERROR is a generic error code and we must call sqlite3_reset() // to get the specific error message. diff --git a/tests/auto/qsqlquery/tst_qsqlquery.cpp b/tests/auto/qsqlquery/tst_qsqlquery.cpp index db3a929..c7a61a5 100644 --- a/tests/auto/qsqlquery/tst_qsqlquery.cpp +++ b/tests/auto/qsqlquery/tst_qsqlquery.cpp @@ -209,6 +209,8 @@ private slots: void QTBUG_6852(); void QTBUG_5765_data() { generic_data("QMYSQL"); } void QTBUG_5765(); + void sqlite_constraint_data() { generic_data("QSQLITE"); } + void sqlite_constraint(); #if 0 void benchmark_data() { generic_data(); } @@ -3078,6 +3080,31 @@ void tst_QSqlQuery::QTBUG_5765() QCOMPARE(q.value(0).toInt(), 123); } +void tst_QSqlQuery::sqlite_constraint() +{ + QFETCH( QString, dbName ); + QSqlDatabase db = QSqlDatabase::database( dbName ); + CHECK_DATABASE( db ); + + if (db.driverName() != QLatin1String("QSQLITE")) { + QSKIP("Sqlite3 specific test", SkipSingle); + return; + } + + QSqlQuery q(db); + const QString trigger(qTableName("test_constraint", __FILE__)); + + QVERIFY_SQL(q, exec("CREATE TEMP TRIGGER "+trigger+" BEFORE DELETE ON "+qtest+ + "\nFOR EACH ROW " + "\nBEGIN" + "\n SELECT RAISE(ABORT, 'Raised Abort successfully');" + "\nEND;" + )); + + QVERIFY(!q.exec("DELETE FROM "+qtest)); + QCOMPARE(q.lastError().databaseText(), QLatin1String("Raised Abort successfully")); +} + #if 0 void tst_QSqlQuery::benchmark() { -- cgit v0.12 From f6d816ffe37ac74d29a7423683d4e046a3906b74 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Nilsen?= Date: Tue, 20 Apr 2010 11:03:24 +0200 Subject: No repaint when resizing graphics item with an effect. Problem was that the item's cache was not invalidated from prepareGeometryChange(). We did invalidate the cache for all the ancestors, but not for the item itself. To avoid looping through the whole parent chain twice, we invalidate the item's cache before walking the parent chain. It would be nice to centralize the cache invalidating mechanism, but for now it's OK to solve it like this. Auto test included. Task-number: QTBUG-9551 Reviewed-by: samuel --- src/gui/graphicsview/qgraphicsitem_p.h | 7 ++++++ tests/auto/qgraphicseffect/tst_qgraphicseffect.cpp | 28 ++++++++++++++++++++++ 2 files changed, 35 insertions(+) diff --git a/src/gui/graphicsview/qgraphicsitem_p.h b/src/gui/graphicsview/qgraphicsitem_p.h index ea04e0b..e737773 100644 --- a/src/gui/graphicsview/qgraphicsitem_p.h +++ b/src/gui/graphicsview/qgraphicsitem_p.h @@ -769,6 +769,13 @@ inline bool QGraphicsItemPrivate::insertionOrder(QGraphicsItem *a, QGraphicsItem inline void QGraphicsItemPrivate::markParentDirty(bool updateBoundingRect) { QGraphicsItemPrivate *parentp = this; +#ifndef QT_NO_GRAPHICSEFFECT + if (updateBoundingRect && parentp->graphicsEffect && !parentp->inSetPosHelper) { + parentp->notifyInvalidated = 1; + static_cast(parentp->graphicsEffect->d_func() + ->source->d_func())->invalidateCache(); + } +#endif while (parentp->parent) { parentp = parentp->parent->d_ptr.data(); parentp->dirtyChildren = 1; diff --git a/tests/auto/qgraphicseffect/tst_qgraphicseffect.cpp b/tests/auto/qgraphicseffect/tst_qgraphicseffect.cpp index dbd4a23..5dc0c9d 100644 --- a/tests/auto/qgraphicseffect/tst_qgraphicseffect.cpp +++ b/tests/auto/qgraphicseffect/tst_qgraphicseffect.cpp @@ -75,6 +75,7 @@ private slots: void inheritOpacity(); void dropShadowClipping(); void childrenVisibilityShouldInvalidateCache(); + void prepareGeometryChangeInvalidateCache(); }; void tst_QGraphicsEffect::initTestCase() @@ -647,6 +648,33 @@ void tst_QGraphicsEffect::childrenVisibilityShouldInvalidateCache() QCOMPARE(parent.nbPaint, 3); } +void tst_QGraphicsEffect::prepareGeometryChangeInvalidateCache() +{ + MyGraphicsItem *item = new MyGraphicsItem; + item->resize(200, 200); + + QGraphicsScene scene; + scene.addItem(item); + + QGraphicsView view(&scene); + view.show(); + QTest::qWaitForWindowShown(&view); + QTRY_COMPARE(item->nbPaint, 1); + + item->nbPaint = 0; + item->setGraphicsEffect(new QGraphicsDropShadowEffect); + QTRY_COMPARE(item->nbPaint, 1); + + item->nbPaint = 0; + item->resize(300, 300); + QTRY_COMPARE(item->nbPaint, 1); + + item->nbPaint = 0; + item->setPos(item->pos() + QPointF(10, 10)); + QTest::qWait(50); + QCOMPARE(item->nbPaint, 0); +} + QTEST_MAIN(tst_QGraphicsEffect) #include "tst_qgraphicseffect.moc" -- cgit v0.12