From 003d09ab22f4d53995efc2d390c451e60afbe8c9 Mon Sep 17 00:00:00 2001 From: Yann Bodson Date: Fri, 10 Sep 2010 17:33:23 +1000 Subject: Autotests cleanup. --- .../tst_qdeclarativeanimatedimage.cpp | 17 ++---- .../tst_qdeclarativeborderimage.cpp | 23 +++----- .../tst_qdeclarativeecmascript.cpp | 16 ++---- .../tst_qdeclarativeimageprovider.cpp | 21 ++----- .../qdeclarativeloader/tst_qdeclarativeloader.cpp | 15 +---- .../tst_qdeclarativexmlhttprequest.cpp | 67 ++++++++++------------ 6 files changed, 52 insertions(+), 107 deletions(-) diff --git a/tests/auto/declarative/qdeclarativeanimatedimage/tst_qdeclarativeanimatedimage.cpp b/tests/auto/declarative/qdeclarativeanimatedimage/tst_qdeclarativeanimatedimage.cpp index 1001278..da15a85 100644 --- a/tests/auto/declarative/qdeclarativeanimatedimage/tst_qdeclarativeanimatedimage.cpp +++ b/tests/auto/declarative/qdeclarativeanimatedimage/tst_qdeclarativeanimatedimage.cpp @@ -47,22 +47,13 @@ #include #include "../shared/testhttpserver.h" +#include "../../../shared/util.h" #ifdef Q_OS_SYMBIAN // In Symbian OS test data is located in applications private dir #define SRCDIR "." #endif -#define TRY_WAIT(expr) \ - do { \ - for (int ii = 0; ii < 6; ++ii) { \ - if ((expr)) break; \ - QTest::qWait(50); \ - } \ - QVERIFY((expr)); \ - } while (false) - - class tst_qdeclarativeanimatedimage : public QObject { Q_OBJECT @@ -152,14 +143,14 @@ void tst_qdeclarativeanimatedimage::remote() QDeclarativeEngine engine; QDeclarativeComponent component(&engine, QUrl("http://127.0.0.1:14449/" + fileName)); - TRY_WAIT(component.isReady()); + QTRY_VERIFY(component.isReady()); QDeclarativeAnimatedImage *anim = qobject_cast(component.create()); QVERIFY(anim); - TRY_WAIT(anim->isPlaying()); + QTRY_VERIFY(anim->isPlaying()); if (paused) { - TRY_WAIT(anim->isPaused()); + QTRY_VERIFY(anim->isPaused()); QCOMPARE(anim->currentFrame(), 2); } QVERIFY(anim->status() != QDeclarativeAnimatedImage::Error); diff --git a/tests/auto/declarative/qdeclarativeborderimage/tst_qdeclarativeborderimage.cpp b/tests/auto/declarative/qdeclarativeborderimage/tst_qdeclarativeborderimage.cpp index 1b73cf7..c77d395 100644 --- a/tests/auto/declarative/qdeclarativeborderimage/tst_qdeclarativeborderimage.cpp +++ b/tests/auto/declarative/qdeclarativeborderimage/tst_qdeclarativeborderimage.cpp @@ -53,6 +53,7 @@ #include #include "../shared/testhttpserver.h" +#include "../../../shared/util.h" #ifdef Q_OS_SYMBIAN // In Symbian OS test data is located in applications private dir @@ -62,16 +63,6 @@ #define SERVER_PORT 14446 #define SERVER_ADDR "http://127.0.0.1:14446" -#define TRY_WAIT(expr) \ - do { \ - for (int ii = 0; ii < 60; ++ii) { \ - if ((expr)) break; \ - QTest::qWait(50); \ - } \ - QVERIFY((expr)); \ - } while (false) - - class tst_qdeclarativeborderimage : public QObject { @@ -154,18 +145,18 @@ void tst_qdeclarativeborderimage::imageSource() QVERIFY(obj != 0); if (remote) - TRY_WAIT(obj->status() == QDeclarativeBorderImage::Loading); + QTRY_VERIFY(obj->status() == QDeclarativeBorderImage::Loading); QCOMPARE(obj->source(), remote ? source : QUrl(source)); if (error.isEmpty()) { - TRY_WAIT(obj->status() == QDeclarativeBorderImage::Ready); + QTRY_VERIFY(obj->status() == QDeclarativeBorderImage::Ready); QCOMPARE(obj->width(), 120.); QCOMPARE(obj->height(), 120.); QCOMPARE(obj->horizontalTileMode(), QDeclarativeBorderImage::Stretch); QCOMPARE(obj->verticalTileMode(), QDeclarativeBorderImage::Stretch); } else { - TRY_WAIT(obj->status() == QDeclarativeBorderImage::Error); + QTRY_VERIFY(obj->status() == QDeclarativeBorderImage::Error); } delete obj; @@ -273,14 +264,14 @@ void tst_qdeclarativeborderimage::sciSource() QVERIFY(obj != 0); if (remote) - TRY_WAIT(obj->status() == QDeclarativeBorderImage::Loading); + QTRY_VERIFY(obj->status() == QDeclarativeBorderImage::Loading); QCOMPARE(obj->source(), remote ? source : QUrl(source)); QCOMPARE(obj->width(), 300.); QCOMPARE(obj->height(), 300.); if (valid) { - TRY_WAIT(obj->status() == QDeclarativeBorderImage::Ready); + QTRY_VERIFY(obj->status() == QDeclarativeBorderImage::Ready); QCOMPARE(obj->border()->left(), 10); QCOMPARE(obj->border()->top(), 20); QCOMPARE(obj->border()->right(), 30); @@ -288,7 +279,7 @@ void tst_qdeclarativeborderimage::sciSource() QCOMPARE(obj->horizontalTileMode(), QDeclarativeBorderImage::Round); QCOMPARE(obj->verticalTileMode(), QDeclarativeBorderImage::Repeat); } else { - TRY_WAIT(obj->status() == QDeclarativeBorderImage::Error); + QTRY_VERIFY(obj->status() == QDeclarativeBorderImage::Error); } delete obj; diff --git a/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp b/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp index 33bf7ea..c10a110 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp +++ b/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp @@ -52,6 +52,7 @@ #include #include "testtypes.h" #include "testhttpserver.h" +#include "../../../shared/util.h" #ifdef Q_OS_SYMBIAN // In Symbian OS test data is located in applications private dir @@ -2416,15 +2417,6 @@ void tst_qdeclarativeecmascript::function() delete o; } -#define TRY_WAIT(expr) \ - do { \ - for (int ii = 0; ii < 6; ++ii) { \ - if ((expr)) break; \ - QTest::qWait(50); \ - } \ - QVERIFY((expr)); \ - } while (false) - // Test the "Qt.include" method void tst_qdeclarativeecmascript::include() { @@ -2496,8 +2488,8 @@ void tst_qdeclarativeecmascript::include() QObject *o = component.create(); QVERIFY(o != 0); - TRY_WAIT(o->property("done").toBool() == true); - TRY_WAIT(o->property("done2").toBool() == true); + QTRY_VERIFY(o->property("done").toBool() == true); + QTRY_VERIFY(o->property("done2").toBool() == true); QCOMPARE(o->property("test1").toBool(), true); QCOMPARE(o->property("test2").toBool(), true); @@ -2524,7 +2516,7 @@ void tst_qdeclarativeecmascript::include() QObject *o = component.create(); QVERIFY(o != 0); - TRY_WAIT(o->property("done").toBool() == true); + QTRY_VERIFY(o->property("done").toBool() == true); QCOMPARE(o->property("test1").toBool(), true); QCOMPARE(o->property("test2").toBool(), true); diff --git a/tests/auto/declarative/qdeclarativeimageprovider/tst_qdeclarativeimageprovider.cpp b/tests/auto/declarative/qdeclarativeimageprovider/tst_qdeclarativeimageprovider.cpp index d0afc8a..d38160d 100644 --- a/tests/auto/declarative/qdeclarativeimageprovider/tst_qdeclarativeimageprovider.cpp +++ b/tests/auto/declarative/qdeclarativeimageprovider/tst_qdeclarativeimageprovider.cpp @@ -45,26 +45,15 @@ #include #include #include +#include "../../../shared/util.h" #ifdef Q_OS_SYMBIAN // In Symbian OS test data is located in applications private dir #define SRCDIR "." #endif -// QDeclarativeImageProvider::request() is run in an idle thread where possible -// Be generous in our timeout. -#define TRY_WAIT(expr) \ - do { \ - for (int ii = 0; ii < 10; ++ii) { \ - if ((expr)) break; \ - QTest::qWait(100); \ - } \ - QVERIFY((expr)); \ - } while (false) - Q_DECLARE_METATYPE(QDeclarativeImageProvider*); - class tst_qdeclarativeimageprovider : public QObject { Q_OBJECT @@ -212,13 +201,13 @@ void tst_qdeclarativeimageprovider::runTest(bool async, QDeclarativeImageProvide QVERIFY(obj != 0); if (async) - TRY_WAIT(obj->status() == QDeclarativeImage::Loading); + QTRY_VERIFY(obj->status() == QDeclarativeImage::Loading); QCOMPARE(obj->source(), QUrl(source)); if (error.isEmpty()) { if (async) - TRY_WAIT(obj->status() == QDeclarativeImage::Ready); + QTRY_VERIFY(obj->status() == QDeclarativeImage::Ready); else QVERIFY(obj->status() == QDeclarativeImage::Ready); QCOMPARE(obj->width(), qreal(size.width())); @@ -229,7 +218,7 @@ void tst_qdeclarativeimageprovider::runTest(bool async, QDeclarativeImageProvide QCOMPARE(obj->progress(), 1.0); } else { if (async) - TRY_WAIT(obj->status() == QDeclarativeImage::Error); + QTRY_VERIFY(obj->status() == QDeclarativeImage::Error); else QVERIFY(obj->status() == QDeclarativeImage::Error); } @@ -391,7 +380,7 @@ void tst_qdeclarativeimageprovider::threadTest() provider->cond.wakeAll(); QTest::qWait(250); foreach(QDeclarativeImage *img, images) { - TRY_WAIT(img->status() == QDeclarativeImage::Ready); + QTRY_VERIFY(img->status() == QDeclarativeImage::Ready); } } diff --git a/tests/auto/declarative/qdeclarativeloader/tst_qdeclarativeloader.cpp b/tests/auto/declarative/qdeclarativeloader/tst_qdeclarativeloader.cpp index 3baf848..b62392d 100644 --- a/tests/auto/declarative/qdeclarativeloader/tst_qdeclarativeloader.cpp +++ b/tests/auto/declarative/qdeclarativeloader/tst_qdeclarativeloader.cpp @@ -61,15 +61,6 @@ inline QUrl TEST_FILE(const QString &filename) return QUrl::fromLocalFile(QLatin1String(SRCDIR) + QLatin1String("/data/") + filename); } -#define TRY_WAIT(expr) \ - do { \ - for (int ii = 0; ii < 6; ++ii) { \ - if ((expr)) break; \ - QTest::qWait(50); \ - } \ - QVERIFY((expr)); \ - } while (false) - class tst_QDeclarativeLoader : public QObject { @@ -460,7 +451,7 @@ void tst_QDeclarativeLoader::networkRequestUrl() QDeclarativeLoader *loader = qobject_cast(component.create()); QVERIFY(loader != 0); - TRY_WAIT(loader->status() == QDeclarativeLoader::Ready); + QTRY_VERIFY(loader->status() == QDeclarativeLoader::Ready); QVERIFY(loader->item()); QCOMPARE(loader->progress(), 1.0); @@ -491,7 +482,7 @@ void tst_QDeclarativeLoader::networkComponent() QDeclarativeLoader *loader = qobject_cast(item->QGraphicsObject::children().at(1)); QVERIFY(loader); - TRY_WAIT(loader->status() == QDeclarativeLoader::Ready); + QTRY_VERIFY(loader->status() == QDeclarativeLoader::Ready); QVERIFY(loader->item()); QCOMPARE(loader->progress(), 1.0); @@ -515,7 +506,7 @@ void tst_QDeclarativeLoader::failNetworkRequest() QDeclarativeLoader *loader = qobject_cast(component.create()); QVERIFY(loader != 0); - TRY_WAIT(loader->status() == QDeclarativeLoader::Error); + QTRY_VERIFY(loader->status() == QDeclarativeLoader::Error); QVERIFY(loader->item() == 0); QCOMPARE(loader->progress(), 0.0); diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/tst_qdeclarativexmlhttprequest.cpp b/tests/auto/declarative/qdeclarativexmlhttprequest/tst_qdeclarativexmlhttprequest.cpp index ecce349..89252fb 100644 --- a/tests/auto/declarative/qdeclarativexmlhttprequest/tst_qdeclarativexmlhttprequest.cpp +++ b/tests/auto/declarative/qdeclarativexmlhttprequest/tst_qdeclarativexmlhttprequest.cpp @@ -45,6 +45,7 @@ #include #include #include "testhttpserver.h" +#include "../../../shared/util.h" #define SERVER_PORT 14445 @@ -156,16 +157,6 @@ void tst_qdeclarativexmlhttprequest::domExceptionCodes() delete object; } -#define TRY_WAIT(expr) \ - do { \ - for (int ii = 0; ii < 6; ++ii) { \ - if ((expr)) break; \ - QTest::qWait(50); \ - } \ - QVERIFY((expr)); \ - } while (false) - - void tst_qdeclarativexmlhttprequest::callbackException_data() { QTest::addColumn("which"); @@ -193,7 +184,7 @@ void tst_qdeclarativexmlhttprequest::callbackException() object->setProperty("which", which); component.completeCreate(); - TRY_WAIT(object->property("threw").toBool() == true); + QTRY_VERIFY(object->property("threw").toBool() == true); delete object; } @@ -289,7 +280,7 @@ void tst_qdeclarativexmlhttprequest::open() QCOMPARE(object->property("responseText").toBool(), true); QCOMPARE(object->property("responseXML").toBool(), true); - TRY_WAIT(object->property("dataOK").toBool() == true); + QTRY_VERIFY(object->property("dataOK").toBool() == true); delete server; delete object; @@ -372,7 +363,7 @@ void tst_qdeclarativexmlhttprequest::setRequestHeader() object->setProperty("url", "http://127.0.0.1:14445/testdocument.html"); component.completeCreate(); - TRY_WAIT(object->property("dataOK").toBool() == true); + QTRY_VERIFY(object->property("dataOK").toBool() == true); delete object; } @@ -442,7 +433,7 @@ void tst_qdeclarativexmlhttprequest::setRequestHeader_illegalName() QCOMPARE(object->property("responseText").toBool(), true); QCOMPARE(object->property("responseXML").toBool(), true); - TRY_WAIT(object->property("dataOK").toBool() == true); + QTRY_VERIFY(object->property("dataOK").toBool() == true); delete object; } @@ -464,7 +455,7 @@ void tst_qdeclarativexmlhttprequest::setRequestHeader_sent() QCOMPARE(object->property("test").toBool(), true); - TRY_WAIT(object->property("dataOK").toBool() == true); + QTRY_VERIFY(object->property("dataOK").toBool() == true); delete object; } @@ -501,7 +492,7 @@ void tst_qdeclarativexmlhttprequest::send_alreadySent() QVERIFY(object != 0); QCOMPARE(object->property("test").toBool(), true); - TRY_WAIT(object->property("dataOK").toBool() == true); + QTRY_VERIFY(object->property("dataOK").toBool() == true); delete object; } @@ -523,7 +514,7 @@ void tst_qdeclarativexmlhttprequest::send_ignoreData() object->setProperty("url", "http://127.0.0.1:14445/testdocument.html"); component.completeCreate(); - TRY_WAIT(object->property("dataOK").toBool() == true); + QTRY_VERIFY(object->property("dataOK").toBool() == true); delete object; } @@ -542,7 +533,7 @@ void tst_qdeclarativexmlhttprequest::send_ignoreData() object->setProperty("url", "http://127.0.0.1:14445/testdocument.html"); component.completeCreate(); - TRY_WAIT(object->property("dataOK").toBool() == true); + QTRY_VERIFY(object->property("dataOK").toBool() == true); delete object; } @@ -566,7 +557,7 @@ void tst_qdeclarativexmlhttprequest::send_withdata() object->setProperty("url", "http://127.0.0.1:14445/testdocument.html"); component.completeCreate(); - TRY_WAIT(object->property("dataOK").toBool() == true); + QTRY_VERIFY(object->property("dataOK").toBool() == true); delete object; } @@ -601,7 +592,7 @@ void tst_qdeclarativexmlhttprequest::abort_unsent() QCOMPARE(object->property("responseText").toBool(), true); QCOMPARE(object->property("responseXML").toBool(), true); - TRY_WAIT(object->property("dataOK").toBool() == true); + QTRY_VERIFY(object->property("dataOK").toBool() == true); delete object; } @@ -622,7 +613,7 @@ void tst_qdeclarativexmlhttprequest::abort_opened() QCOMPARE(object->property("responseText").toBool(), true); QCOMPARE(object->property("responseXML").toBool(), true); - TRY_WAIT(object->property("dataOK").toBool() == true); + QTRY_VERIFY(object->property("dataOK").toBool() == true); delete object; } @@ -647,7 +638,7 @@ void tst_qdeclarativexmlhttprequest::abort() QCOMPARE(object->property("didNotSeeUnsent").toBool(), true); QCOMPARE(object->property("endStateUnsent").toBool(), true); - TRY_WAIT(object->property("dataOK").toBool() == true); + QTRY_VERIFY(object->property("dataOK").toBool() == true); delete object; } @@ -674,7 +665,7 @@ void tst_qdeclarativexmlhttprequest::getResponseHeader() QCOMPARE(object->property("readyState").toBool(), true); QCOMPARE(object->property("openedState").toBool(), true); - TRY_WAIT(object->property("dataOK").toBool() == true); + QTRY_VERIFY(object->property("dataOK").toBool() == true); QCOMPARE(object->property("headersReceivedState").toBool(), true); QCOMPARE(object->property("headersReceivedNullHeader").toBool(), true); @@ -722,7 +713,7 @@ void tst_qdeclarativexmlhttprequest::getResponseHeader_args() QObject *object = component.create(); QVERIFY(object != 0); - TRY_WAIT(object->property("exceptionThrown").toBool() == true); + QTRY_VERIFY(object->property("exceptionThrown").toBool() == true); delete object; } @@ -748,7 +739,7 @@ void tst_qdeclarativexmlhttprequest::getAllResponseHeaders() QCOMPARE(object->property("readyState").toBool(), true); QCOMPARE(object->property("openedState").toBool(), true); - TRY_WAIT(object->property("dataOK").toBool() == true); + QTRY_VERIFY(object->property("dataOK").toBool() == true); QCOMPARE(object->property("headersReceivedState").toBool(), true); QCOMPARE(object->property("headersReceivedHeader").toBool(), true); @@ -790,7 +781,7 @@ void tst_qdeclarativexmlhttprequest::getAllResponseHeaders_args() QObject *object = component.create(); QVERIFY(object != 0); - TRY_WAIT(object->property("exceptionThrown").toBool() == true); + QTRY_VERIFY(object->property("exceptionThrown").toBool() == true); delete object; } @@ -813,7 +804,7 @@ void tst_qdeclarativexmlhttprequest::status() object->setProperty("expectedStatus", status); component.completeCreate(); - TRY_WAIT(object->property("dataOK").toBool() == true); + QTRY_VERIFY(object->property("dataOK").toBool() == true); QCOMPARE(object->property("unsentException").toBool(), true); QCOMPARE(object->property("openedException").toBool(), true); @@ -853,7 +844,7 @@ void tst_qdeclarativexmlhttprequest::statusText() object->setProperty("expectedStatus", statusText); component.completeCreate(); - TRY_WAIT(object->property("dataOK").toBool() == true); + QTRY_VERIFY(object->property("dataOK").toBool() == true); QCOMPARE(object->property("unsentException").toBool(), true); QCOMPARE(object->property("openedException").toBool(), true); @@ -894,7 +885,7 @@ void tst_qdeclarativexmlhttprequest::responseText() object->setProperty("expectedText", responseText); component.completeCreate(); - TRY_WAIT(object->property("dataOK").toBool() == true); + QTRY_VERIFY(object->property("dataOK").toBool() == true); QCOMPARE(object->property("unsent").toBool(), true); QCOMPARE(object->property("opened").toBool(), true); @@ -931,7 +922,7 @@ void tst_qdeclarativexmlhttprequest::nonUtf8() object->setProperty("fileName", fileName); QMetaObject::invokeMethod(object, "startRequest"); - TRY_WAIT(object->property("dataOK").toBool() == true); + QTRY_VERIFY(object->property("dataOK").toBool() == true); QCOMPARE(object->property("responseText").toString(), responseText); @@ -1000,7 +991,7 @@ void tst_qdeclarativexmlhttprequest::redirects() object->setProperty("expectedText", ""); component.completeCreate(); - TRY_WAIT(object->property("done").toBool() == true); + QTRY_VERIFY(object->property("done").toBool() == true); QCOMPARE(object->property("dataOK").toBool(), true); delete object; @@ -1019,7 +1010,7 @@ void tst_qdeclarativexmlhttprequest::redirects() object->setProperty("expectedText", ""); component.completeCreate(); - TRY_WAIT(object->property("done").toBool() == true); + QTRY_VERIFY(object->property("done").toBool() == true); QCOMPARE(object->property("dataOK").toBool(), true); delete object; @@ -1056,7 +1047,7 @@ void tst_qdeclarativexmlhttprequest::responseXML_invalid() QObject *object = component.create(); QVERIFY(object != 0); - TRY_WAIT(object->property("dataOK").toBool() == true); + QTRY_VERIFY(object->property("dataOK").toBool() == true); QCOMPARE(object->property("xmlNull").toBool(), true); @@ -1070,7 +1061,7 @@ void tst_qdeclarativexmlhttprequest::document() QObject *object = component.create(); QVERIFY(object != 0); - TRY_WAIT(object->property("dataOK").toBool() == true); + QTRY_VERIFY(object->property("dataOK").toBool() == true); QCOMPARE(object->property("xmlTest").toBool(), true); @@ -1084,7 +1075,7 @@ void tst_qdeclarativexmlhttprequest::element() QObject *object = component.create(); QVERIFY(object != 0); - TRY_WAIT(object->property("dataOK").toBool() == true); + QTRY_VERIFY(object->property("dataOK").toBool() == true); QCOMPARE(object->property("xmlTest").toBool(), true); @@ -1098,7 +1089,7 @@ void tst_qdeclarativexmlhttprequest::attr() QObject *object = component.create(); QVERIFY(object != 0); - TRY_WAIT(object->property("dataOK").toBool() == true); + QTRY_VERIFY(object->property("dataOK").toBool() == true); QCOMPARE(object->property("xmlTest").toBool(), true); @@ -1112,7 +1103,7 @@ void tst_qdeclarativexmlhttprequest::text() QObject *object = component.create(); QVERIFY(object != 0); - TRY_WAIT(object->property("dataOK").toBool() == true); + QTRY_VERIFY(object->property("dataOK").toBool() == true); QCOMPARE(object->property("xmlTest").toBool(), true); @@ -1126,7 +1117,7 @@ void tst_qdeclarativexmlhttprequest::cdata() QObject *object = component.create(); QVERIFY(object != 0); - TRY_WAIT(object->property("dataOK").toBool() == true); + QTRY_VERIFY(object->property("dataOK").toBool() == true); QCOMPARE(object->property("xmlTest").toBool(), true); -- cgit v0.12 From 8b1c78c80181e6125d39b64f7ffa698f50ed8042 Mon Sep 17 00:00:00 2001 From: mread Date: Fri, 10 Sep 2010 14:57:13 +0100 Subject: Updated 4.7.0 changelog Updated 4.7.0 changelog with Avkon removal compatibility information Reviewed-by: Harald Fernengel --- dist/changes-4.7.0 | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/dist/changes-4.7.0 b/dist/changes-4.7.0 index a5939e3..53e51f8 100644 --- a/dist/changes-4.7.0 +++ b/dist/changes-4.7.0 @@ -371,6 +371,10 @@ Qt for Symbian - QSplashScreen * [QTBUG-11129] Fixed a hanging bug in QSplashScreen on 3.1 devices. + - QS60Main... classes + * The future compatibility of QS60MainAppUi, QS60MainDocument and + QS60MainApplication are improved by removing the need for any + sub-class to link to Avkon functions that may not exist in future. **************************************************************************** -- cgit v0.12 From 771cfe6f172820a1a370255cb74e066913408a6f Mon Sep 17 00:00:00 2001 From: Jason Barron Date: Tue, 24 Aug 2010 17:00:59 +0200 Subject: Fix crash in OpenVG when failing to allocate large VGImages. The reclaimSpace() function of the VG image pool was crashing when attempting to free up space for a large image. It was calling moveToHeadOfLRU() which adds the image to the pool. If the pixmap is large enough so that it pushes all the others out, then it will be the only pixmap left in the pool when this function returns. This is problematic because this pixmap is not permanent so it could be deleted. If that happens, then subsequent calls to this function will crash because the LRU pixmap has been deleted. The fix is to check if the pixmap was in the pool to begin with and if not, then be sure to remove it before returning from this function. Task-number: QT-3652 Reviewed-by: Jani Hautakangas --- src/openvg/qvgimagepool.cpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/openvg/qvgimagepool.cpp b/src/openvg/qvgimagepool.cpp index 78277aa..0c236ea 100644 --- a/src/openvg/qvgimagepool.cpp +++ b/src/openvg/qvgimagepool.cpp @@ -154,16 +154,23 @@ bool QVGImagePool::reclaimSpace(VGImageFormat format, Q_UNUSED(width); Q_UNUSED(height); - if (data) + bool succeeded = false; + bool wasInLRU = false; + if (data) { + wasInLRU = data->inLRU; moveToHeadOfLRU(data); + } QVGPixmapData *lrudata = pixmapLRU(); if (lrudata && lrudata != data) { lrudata->reclaimImages(); - return true; + succeeded = true; } - return false; + if (data && !wasInLRU) + removeFromLRU(data); + + return succeeded; } void QVGImagePool::hibernate() -- cgit v0.12 From ff98c93a33170b8fdc28b553490819b51cb80d86 Mon Sep 17 00:00:00 2001 From: Jason Barron Date: Wed, 25 Aug 2010 13:51:42 +0200 Subject: Fix crash in QRuntimeGraphicsSystem due to destruction order. Firstly, fix a "leak" by deleting the graphics system when QApplication is destroyed. Secondly, fix a crash when the following scenario occurs: - ~QApplication() deletes the current graphics system (see above) - ~QApplication() calls qt_cleanup() - qt_cleanup() calls QPixmapCache::clear() to delete pixmaps - ~QRuntimePixmapData() tries to remove the pixmap from the runtime graphics system, but it has already been deleted. - *Crash* Reviewed-by: Gunnar Sletta Reviewed-by: Jani Hautakangas --- src/gui/kernel/qapplication.cpp | 2 ++ src/gui/painting/qgraphicssystem_runtime.cpp | 6 ++++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/gui/kernel/qapplication.cpp b/src/gui/kernel/qapplication.cpp index 82dd83a..ebad56e 100644 --- a/src/gui/kernel/qapplication.cpp +++ b/src/gui/kernel/qapplication.cpp @@ -1116,6 +1116,8 @@ QApplication::~QApplication() QApplicationPrivate::app_style = 0; delete QApplicationPrivate::app_icon; QApplicationPrivate::app_icon = 0; + delete QApplicationPrivate::graphics_system; + QApplicationPrivate::graphics_system = 0; #ifndef QT_NO_CURSOR d->cursor_list.clear(); #endif diff --git a/src/gui/painting/qgraphicssystem_runtime.cpp b/src/gui/painting/qgraphicssystem_runtime.cpp index 2828e9d..a9fbbee 100644 --- a/src/gui/painting/qgraphicssystem_runtime.cpp +++ b/src/gui/painting/qgraphicssystem_runtime.cpp @@ -94,7 +94,8 @@ QRuntimePixmapData::QRuntimePixmapData(const QRuntimeGraphicsSystem *gs, PixelTy QRuntimePixmapData::~QRuntimePixmapData() { - m_graphicsSystem->removePixmapData(this); + if (QApplicationPrivate::graphics_system) + m_graphicsSystem->removePixmapData(this); delete m_data; } @@ -258,7 +259,8 @@ QRuntimeWindowSurface::QRuntimeWindowSurface(const QRuntimeGraphicsSystem *gs, Q QRuntimeWindowSurface::~QRuntimeWindowSurface() { - m_graphicsSystem->removeWindowSurface(this); + if (QApplicationPrivate::graphics_system) + m_graphicsSystem->removeWindowSurface(this); } QPaintDevice *QRuntimeWindowSurface::paintDevice() -- cgit v0.12