From 4204fdcc04e20eabd19704f2235ba06afa84605e Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Thu, 29 Oct 2009 17:32:57 +0100 Subject: Avoid infinite loop when laying out text with unconvertible chars When the stringToCMap() fails, it can be because it did not have enough space in the layout, or it can because of other errors. In order to implement "try-again" processing in a simple way, we had an infinite loop which assumed that stringToCMap() would always succeed in the second run (which would be the case if the only possible error was "not enough space".) Since there are other possible failures not related to the number of glyphs, you could easily get into an infinite loop here, e.g. when laying out text that contains the Byte Order Mark. The fix changes the implementation to explictly try stringToCMap() twice at max, and is also how it's implemented in the default qtextengine.cpp. Task-number: QTBUG-4680 Reviewed-by: Trond Conflicts: src/gui/text/qtextengine_mac.cpp tests/auto/qtextlayout/tst_qtextlayout.cpp --- tests/auto/qtextlayout/tst_qtextlayout.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'tests') diff --git a/tests/auto/qtextlayout/tst_qtextlayout.cpp b/tests/auto/qtextlayout/tst_qtextlayout.cpp index a5fed4e27f..b02a70455c 100644 --- a/tests/auto/qtextlayout/tst_qtextlayout.cpp +++ b/tests/auto/qtextlayout/tst_qtextlayout.cpp @@ -119,6 +119,7 @@ private slots: void smallTextLengthWordWrap(); void smallTextLengthWrapAtWordBoundaryOrAnywhere(); void testLineBreakingAllSpaces(); + void lineWidthFromBOM(); private: @@ -1277,5 +1278,18 @@ void tst_QTextLayout::widthOfTabs() QCOMPARE(qRound(engine.width(0, 5)), qRound(engine.boundingBox(0, 5).width)); } +void tst_QTextLayout::lineWidthFromBOM() +{ + const QString string(QChar(0xfeff)); // BYTE ORDER MARK + QTextLayout layout(string); + layout.beginLayout(); + QTextLine line = layout.createLine(); + line.setLineWidth(INT_MAX / 256); + layout.endLayout(); + + // Don't spin into an infinite loop + } + + QTEST_MAIN(tst_QTextLayout) #include "tst_qtextlayout.moc" -- cgit v1.2.3 From 91c09562ed9c6eb1bd3a4dbd84a8cc64647751ee Mon Sep 17 00:00:00 2001 From: Derick Hawcroft Date: Thu, 5 Nov 2009 10:35:48 +1000 Subject: Fix retrieval of SQL type "TIME" information for PostgreSQL PostgreSQL can store/retieve the millisecond part of type "TIME" , so allow it in the API level. Task-number: QTBUG-5251 Reviewed-by: Bill King --- tests/auto/qsqlquery/tst_qsqlquery.cpp | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'tests') diff --git a/tests/auto/qsqlquery/tst_qsqlquery.cpp b/tests/auto/qsqlquery/tst_qsqlquery.cpp index 3463153214..87774a3250 100644 --- a/tests/auto/qsqlquery/tst_qsqlquery.cpp +++ b/tests/auto/qsqlquery/tst_qsqlquery.cpp @@ -194,6 +194,8 @@ private slots: void sqlServerReturn0_data() { generic_data(); } void sqlServerReturn0(); + void QTBUG_5251_data() { generic_data("QPSQL"); } + void QTBUG_5251(); private: // returns all database connections @@ -2880,5 +2882,35 @@ void tst_QSqlQuery::sqlServerReturn0() QVERIFY_SQL(q, next()); } +void tst_QSqlQuery::QTBUG_5251() +{ + QFETCH( QString, dbName ); + QSqlDatabase db = QSqlDatabase::database( dbName ); + CHECK_DATABASE( db ); + + if (!db.driverName().startsWith( "QPSQL" )) return; + + QSqlQuery q(db); + q.exec("DROP TABLE " + qTableName("timetest")); + QVERIFY_SQL(q, exec("CREATE TABLE " + qTableName("timetest") + " (t TIME)")); + QVERIFY_SQL(q, exec("INSERT INTO " + qTableName("timetest") + " VALUES ('1:2:3.666')")); + + QSqlTableModel timetestModel(0,db); + timetestModel.setEditStrategy(QSqlTableModel::OnManualSubmit); + timetestModel.setTable(qTableName("timetest")); + QVERIFY_SQL(timetestModel, select()); + + QCOMPARE(timetestModel.record(0).field(0).value().toTime().toString("HH:mm:ss.zzz"), QString("01:02:03.666")); + QVERIFY_SQL(timetestModel,setData(timetestModel.index(0, 0), QTime(0,12,34,500))); + QCOMPARE(timetestModel.record(0).field(0).value().toTime().toString("HH:mm:ss.zzz"), QString("00:12:34.500")); + QVERIFY_SQL(timetestModel, submitAll()); + QCOMPARE(timetestModel.record(0).field(0).value().toTime().toString("HH:mm:ss.zzz"), QString("00:12:34.500")); + + QVERIFY_SQL(q, exec("UPDATE " + qTableName("timetest") + " SET t = '0:11:22.33'")); + QVERIFY_SQL(timetestModel, select()); + QCOMPARE(timetestModel.record(0).field(0).value().toTime().toString("HH:mm:ss.zzz"), QString("00:11:22.330")); + +} + QTEST_MAIN( tst_QSqlQuery ) #include "tst_qsqlquery.moc" -- cgit v1.2.3