From 91732818e559c1174283282c17c856e9fc9f78ac Mon Sep 17 00:00:00 2001 From: Joerg Bornemann Date: Wed, 24 Jan 2018 08:02:55 +0100 Subject: Remove dead code from tst_qwineventnotifier.cpp The idx member of EventWithNotifier is unused. Change-Id: I0f5aacaaad4b4e82c57ff7bb020586944014f139 Reviewed-by: Friedemann Kleint --- tests/auto/corelib/kernel/qwineventnotifier/tst_qwineventnotifier.cpp | 4 ---- 1 file changed, 4 deletions(-) (limited to 'tests/auto/corelib/kernel') diff --git a/tests/auto/corelib/kernel/qwineventnotifier/tst_qwineventnotifier.cpp b/tests/auto/corelib/kernel/qwineventnotifier/tst_qwineventnotifier.cpp index 15a39b62c0..64e78ec3c3 100644 --- a/tests/auto/corelib/kernel/qwineventnotifier/tst_qwineventnotifier.cpp +++ b/tests/auto/corelib/kernel/qwineventnotifier/tst_qwineventnotifier.cpp @@ -109,9 +109,6 @@ public: this, &EventWithNotifier::onNotifierActivated); notifier.setHandle(CreateEvent(0, TRUE, FALSE, 0)); notifier.setEnabled(true); - - static int nextIndex = 0; - idx = nextIndex++; } ~EventWithNotifier() @@ -137,7 +134,6 @@ public slots: private: QWinEventNotifier notifier; int activatedCount = 0; - int idx = 0; }; void tst_QWinEventNotifier::manyNotifiers() -- cgit v1.2.3 From ab1e50757454b5afda2f6dec52d2eb16a32d4798 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Fri, 19 Jan 2018 23:32:58 -0800 Subject: QVariant: convert QDateTime and QTime to string with milliseconds This way, it's lossless. Change-Id: I5e421e32396d44e4b39efffd150b744e40fff3a1 Reviewed-by: Allan Sandfeld Jensen Reviewed-by: Lars Knoll --- tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'tests/auto/corelib/kernel') diff --git a/tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp b/tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp index 0d45159d09..6ec90a66c8 100644 --- a/tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp +++ b/tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp @@ -1099,8 +1099,9 @@ void tst_QVariant::toString_data() QTest::newRow( "bool" ) << QVariant( true ) << QString( "true" ); QTest::newRow( "qdate" ) << QVariant( QDate( 2002, 1, 1 ) ) << QString( "2002-01-01" ); - QTest::newRow( "qtime" ) << QVariant( QTime( 12, 34, 56 ) ) << QString( "12:34:56" ); - QTest::newRow( "qdatetime" ) << QVariant( QDateTime( QDate( 2002, 1, 1 ), QTime( 12, 34, 56 ) ) ) << QString( "2002-01-01T12:34:56" ); + QTest::newRow( "qtime" ) << QVariant( QTime( 12, 34, 56 ) ) << QString( "12:34:56.000" ); + QTest::newRow( "qtime-with-ms" ) << QVariant( QTime( 12, 34, 56, 789 ) ) << QString( "12:34:56.789" ); + QTest::newRow( "qdatetime" ) << QVariant( QDateTime( QDate( 2002, 1, 1 ), QTime( 12, 34, 56, 789 ) ) ) << QString( "2002-01-01T12:34:56.789" ); QTest::newRow( "llong" ) << QVariant( (qlonglong)Q_INT64_C(123456789012) ) << QString( "123456789012" ); QTest::newRow("QJsonValue") << QVariant(QJsonValue(QString("hello"))) << QString("hello"); @@ -1151,6 +1152,7 @@ void tst_QVariant::toTime_data() QTest::newRow( "qtime" ) << QVariant( QTime( 12, 34, 56 ) ) << QTime( 12, 34, 56 ); QTest::newRow( "qdatetime" ) << QVariant( QDateTime( QDate( 2002, 10, 10 ), QTime( 12, 34, 56 ) ) ) << QTime( 12, 34, 56 ); QTest::newRow( "qstring" ) << QVariant( QString( "12:34:56" ) ) << QTime( 12, 34, 56 ); + QTest::newRow( "qstring-with-ms" ) << QVariant( QString( "12:34:56.789" ) ) << QTime( 12, 34, 56, 789 ); } void tst_QVariant::toTime() @@ -1171,6 +1173,10 @@ void tst_QVariant::toDateTime_data() << QDateTime( QDate( 2002, 10, 10 ), QTime( 12, 34, 56 ) ); QTest::newRow( "qdate" ) << QVariant( QDate( 2002, 10, 10 ) ) << QDateTime( QDate( 2002, 10, 10 ), QTime( 0, 0, 0 ) ); QTest::newRow( "qstring" ) << QVariant( QString( "2002-10-10T12:34:56" ) ) << QDateTime( QDate( 2002, 10, 10 ), QTime( 12, 34, 56 ) ); + QTest::newRow( "qstring-utc" ) << QVariant( QString( "2002-10-10T12:34:56Z" ) ) + << QDateTime( QDate( 2002, 10, 10 ), QTime( 12, 34, 56 ), Qt::UTC ); + QTest::newRow( "qstring-with-ms" ) << QVariant( QString( "2002-10-10T12:34:56.789" ) ) + << QDateTime( QDate( 2002, 10, 10 ), QTime( 12, 34, 56, 789 ) ); } void tst_QVariant::toDateTime() -- cgit v1.2.3 From 6dbf3576093858d981d8321b00f0b19faa7cf217 Mon Sep 17 00:00:00 2001 From: Joerg Bornemann Date: Fri, 13 Oct 2017 16:27:13 +0200 Subject: Fix asserts and crashes in QWinEventNotifier activation loop The backwards iteration was done under the assumption that the only valid modification of the winEventNotifierList in a slot connected to activated() would be the removal of the notifier itself. This is wrong. Instead, iterate forwards, like before 85403d0a, and check the index against the current list size in every iteration. This ensures that we do not run out of bounds while the list is modified. Also, retry the activation loop if the list was modified by a slot connected to activated(). This ensures that all notifiers with signaled handles are activated. Task-number: QTBUG-65940 Change-Id: I25f305463b9234f391abc51fe0628d02f49b6931 Reviewed-by: Friedemann Kleint Reviewed-by: Oswald Buddenhagen --- .../qwineventnotifier/tst_qwineventnotifier.cpp | 60 ++++++++++++++++++++++ 1 file changed, 60 insertions(+) (limited to 'tests/auto/corelib/kernel') diff --git a/tests/auto/corelib/kernel/qwineventnotifier/tst_qwineventnotifier.cpp b/tests/auto/corelib/kernel/qwineventnotifier/tst_qwineventnotifier.cpp index 64e78ec3c3..76efa008f7 100644 --- a/tests/auto/corelib/kernel/qwineventnotifier/tst_qwineventnotifier.cpp +++ b/tests/auto/corelib/kernel/qwineventnotifier/tst_qwineventnotifier.cpp @@ -29,8 +29,11 @@ #include #include #include +#include +#include #include +#include #include class tst_QWinEventNotifier : public QObject @@ -44,6 +47,8 @@ private slots: void simple_data(); void simple(); void manyNotifiers(); + void disableNotifiersInActivatedSlot_data(); + void disableNotifiersInActivatedSlot(); private: HANDLE simpleHEvent; @@ -119,6 +124,7 @@ public: HANDLE eventHandle() const { return notifier.handle(); } int numberOfTimesActivated() const { return activatedCount; } + void setEnabled(bool b) { notifier.setEnabled(b); } signals: void activated(); @@ -180,6 +186,60 @@ void tst_QWinEventNotifier::manyNotifiers() })); } +using Indices = QVector; + +void tst_QWinEventNotifier::disableNotifiersInActivatedSlot_data() +{ + QTest::addColumn("count"); + QTest::addColumn("notifiersToSignal"); + QTest::addColumn("notifiersToDisable"); + QTest::addColumn("deleteNotifiers"); + QTest::newRow("disable_signaled") << 3 << Indices{1} << Indices{1} << false; + QTest::newRow("disable_signaled2") << 3 << Indices{1, 2} << Indices{1} << false; + QTest::newRow("disable_before_signaled") << 3 << Indices{1} << Indices{0, 1} << false; + QTest::newRow("disable_after_signaled") << 3 << Indices{1} << Indices{1, 2} << false; + QTest::newRow("delete_signaled") << 3 << Indices{1} << Indices{1} << true; + QTest::newRow("delete_before_signaled1") << 3 << Indices{1} << Indices{0} << true; + QTest::newRow("delete_before_signaled2") << 3 << Indices{1} << Indices{0, 1} << true; + QTest::newRow("delete_before_signaled3") << 4 << Indices{3, 1} << Indices{0, 1} << true; + QTest::newRow("delete_after_signaled1") << 3 << Indices{1} << Indices{1, 2} << true; + QTest::newRow("delete_after_signaled2") << 4 << Indices{1, 3} << Indices{1, 2} << true; + QTest::newRow("delete_after_signaled3") << 5 << Indices{1} << Indices{1, 4} << true; +} + +void tst_QWinEventNotifier::disableNotifiersInActivatedSlot() +{ + QFETCH(int, count); + QFETCH(Indices, notifiersToSignal); + QFETCH(Indices, notifiersToDisable); + QFETCH(bool, deleteNotifiers); + + QVarLengthArray, 10> events(count); + for (int i = 0; i < count; ++i) + events[i].reset(new EventWithNotifier); + + auto isActivatedOrNull = [&events](int i) { + return !events.at(i) || events.at(i)->numberOfTimesActivated() > 0; + }; + + for (auto &e : events) { + connect(e.get(), &EventWithNotifier::activated, [&]() { + for (int i : notifiersToDisable) { + if (deleteNotifiers) + events[i].reset(); + else + events.at(i)->setEnabled(false); + } + if (std::all_of(notifiersToSignal.begin(), notifiersToSignal.end(), isActivatedOrNull)) + QTimer::singleShot(0, &QTestEventLoop::instance(), SLOT(exitLoop())); + }); + } + for (int i : notifiersToSignal) + SetEvent(events.at(i)->eventHandle()); + QTestEventLoop::instance().enterLoop(30); + QVERIFY(!QTestEventLoop::instance().timeout()); +} + QTEST_MAIN(tst_QWinEventNotifier) #include "tst_qwineventnotifier.moc" -- cgit v1.2.3 From 69d2501ee1900c43a35802eae05a734e479a7776 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Mon, 29 Jan 2018 23:56:05 -0800 Subject: Revert "QVariant: convert QDateTime and QTime to string with milliseconds" This reverts commit ab1e50757454b5afda2f6dec52d2eb16a32d4798. That was supposed to be a minor behavior change, but ends up having visible effects such as QtXmlPatterns xs:dateTime type now reporting sub-second fractions. So we're reverting in 5.10 and re-applying in 5.11. Change-Id: I741e49459c9a688c1c329d6cbd521cd4a0b2aa84 Reviewed-by: Lars Knoll --- tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) (limited to 'tests/auto/corelib/kernel') diff --git a/tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp b/tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp index 6ec90a66c8..0d45159d09 100644 --- a/tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp +++ b/tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp @@ -1099,9 +1099,8 @@ void tst_QVariant::toString_data() QTest::newRow( "bool" ) << QVariant( true ) << QString( "true" ); QTest::newRow( "qdate" ) << QVariant( QDate( 2002, 1, 1 ) ) << QString( "2002-01-01" ); - QTest::newRow( "qtime" ) << QVariant( QTime( 12, 34, 56 ) ) << QString( "12:34:56.000" ); - QTest::newRow( "qtime-with-ms" ) << QVariant( QTime( 12, 34, 56, 789 ) ) << QString( "12:34:56.789" ); - QTest::newRow( "qdatetime" ) << QVariant( QDateTime( QDate( 2002, 1, 1 ), QTime( 12, 34, 56, 789 ) ) ) << QString( "2002-01-01T12:34:56.789" ); + QTest::newRow( "qtime" ) << QVariant( QTime( 12, 34, 56 ) ) << QString( "12:34:56" ); + QTest::newRow( "qdatetime" ) << QVariant( QDateTime( QDate( 2002, 1, 1 ), QTime( 12, 34, 56 ) ) ) << QString( "2002-01-01T12:34:56" ); QTest::newRow( "llong" ) << QVariant( (qlonglong)Q_INT64_C(123456789012) ) << QString( "123456789012" ); QTest::newRow("QJsonValue") << QVariant(QJsonValue(QString("hello"))) << QString("hello"); @@ -1152,7 +1151,6 @@ void tst_QVariant::toTime_data() QTest::newRow( "qtime" ) << QVariant( QTime( 12, 34, 56 ) ) << QTime( 12, 34, 56 ); QTest::newRow( "qdatetime" ) << QVariant( QDateTime( QDate( 2002, 10, 10 ), QTime( 12, 34, 56 ) ) ) << QTime( 12, 34, 56 ); QTest::newRow( "qstring" ) << QVariant( QString( "12:34:56" ) ) << QTime( 12, 34, 56 ); - QTest::newRow( "qstring-with-ms" ) << QVariant( QString( "12:34:56.789" ) ) << QTime( 12, 34, 56, 789 ); } void tst_QVariant::toTime() @@ -1173,10 +1171,6 @@ void tst_QVariant::toDateTime_data() << QDateTime( QDate( 2002, 10, 10 ), QTime( 12, 34, 56 ) ); QTest::newRow( "qdate" ) << QVariant( QDate( 2002, 10, 10 ) ) << QDateTime( QDate( 2002, 10, 10 ), QTime( 0, 0, 0 ) ); QTest::newRow( "qstring" ) << QVariant( QString( "2002-10-10T12:34:56" ) ) << QDateTime( QDate( 2002, 10, 10 ), QTime( 12, 34, 56 ) ); - QTest::newRow( "qstring-utc" ) << QVariant( QString( "2002-10-10T12:34:56Z" ) ) - << QDateTime( QDate( 2002, 10, 10 ), QTime( 12, 34, 56 ), Qt::UTC ); - QTest::newRow( "qstring-with-ms" ) << QVariant( QString( "2002-10-10T12:34:56.789" ) ) - << QDateTime( QDate( 2002, 10, 10 ), QTime( 12, 34, 56, 789 ) ); } void tst_QVariant::toDateTime() -- cgit v1.2.3