From b94eba6899e4162ce2b5a98b5603289e8ec2f66e Mon Sep 17 00:00:00 2001 From: Jason McDonald Date: Tue, 30 Aug 2011 19:54:32 +1000 Subject: Make lightxml and xml log formatting consistent For XML logs, an Incident tag with no sub-tags has a space before the closing slash. For Light XML logs, this space was missing unless the -flush command line option was supplied. Change-Id: I6de2e140f9309f333b5b97ed7f8116e4e727a149 Reviewed-on: http://codereview.qt.nokia.com/3871 Reviewed-by: Qt Sanity Bot Reviewed-by: Rohan McGovern --- src/testlib/qtestlightxmlstreamer.cpp | 2 +- tests/auto/selftests/expected_assert.lightxml | 4 ++-- tests/auto/selftests/expected_badxml.lightxml | 4 ++-- tests/auto/selftests/expected_benchlibcallgrind.lightxml | 4 ++-- tests/auto/selftests/expected_benchlibeventcounter.lightxml | 4 ++-- tests/auto/selftests/expected_benchliboptions.lightxml | 4 ++-- tests/auto/selftests/expected_benchlibtickcounter.lightxml | 4 ++-- tests/auto/selftests/expected_benchlibwalltime.lightxml | 4 ++-- tests/auto/selftests/expected_cmptest.lightxml | 8 ++++---- tests/auto/selftests/expected_commandlinedata.lightxml | 4 ++-- tests/auto/selftests/expected_crashes.lightxml | 2 +- tests/auto/selftests/expected_datatable.lightxml | 10 +++++----- tests/auto/selftests/expected_datetime.lightxml | 4 ++-- tests/auto/selftests/expected_exceptionthrow.lightxml | 2 +- tests/auto/selftests/expected_expectfail.lightxml | 4 ++-- tests/auto/selftests/expected_failinit.lightxml | 2 +- tests/auto/selftests/expected_fetchbogus.lightxml | 2 +- tests/auto/selftests/expected_globaldata.lightxml | 6 +++--- tests/auto/selftests/expected_longstring.lightxml | 4 ++-- tests/auto/selftests/expected_maxwarnings.lightxml | 4 ++-- tests/auto/selftests/expected_multiexec.lightxml | 6 +++--- tests/auto/selftests/expected_singleskip.lightxml | 4 ++-- tests/auto/selftests/expected_skip.lightxml | 4 ++-- tests/auto/selftests/expected_skipinit.lightxml | 2 +- tests/auto/selftests/expected_sleep.lightxml | 6 +++--- tests/auto/selftests/expected_strcmp.lightxml | 6 +++--- tests/auto/selftests/expected_subtest.lightxml | 8 ++++---- tests/auto/selftests/expected_warnings.lightxml | 4 ++-- tests/auto/selftests/expected_xunit.lightxml | 4 ++-- 29 files changed, 63 insertions(+), 63 deletions(-) diff --git a/src/testlib/qtestlightxmlstreamer.cpp b/src/testlib/qtestlightxmlstreamer.cpp index c0010cc522..892c0fd64e 100644 --- a/src/testlib/qtestlightxmlstreamer.cpp +++ b/src/testlib/qtestlightxmlstreamer.cpp @@ -152,7 +152,7 @@ void QTestLightXmlStreamer::formatBeforeAttributes(const QTestElement *element, element->attributeValue(QTest::AI_Line)); if( !element->childElements() ) - QTest::qt_asprintf(formatted, "\n", + QTest::qt_asprintf(formatted, "\n", element->attributeValue(QTest::AI_Result), buf.constData()); else QTest::qt_asprintf(formatted, "\n", diff --git a/tests/auto/selftests/expected_assert.lightxml b/tests/auto/selftests/expected_assert.lightxml index f49cdf0826..e24545f086 100644 --- a/tests/auto/selftests/expected_assert.lightxml +++ b/tests/auto/selftests/expected_assert.lightxml @@ -3,10 +3,10 @@ @INSERT_QT_VERSION_HERE@ - + - + diff --git a/tests/auto/selftests/expected_badxml.lightxml b/tests/auto/selftests/expected_badxml.lightxml index 0875a62bae..57bcf84e29 100644 --- a/tests/auto/selftests/expected_badxml.lightxml +++ b/tests/auto/selftests/expected_badxml.lightxml @@ -3,7 +3,7 @@ @INSERT_QT_VERSION_HERE@ - + @@ -51,5 +51,5 @@ - + diff --git a/tests/auto/selftests/expected_benchlibcallgrind.lightxml b/tests/auto/selftests/expected_benchlibcallgrind.lightxml index bdc3d77212..dd5319f55e 100644 --- a/tests/auto/selftests/expected_benchlibcallgrind.lightxml +++ b/tests/auto/selftests/expected_benchlibcallgrind.lightxml @@ -3,7 +3,7 @@ @INSERT_QT_VERSION_HERE@ - + @@ -11,5 +11,5 @@ - + diff --git a/tests/auto/selftests/expected_benchlibeventcounter.lightxml b/tests/auto/selftests/expected_benchlibeventcounter.lightxml index 218f4c8916..a6150a90af 100644 --- a/tests/auto/selftests/expected_benchlibeventcounter.lightxml +++ b/tests/auto/selftests/expected_benchlibeventcounter.lightxml @@ -3,7 +3,7 @@ @INSERT_QT_VERSION_HERE@ - + @@ -17,5 +17,5 @@ - + diff --git a/tests/auto/selftests/expected_benchliboptions.lightxml b/tests/auto/selftests/expected_benchliboptions.lightxml index 7a42cc750f..63d0218b2c 100644 --- a/tests/auto/selftests/expected_benchliboptions.lightxml +++ b/tests/auto/selftests/expected_benchliboptions.lightxml @@ -3,7 +3,7 @@ @INSERT_QT_VERSION_HERE@ - + @@ -11,5 +11,5 @@ - + diff --git a/tests/auto/selftests/expected_benchlibtickcounter.lightxml b/tests/auto/selftests/expected_benchlibtickcounter.lightxml index ea926c2073..845fd9c161 100644 --- a/tests/auto/selftests/expected_benchlibtickcounter.lightxml +++ b/tests/auto/selftests/expected_benchlibtickcounter.lightxml @@ -3,7 +3,7 @@ @INSERT_QT_VERSION_HERE@ - + @@ -11,5 +11,5 @@ - + diff --git a/tests/auto/selftests/expected_benchlibwalltime.lightxml b/tests/auto/selftests/expected_benchlibwalltime.lightxml index 500647d606..f1d89328ef 100644 --- a/tests/auto/selftests/expected_benchlibwalltime.lightxml +++ b/tests/auto/selftests/expected_benchlibwalltime.lightxml @@ -3,7 +3,7 @@ @INSERT_QT_VERSION_HERE@ - + @@ -21,5 +21,5 @@ - + diff --git a/tests/auto/selftests/expected_cmptest.lightxml b/tests/auto/selftests/expected_cmptest.lightxml index a6d35e47ac..910d81295d 100644 --- a/tests/auto/selftests/expected_cmptest.lightxml +++ b/tests/auto/selftests/expected_cmptest.lightxml @@ -3,13 +3,13 @@ @INSERT_QT_VERSION_HERE@ - + - + - + @@ -28,5 +28,5 @@ - + diff --git a/tests/auto/selftests/expected_commandlinedata.lightxml b/tests/auto/selftests/expected_commandlinedata.lightxml index ad1f893519..b6ca8693ae 100644 --- a/tests/auto/selftests/expected_commandlinedata.lightxml +++ b/tests/auto/selftests/expected_commandlinedata.lightxml @@ -3,7 +3,7 @@ @INSERT_QT_VERSION_HERE@ - + @@ -32,5 +32,5 @@ - + diff --git a/tests/auto/selftests/expected_crashes.lightxml b/tests/auto/selftests/expected_crashes.lightxml index 2eee3cc3a1..76890deb75 100644 --- a/tests/auto/selftests/expected_crashes.lightxml +++ b/tests/auto/selftests/expected_crashes.lightxml @@ -3,7 +3,7 @@ @INSERT_QT_VERSION_HERE@ - + diff --git a/tests/auto/selftests/expected_datatable.lightxml b/tests/auto/selftests/expected_datatable.lightxml index a1c9d2b057..7e737620bf 100644 --- a/tests/auto/selftests/expected_datatable.lightxml +++ b/tests/auto/selftests/expected_datatable.lightxml @@ -3,16 +3,16 @@ @INSERT_QT_VERSION_HERE@ - + - + - + - + @@ -48,5 +48,5 @@ - + diff --git a/tests/auto/selftests/expected_datetime.lightxml b/tests/auto/selftests/expected_datetime.lightxml index edad6aa832..abc2930f4c 100644 --- a/tests/auto/selftests/expected_datetime.lightxml +++ b/tests/auto/selftests/expected_datetime.lightxml @@ -3,7 +3,7 @@ @INSERT_QT_VERSION_HERE@ - + @@ -23,5 +23,5 @@ - + diff --git a/tests/auto/selftests/expected_exceptionthrow.lightxml b/tests/auto/selftests/expected_exceptionthrow.lightxml index 90371e4e36..0b8de0a6ba 100644 --- a/tests/auto/selftests/expected_exceptionthrow.lightxml +++ b/tests/auto/selftests/expected_exceptionthrow.lightxml @@ -3,7 +3,7 @@ @INSERT_QT_VERSION_HERE@ - + diff --git a/tests/auto/selftests/expected_expectfail.lightxml b/tests/auto/selftests/expected_expectfail.lightxml index d3fb05bb48..1b77cf6230 100644 --- a/tests/auto/selftests/expected_expectfail.lightxml +++ b/tests/auto/selftests/expected_expectfail.lightxml @@ -3,7 +3,7 @@ @INSERT_QT_VERSION_HERE@ - + @@ -31,5 +31,5 @@ - + diff --git a/tests/auto/selftests/expected_failinit.lightxml b/tests/auto/selftests/expected_failinit.lightxml index 93a4e3f90e..0edf225bf1 100644 --- a/tests/auto/selftests/expected_failinit.lightxml +++ b/tests/auto/selftests/expected_failinit.lightxml @@ -8,5 +8,5 @@ - + diff --git a/tests/auto/selftests/expected_fetchbogus.lightxml b/tests/auto/selftests/expected_fetchbogus.lightxml index c53d851d79..b8ecaef782 100644 --- a/tests/auto/selftests/expected_fetchbogus.lightxml +++ b/tests/auto/selftests/expected_fetchbogus.lightxml @@ -3,7 +3,7 @@ @INSERT_QT_VERSION_HERE@ - + diff --git a/tests/auto/selftests/expected_globaldata.lightxml b/tests/auto/selftests/expected_globaldata.lightxml index 2d195ee58b..7e245896f2 100644 --- a/tests/auto/selftests/expected_globaldata.lightxml +++ b/tests/auto/selftests/expected_globaldata.lightxml @@ -3,10 +3,10 @@ @INSERT_QT_VERSION_HERE@ - + - + @@ -26,5 +26,5 @@ - + diff --git a/tests/auto/selftests/expected_longstring.lightxml b/tests/auto/selftests/expected_longstring.lightxml index a186ccc604..945a9f3d94 100644 --- a/tests/auto/selftests/expected_longstring.lightxml +++ b/tests/auto/selftests/expected_longstring.lightxml @@ -3,7 +3,7 @@ @INSERT_QT_VERSION_HERE@ - + @@ -19,5 +19,5 @@ Aenean posuere, tortor sed cursus feugiat, nunc augue blandit nunc, eu sollicitu - + diff --git a/tests/auto/selftests/expected_maxwarnings.lightxml b/tests/auto/selftests/expected_maxwarnings.lightxml index f9320ea151..a5475c4b72 100644 --- a/tests/auto/selftests/expected_maxwarnings.lightxml +++ b/tests/auto/selftests/expected_maxwarnings.lightxml @@ -3,7 +3,7 @@ @INSERT_QT_VERSION_HERE@ - + @@ -6016,5 +6016,5 @@ - + diff --git a/tests/auto/selftests/expected_multiexec.lightxml b/tests/auto/selftests/expected_multiexec.lightxml index 1f42eac34e..1a66e92f8f 100644 --- a/tests/auto/selftests/expected_multiexec.lightxml +++ b/tests/auto/selftests/expected_multiexec.lightxml @@ -3,11 +3,11 @@ @INSERT_QT_VERSION_HERE@ - + - + - + diff --git a/tests/auto/selftests/expected_singleskip.lightxml b/tests/auto/selftests/expected_singleskip.lightxml index 971a999643..bcddcae004 100644 --- a/tests/auto/selftests/expected_singleskip.lightxml +++ b/tests/auto/selftests/expected_singleskip.lightxml @@ -3,7 +3,7 @@ @INSERT_QT_VERSION_HERE@ - + @@ -11,5 +11,5 @@ - + diff --git a/tests/auto/selftests/expected_skip.lightxml b/tests/auto/selftests/expected_skip.lightxml index 145704ef7a..474fccc9c6 100644 --- a/tests/auto/selftests/expected_skip.lightxml +++ b/tests/auto/selftests/expected_skip.lightxml @@ -3,7 +3,7 @@ @INSERT_QT_VERSION_HERE@ - + @@ -26,5 +26,5 @@ - + diff --git a/tests/auto/selftests/expected_skipinit.lightxml b/tests/auto/selftests/expected_skipinit.lightxml index ea07bd7b9d..005169e7e6 100644 --- a/tests/auto/selftests/expected_skipinit.lightxml +++ b/tests/auto/selftests/expected_skipinit.lightxml @@ -8,5 +8,5 @@ - + diff --git a/tests/auto/selftests/expected_sleep.lightxml b/tests/auto/selftests/expected_sleep.lightxml index d7e8ea970f..1a056c8562 100644 --- a/tests/auto/selftests/expected_sleep.lightxml +++ b/tests/auto/selftests/expected_sleep.lightxml @@ -3,11 +3,11 @@ @INSERT_QT_VERSION_HERE@ - + - + - + diff --git a/tests/auto/selftests/expected_strcmp.lightxml b/tests/auto/selftests/expected_strcmp.lightxml index 40b5da4878..ede19b8171 100644 --- a/tests/auto/selftests/expected_strcmp.lightxml +++ b/tests/auto/selftests/expected_strcmp.lightxml @@ -3,10 +3,10 @@ @INSERT_QT_VERSION_HERE@ - + - + @@ -47,5 +47,5 @@ - + diff --git a/tests/auto/selftests/expected_subtest.lightxml b/tests/auto/selftests/expected_subtest.lightxml index c2b8d4d2f7..00c1a992bd 100644 --- a/tests/auto/selftests/expected_subtest.lightxml +++ b/tests/auto/selftests/expected_subtest.lightxml @@ -3,13 +3,13 @@ @INSERT_QT_VERSION_HERE@ - + - + - + @@ -45,5 +45,5 @@ - + diff --git a/tests/auto/selftests/expected_warnings.lightxml b/tests/auto/selftests/expected_warnings.lightxml index 4e0ae8a789..c91d9d5da6 100644 --- a/tests/auto/selftests/expected_warnings.lightxml +++ b/tests/auto/selftests/expected_warnings.lightxml @@ -3,7 +3,7 @@ @INSERT_QT_VERSION_HERE@ - + @@ -39,5 +39,5 @@ - + diff --git a/tests/auto/selftests/expected_xunit.lightxml b/tests/auto/selftests/expected_xunit.lightxml index 726f08d321..f276c051be 100644 --- a/tests/auto/selftests/expected_xunit.lightxml +++ b/tests/auto/selftests/expected_xunit.lightxml @@ -3,7 +3,7 @@ @INSERT_QT_VERSION_HERE@ - + @@ -48,5 +48,5 @@ - + -- cgit v1.2.3 From 21776e926074a572316dfb4e3346423f3111d7f7 Mon Sep 17 00:00:00 2001 From: Jason McDonald Date: Wed, 31 Aug 2011 12:52:27 +1000 Subject: Fix errors in lightxml test logger The newer test logger did not produce the same light XML output as the logger that it replaced. In particular, it did not output the tag and it incorrectly nested a tag inside the tag when a fatal error occured in a test. Unfortunately, it appears that the expected lightxml output for the selftests was produced by running tests using the newer logger, while the selftests did not use the older lightxml logger. Thus the errors were not detected by the selftests. This commit adds the older lightxml logger to the selftests, updates the expected test data accordingly, and modifies the newer lightxml logger to behave correctly. This last item is achieved by making the lightxml streamer copy most of the code from the xml streamer -- lightxml output is supposed to be same as xml, except for the omission of the root and tags. Change-Id: Ie6e1f69dd6000df2b9d0c5c8e2109fe7bbff3956 Reviewed-on: http://codereview.qt.nokia.com/3902 Reviewed-by: Qt Sanity Bot Reviewed-by: Rohan McGovern --- src/testlib/qtestlightxmlstreamer.cpp | 88 +++++++++++++++------- tests/auto/selftests/expected_assert.lightxml | 2 +- tests/auto/selftests/expected_badxml.lightxml | 25 +++++- .../selftests/expected_benchlibcallgrind.lightxml | 3 +- .../expected_benchlibeventcounter.lightxml | 3 +- tests/auto/selftests/expected_cmptest.lightxml | 10 +++ .../selftests/expected_commandlinedata.lightxml | 12 ++- tests/auto/selftests/expected_datatable.lightxml | 29 +++++++ tests/auto/selftests/expected_datetime.lightxml | 2 + tests/auto/selftests/expected_expectfail.lightxml | 11 ++- tests/auto/selftests/expected_fetchbogus.lightxml | 4 +- tests/auto/selftests/expected_globaldata.lightxml | 6 +- tests/auto/selftests/expected_maxwarnings.lightxml | 3 +- tests/auto/selftests/expected_skip.lightxml | 5 +- tests/auto/selftests/expected_strcmp.lightxml | 8 +- tests/auto/selftests/expected_warnings.lightxml | 5 +- tests/auto/selftests/expected_xunit.lightxml | 7 +- tests/auto/selftests/tst_selftests.cpp | 22 +++--- 18 files changed, 177 insertions(+), 68 deletions(-) diff --git a/src/testlib/qtestlightxmlstreamer.cpp b/src/testlib/qtestlightxmlstreamer.cpp index 892c0fd64e..4aba2a2bf8 100644 --- a/src/testlib/qtestlightxmlstreamer.cpp +++ b/src/testlib/qtestlightxmlstreamer.cpp @@ -77,9 +77,32 @@ void QTestLightXmlStreamer::formatStart(const QTestElement *element, QTestCharBu QTestCharBuffer cdataDesc; QXmlTestLogger::xmlCdata(&cdataDesc, element->attributeValue(QTest::AI_Description)); - QTest::qt_asprintf(formatted, " \n", - cdataDesc.constData()); - break; + QTestCharBuffer location; + QTestCharBuffer quotedFile; + QXmlTestLogger::xmlQuote("edFile, element->attributeValue(QTest::AI_File)); + + QTest::qt_asprintf(&location, "%s=\"%s\" %s=\"%s\"", + element->attributeName(QTest::AI_File), + quotedFile.constData(), + element->attributeName(QTest::AI_Line), + element->attributeValue(QTest::AI_Line)); + + if (element->attribute(QTest::AI_Tag)) { + QTestCharBuffer cdataTag; + QXmlTestLogger::xmlCdata(&cdataTag, element->attributeValue(QTest::AI_Tag)); + QTest::qt_asprintf(formatted, "\n" + " \n" + " \n" + "\n", element->attributeValue(QTest::AI_Result), + location.constData(), cdataTag.constData(), cdataDesc.constData()); + } + else { + QTest::qt_asprintf(formatted, "\n" + " \n" + "\n", element->attributeValue(QTest::AI_Result), + location.constData(), cdataDesc.constData()); + } + break; } case QTest::LET_Error: { // assuming type and attribute names don't need quoting @@ -88,12 +111,20 @@ void QTestLightXmlStreamer::formatStart(const QTestElement *element, QTestCharBu QXmlTestLogger::xmlQuote("edFile, element->attributeValue(QTest::AI_File)); QXmlTestLogger::xmlCdata(&cdataDesc, element->attributeValue(QTest::AI_Description)); - QTest::qt_asprintf(formatted, "\n \n\n", + QTestCharBuffer tagbuf; + if (element->attribute(QTest::AI_Tag)) { + QTestCharBuffer cdataTag; + QXmlTestLogger::xmlCdata(&cdataTag, element->attributeValue(QTest::AI_Tag)); + QTest::qt_asprintf(&tagbuf, " \n", cdataTag.constData()); + } + + QTest::qt_asprintf(formatted, "\n%s \n\n", element->attributeValue(QTest::AI_Type), element->attributeName(QTest::AI_File), quotedFile.constData(), element->attributeName(QTest::AI_Line), element->attributeValue(QTest::AI_Line), + tagbuf.constData(), cdataDesc.constData()); break; } @@ -126,10 +157,29 @@ void QTestLightXmlStreamer::formatEnd(const QTestElement *element, QTestCharBuff return; if (element->elementType() == QTest::LET_TestCase) { - if( element->attribute(QTest::AI_Result) && element->childElements()) - QTest::qt_asprintf(formatted, "\n\n"); - else + bool failed = false; + for (QTestElement* child = element->childElements(); child; child = child->nextElement()) { + if ( child->elementType() == QTest::LET_Failure + && child->attribute(QTest::AI_Result) + && ( !strcmp(child->attributeValue(QTest::AI_Result), "fail") + || !strcmp(child->attributeValue(QTest::AI_Result), "xpass")) + ) + { + failed = true; + break; + } + } + + // For passing functions, no Incident has been output yet. + // For failing functions, we already output one. + // Please note: we are outputting "pass" even if there was an xfail etc. + // This is by design (arguably bad design, but dangerous to change now!) + if (element->attribute(QTest::AI_Result) && !failed) { + QTest::qt_asprintf(formatted, "\n\n"); + } + else { QTest::qt_asprintf(formatted, "\n"); + } } else { formatted->data()[0] = '\0'; } @@ -137,29 +187,11 @@ void QTestLightXmlStreamer::formatEnd(const QTestElement *element, QTestCharBuff void QTestLightXmlStreamer::formatBeforeAttributes(const QTestElement *element, QTestCharBuffer *formatted) const { - if(!element || !formatted) + Q_UNUSED(element); + if (!formatted) return; - if (element->elementType() == QTest::LET_TestCase && element->attribute(QTest::AI_Result)) { - QTestCharBuffer buf; - QTestCharBuffer quotedFile; - QXmlTestLogger::xmlQuote("edFile, element->attributeValue(QTest::AI_File)); - - QTest::qt_asprintf(&buf, "%s=\"%s\" %s=\"%s\"", - element->attributeName(QTest::AI_File), - quotedFile.constData(), - element->attributeName(QTest::AI_Line), - element->attributeValue(QTest::AI_Line)); - - if( !element->childElements() ) - QTest::qt_asprintf(formatted, "\n", - element->attributeValue(QTest::AI_Result), buf.constData()); - else - QTest::qt_asprintf(formatted, "\n", - element->attributeValue(QTest::AI_Result), buf.constData()); - } else { - formatted->data()[0] = '\0'; - } + formatted->data()[0] = '\0'; } void QTestLightXmlStreamer::output(QTestElement *element) const diff --git a/tests/auto/selftests/expected_assert.lightxml b/tests/auto/selftests/expected_assert.lightxml index e24545f086..9062ca69a8 100644 --- a/tests/auto/selftests/expected_assert.lightxml +++ b/tests/auto/selftests/expected_assert.lightxml @@ -9,10 +9,10 @@ - + diff --git a/tests/auto/selftests/expected_badxml.lightxml b/tests/auto/selftests/expected_badxml.lightxml index 57bcf84e29..19bec33e1e 100644 --- a/tests/auto/selftests/expected_badxml.lightxml +++ b/tests/auto/selftests/expected_badxml.lightxml @@ -6,44 +6,61 @@ - + text ]]]> more text]]> + + text ]]]> more text]]> + + + + + + open < tags < text]]> + + open < tags < text]]> + + " mixed ]]]> up > " in < the ]]]> hopes < of triggering "< ]]]> bugs]]> + + " mixed ]]]> up > " in < the ]]]> hopes < of triggering "< ]]]> bugs]]> - + - + text ]]]> more text]]> + + open < tags < text]]> + " mixed ]]]> up > " in < the ]]]> hopes < of triggering "< ]]]> bugs]]> - + diff --git a/tests/auto/selftests/expected_benchlibcallgrind.lightxml b/tests/auto/selftests/expected_benchlibcallgrind.lightxml index dd5319f55e..c2394e545e 100644 --- a/tests/auto/selftests/expected_benchlibcallgrind.lightxml +++ b/tests/auto/selftests/expected_benchlibcallgrind.lightxml @@ -6,9 +6,8 @@ - - + diff --git a/tests/auto/selftests/expected_benchlibeventcounter.lightxml b/tests/auto/selftests/expected_benchlibeventcounter.lightxml index a6150a90af..3bede6de83 100644 --- a/tests/auto/selftests/expected_benchlibeventcounter.lightxml +++ b/tests/auto/selftests/expected_benchlibeventcounter.lightxml @@ -6,7 +6,6 @@ - @@ -14,7 +13,7 @@ - + diff --git a/tests/auto/selftests/expected_cmptest.lightxml b/tests/auto/selftests/expected_cmptest.lightxml index 910d81295d..72d1caf5f8 100644 --- a/tests/auto/selftests/expected_cmptest.lightxml +++ b/tests/auto/selftests/expected_cmptest.lightxml @@ -13,15 +13,25 @@ + + + + + + + + + + ) Expected (expected): QVariant(PhonyClass,)]]> diff --git a/tests/auto/selftests/expected_commandlinedata.lightxml b/tests/auto/selftests/expected_commandlinedata.lightxml index b6ca8693ae..6907b7211f 100644 --- a/tests/auto/selftests/expected_commandlinedata.lightxml +++ b/tests/auto/selftests/expected_commandlinedata.lightxml @@ -6,30 +6,34 @@ - + + + + + - + - + - + diff --git a/tests/auto/selftests/expected_datatable.lightxml b/tests/auto/selftests/expected_datatable.lightxml index 7e737620bf..e14d1e2abb 100644 --- a/tests/auto/selftests/expected_datatable.lightxml +++ b/tests/auto/selftests/expected_datatable.lightxml @@ -16,34 +16,63 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/auto/selftests/expected_datetime.lightxml b/tests/auto/selftests/expected_datetime.lightxml index abc2930f4c..49f8546e6a 100644 --- a/tests/auto/selftests/expected_datetime.lightxml +++ b/tests/auto/selftests/expected_datetime.lightxml @@ -17,6 +17,8 @@ + + diff --git a/tests/auto/selftests/expected_expectfail.lightxml b/tests/auto/selftests/expected_expectfail.lightxml index 1b77cf6230..003b8e866d 100644 --- a/tests/auto/selftests/expected_expectfail.lightxml +++ b/tests/auto/selftests/expected_expectfail.lightxml @@ -6,29 +6,34 @@ - + + - + - + + + + + diff --git a/tests/auto/selftests/expected_fetchbogus.lightxml b/tests/auto/selftests/expected_fetchbogus.lightxml index b8ecaef782..1812c0e6b5 100644 --- a/tests/auto/selftests/expected_fetchbogus.lightxml +++ b/tests/auto/selftests/expected_fetchbogus.lightxml @@ -6,10 +6,12 @@ - + + + diff --git a/tests/auto/selftests/expected_globaldata.lightxml b/tests/auto/selftests/expected_globaldata.lightxml index 7e245896f2..c4db4bc90c 100644 --- a/tests/auto/selftests/expected_globaldata.lightxml +++ b/tests/auto/selftests/expected_globaldata.lightxml @@ -10,20 +10,22 @@ + + - + - + diff --git a/tests/auto/selftests/expected_maxwarnings.lightxml b/tests/auto/selftests/expected_maxwarnings.lightxml index a5475c4b72..054108fe6d 100644 --- a/tests/auto/selftests/expected_maxwarnings.lightxml +++ b/tests/auto/selftests/expected_maxwarnings.lightxml @@ -6,7 +6,6 @@ - @@ -6013,7 +6012,7 @@ - + diff --git a/tests/auto/selftests/expected_skip.lightxml b/tests/auto/selftests/expected_skip.lightxml index 474fccc9c6..61cfe7db72 100644 --- a/tests/auto/selftests/expected_skip.lightxml +++ b/tests/auto/selftests/expected_skip.lightxml @@ -16,14 +16,15 @@ - + + - + diff --git a/tests/auto/selftests/expected_strcmp.lightxml b/tests/auto/selftests/expected_strcmp.lightxml index ede19b8171..28dc9335ec 100644 --- a/tests/auto/selftests/expected_strcmp.lightxml +++ b/tests/auto/selftests/expected_strcmp.lightxml @@ -9,10 +9,16 @@ - + + + + + + + diff --git a/tests/auto/selftests/expected_warnings.lightxml b/tests/auto/selftests/expected_warnings.lightxml index c91d9d5da6..116156ed8a 100644 --- a/tests/auto/selftests/expected_warnings.lightxml +++ b/tests/auto/selftests/expected_warnings.lightxml @@ -6,7 +6,6 @@ - @@ -25,16 +24,16 @@ - + - + diff --git a/tests/auto/selftests/expected_xunit.lightxml b/tests/auto/selftests/expected_xunit.lightxml index f276c051be..92772015c8 100644 --- a/tests/auto/selftests/expected_xunit.lightxml +++ b/tests/auto/selftests/expected_xunit.lightxml @@ -6,17 +6,16 @@ - - + - ]]> + @@ -36,11 +35,13 @@ + + diff --git a/tests/auto/selftests/tst_selftests.cpp b/tests/auto/selftests/tst_selftests.cpp index 78f0620779..320d993426 100644 --- a/tests/auto/selftests/tst_selftests.cpp +++ b/tests/auto/selftests/tst_selftests.cpp @@ -173,11 +173,12 @@ Logger::Logger(QString const& _name, QString const& _testdata_suffix, QStringLis static QList allLoggers() { return QList() - << Logger("plain", "txt", QStringList()) - << Logger("xml", "xml", QStringList() << "-xml") - << Logger("xml flush", "xml", QStringList() << "-xml" << "-flush") - << Logger("xunitxml", "xunitxml", QStringList() << "-xunitxml") - << Logger("lightxml", "lightxml", QStringList() << "-lightxml") + << Logger("plain", "txt", QStringList()) + << Logger("xml", "xml", QStringList() << "-xml") + << Logger("xml flush", "xml", QStringList() << "-xml" << "-flush") + << Logger("xunitxml", "xunitxml", QStringList() << "-xunitxml") + << Logger("lightxml", "lightxml", QStringList() << "-lightxml") + << Logger("lightxml flush", "lightxml", QStringList() << "-lightxml" << "-flush") ; } @@ -416,11 +417,12 @@ void tst_Selftests::doRunSubTest(QString const& subdir, QString const& logger, Q const QString expected(QString::fromLatin1(exp.at(i)).replace("@INSERT_QT_VERSION_HERE@", QT_VERSION_STR)); if (line.contains("ASSERT") && output != expected) { - QEXPECT_FAIL("assert", "QTestLib prints out the absolute path.", Continue); - QEXPECT_FAIL("assert xml", "QTestLib prints out the absolute path.", Continue); - QEXPECT_FAIL("assert xml flush","QTestLib prints out the absolute path.", Continue); - QEXPECT_FAIL("assert lightxml", "QTestLib prints out the absolute path.", Continue); - QEXPECT_FAIL("assert xunitxml", "QTestLib prints out the absolute path.", Continue); + QEXPECT_FAIL("assert", "QTestLib prints out the absolute path.", Continue); + QEXPECT_FAIL("assert xml", "QTestLib prints out the absolute path.", Continue); + QEXPECT_FAIL("assert xml flush", "QTestLib prints out the absolute path.", Continue); + QEXPECT_FAIL("assert lightxml", "QTestLib prints out the absolute path.", Continue); + QEXPECT_FAIL("assert lightxml flush", "QTestLib prints out the absolute path.", Continue); + QEXPECT_FAIL("assert xunitxml", "QTestLib prints out the absolute path.", Continue); } /* On some platforms we compile without RTTI, and as a result we never throw an exception. */ -- cgit v1.2.3 From dd91701a502859e57a095fccebde502c6abc458b Mon Sep 17 00:00:00 2001 From: Peter Hartmann Date: Tue, 30 Aug 2011 12:24:30 +0200 Subject: QSslCertificate: regenerate blacklisted certificates, they were expired regenerating blacklisted certificates with same serial number and common name, but longer validity: Now they are valid for 10 years. (cherry picked from commit a3d22777028b102b7f65cf2db9719f5d57308b04) Change-Id: I7884484c2f61b3a55f671faa38967e62fc8954f0 Reviewed-on: http://codereview.qt.nokia.com/3894 Reviewed-by: Qt Sanity Bot Reviewed-by: Martin Petersson --- .../more-certificates/blacklisted1.pem | 20 ++++++++++---------- .../more-certificates/blacklisted2.pem | 20 ++++++++++---------- .../more-certificates/blacklisted3.pem | 20 ++++++++++---------- .../more-certificates/blacklisted4.pem | 20 ++++++++++---------- .../more-certificates/blacklisted5.pem | 20 ++++++++++---------- .../more-certificates/blacklisted6.pem | 20 ++++++++++---------- .../more-certificates/blacklisted7.pem | 20 ++++++++++---------- .../more-certificates/blacklisted8.pem | 20 ++++++++++---------- .../more-certificates/blacklisted9.pem | 20 ++++++++++---------- 9 files changed, 90 insertions(+), 90 deletions(-) diff --git a/tests/auto/qsslcertificate/more-certificates/blacklisted1.pem b/tests/auto/qsslcertificate/more-certificates/blacklisted1.pem index 3945aea91e..7fc0a054c0 100644 --- a/tests/auto/qsslcertificate/more-certificates/blacklisted1.pem +++ b/tests/auto/qsslcertificate/more-certificates/blacklisted1.pem @@ -2,18 +2,18 @@ MIIDDzCCAnigAwIBAgIQBH7L6fylX3vQnq424QyuHjANBgkqhkiG9w0BAQUFADBf MQswCQYDVQQGEwJBVTETMBEGA1UECBMKU29tZS1TdGF0ZTEhMB8GA1UEChMYSW50 ZXJuZXQgV2lkZ2l0cyBQdHkgTHRkMRgwFgYDVQQDEw9tYWlsLmdvb2dsZS5jb20w -HhcNMTEwMzI0MTMwNjI1WhcNMTEwNDIzMTMwNjI1WjBfMQswCQYDVQQGEwJBVTET +HhcNMTEwODMwMTAxOTI2WhcNMjEwODI3MTAxOTI2WjBfMQswCQYDVQQGEwJBVTET MBEGA1UECBMKU29tZS1TdGF0ZTEhMB8GA1UEChMYSW50ZXJuZXQgV2lkZ2l0cyBQ dHkgTHRkMRgwFgYDVQQDEw9tYWlsLmdvb2dsZS5jb20wgZ8wDQYJKoZIhvcNAQEB -BQADgY0AMIGJAoGBAOeAGV2FbGnT4rLjTvCNEEDjj0/iIUATa6RT8WKF2PVaOzbE -oceiODx6hTStvBnCgs+h/d3eVKgp+uAyBde5sW/HlOwHrNgKF3ZDvxegzIOEHaVI -ndNtBpFS3UyOEkO0NxfioBatNRYpeTRU/DVmazu3yvzgrV1V2mDsrNngVWxJAgMB -AAGjgcswgcgwHQYDVR0OBBYEFHcF1eqRpm7B78aY8ZjseN6zSYbvMIGYBgNVHSME -gZAwgY2AFHcF1eqRpm7B78aY8ZjseN6zSYbvoWOkYTBfMQswCQYDVQQGEwJBVTET +BQADgY0AMIGJAoGBANOvJQGm9vyX8f61SP1XDp23sEDS2SAsDNIxdeONmFthfQRh +EBlJMNDByegnImZPMN4tA2T2iKcvdkxyQhC9vnQ+HEqJxxu0EhOwO+UdsSII7Lns +yQZVj2QAoTvC0+MFHPo+wl39JEe3ZytNwQZLjfZSLdS/j0cAyoTkFNconK0bAgMB +AAGjgcswgcgwHQYDVR0OBBYEFGFxxhfk1fvT8zPfLKPE0YYp9HZEMIGYBgNVHSME +gZAwgY2AFGFxxhfk1fvT8zPfLKPE0YYp9HZEoWOkYTBfMQswCQYDVQQGEwJBVTET MBEGA1UECBMKU29tZS1TdGF0ZTEhMB8GA1UEChMYSW50ZXJuZXQgV2lkZ2l0cyBQ dHkgTHRkMRgwFgYDVQQDEw9tYWlsLmdvb2dsZS5jb22CEAR+y+n8pV970J6uNuEM -rh4wDAYDVR0TBAUwAwEB/zANBgkqhkiG9w0BAQUFAAOBgQBEb1iF+EbhAJli5Sj2 -+iEdJ5xMP8R6FtgqAYknqXD8+tyEyXxJXdN186qdAWuTD9N22AUqi61BPWxUkufW -xH8FYMEHdFCkitvYE0321+GT5pJz6ON/d5Co+wusumt7T5oSjzj8Ax9V+nmo3Nkb -dSANM4/Lnc6moijcpJZq+GC1ng== +rh4wDAYDVR0TBAUwAwEB/zANBgkqhkiG9w0BAQUFAAOBgQAldVSTJ4lNG9Qxx2GG +/y/ccH/BBYkpPXBklKP/U528Zk48jypWsbnZ07rQrPIlSXYQHffdNH3JsEiF/el9 +bIu+6tGJzmjqvtl5fD5S+yBvI3ySx3Fz6lWmUlqT6UY1X8Oob2PsR6u6mfT8Q1da +d02x97EUSiAzYvzxndqD6g8R1w== -----END CERTIFICATE----- diff --git a/tests/auto/qsslcertificate/more-certificates/blacklisted2.pem b/tests/auto/qsslcertificate/more-certificates/blacklisted2.pem index 4b8d0599d2..3c8489fbcd 100644 --- a/tests/auto/qsslcertificate/more-certificates/blacklisted2.pem +++ b/tests/auto/qsslcertificate/more-certificates/blacklisted2.pem @@ -2,18 +2,18 @@ MIIDDjCCAnegAwIBAgIRAPXIavNhYvE6ZPVPbclYfAYwDQYJKoZIhvcNAQEFBQAw XjELMAkGA1UEBhMCQVUxEzARBgNVBAgTClNvbWUtU3RhdGUxITAfBgNVBAoTGElu dGVybmV0IFdpZGdpdHMgUHR5IEx0ZDEXMBUGA1UEAxMOd3d3Lmdvb2dsZS5jb20w -HhcNMTEwMzI0MTMwNzExWhcNMTEwNDIzMTMwNzExWjBeMQswCQYDVQQGEwJBVTET +HhcNMTEwODMwMTAxOTUxWhcNMjEwODI3MTAxOTUxWjBeMQswCQYDVQQGEwJBVTET MBEGA1UECBMKU29tZS1TdGF0ZTEhMB8GA1UEChMYSW50ZXJuZXQgV2lkZ2l0cyBQ dHkgTHRkMRcwFQYDVQQDEw53d3cuZ29vZ2xlLmNvbTCBnzANBgkqhkiG9w0BAQEF -AAOBjQAwgYkCgYEAy1fNDFl65Njfcd1EUJeaxvyiKln+JKlqUmk1x4mrE1BQoa0C -QZaiXAF21rDhivWejZWBiEQ4IWbg3b12ANY74G1KqAfLC4BNKS9UP94hy18vezRA -pFc+m/HAClwc8AdACpl8eZpQW8cMgdvnMBMZTrQkgV0JYykX+uDD9Tb+QNUCAwEA -AaOByzCByDAdBgNVHQ4EFgQUSelG6IVRj2ZQbp049zkQ0X/Po9wwgZgGA1UdIwSB -kDCBjYAUSelG6IVRj2ZQbp049zkQ0X/Po9yhYqRgMF4xCzAJBgNVBAYTAkFVMRMw +AAOBjQAwgYkCgYEAriNo6jkVPi+gyynL2YiPBqDsBa4MuM4rQwM7vcHDRO9GizKi +6gV7/loaqvr7zqKnHmoARP6OqxDMMEWfZ4QGJjToVKS6srE7dPJEh1lRzK+bsl02 +xGCP/RKJqnZcW1oUpFUceRBQ8TWynZ1L7cE/YUlOhqXnMO9aPibqbWj8AGcCAwEA +AaOByzCByDAdBgNVHQ4EFgQUo/E6UVU6oRgxQF8yftx0/9dvzMgwgZgGA1UdIwSB +kDCBjYAUo/E6UVU6oRgxQF8yftx0/9dvzMihYqRgMF4xCzAJBgNVBAYTAkFVMRMw EQYDVQQIEwpTb21lLVN0YXRlMSEwHwYDVQQKExhJbnRlcm5ldCBXaWRnaXRzIFB0 eSBMdGQxFzAVBgNVBAMTDnd3dy5nb29nbGUuY29tghEA9chq82Fi8Tpk9U9tyVh8 -BjAMBgNVHRMEBTADAQH/MA0GCSqGSIb3DQEBBQUAA4GBALQyDC/AMQMNj2fa6E8L -umILCklWJwG1K1p/1bUAgm0CB8zm94n1xrh/ZK4+HS+k2a9OQmvLRbFyJn8Wua8p -3UU0267UNkCanA1FKHuO3Mo18wLvjMLWjjCQ4g1C9IvJx6P+8EFDQFG+MJBV/w2k -gJXXVl3q1T1dvahIgfav9QBL +BjAMBgNVHRMEBTADAQH/MA0GCSqGSIb3DQEBBQUAA4GBAESHOPB9eAsTKkO4lY8d +EKr2XrRqUkk5KqMFraAHWRekJFwl0R39Q6MDjRHr6NpPJkSKuBPppkr9nk6WDfpt +TG+oN3Yb1rFmJv6eZw8ud9btoquc8jAtaQnihbjFPEP9cCLBw3Gz1C/JBjDw1tgK +zXKNU+jMZYk7c5Z64DocggBH -----END CERTIFICATE----- diff --git a/tests/auto/qsslcertificate/more-certificates/blacklisted3.pem b/tests/auto/qsslcertificate/more-certificates/blacklisted3.pem index e47ece60dd..fa458cca36 100644 --- a/tests/auto/qsslcertificate/more-certificates/blacklisted3.pem +++ b/tests/auto/qsslcertificate/more-certificates/blacklisted3.pem @@ -2,18 +2,18 @@ MIIDETCCAnqgAwIBAgIRANdVj9r18RBbshMoK3B3KaMwDQYJKoZIhvcNAQEFBQAw XzELMAkGA1UEBhMCQVUxEzARBgNVBAgTClNvbWUtU3RhdGUxITAfBgNVBAoTGElu dGVybmV0IFdpZGdpdHMgUHR5IEx0ZDEYMBYGA1UEAxMPbG9naW4ueWFob28uY29t -MB4XDTExMDMyNDEzMDg0MloXDTExMDQyMzEzMDg0MlowXzELMAkGA1UEBhMCQVUx +MB4XDTExMDgzMDEwMjAzNloXDTIxMDgyNzEwMjAzNlowXzELMAkGA1UEBhMCQVUx EzARBgNVBAgTClNvbWUtU3RhdGUxITAfBgNVBAoTGEludGVybmV0IFdpZGdpdHMg UHR5IEx0ZDEYMBYGA1UEAxMPbG9naW4ueWFob28uY29tMIGfMA0GCSqGSIb3DQEB -AQUAA4GNADCBiQKBgQCosFLKRvGtxjvdAjWdEAHYycFTa4VtdpXmCNhNHf2xbeLn -xzde10KjEe44pQxNI+UUD1rJkyuH6wUfloyefn0D2Mu+MvusmvOEzFosa4EDbK9s -BAAlsSiyJgrp/GgbEPq/XOl4XJRBIVP1WC6LllduNbskFCipDqS+HQwifXmmwQID -AQABo4HMMIHJMB0GA1UdDgQWBBSEgWnsoYtd5GEx/MGJvKxuIuROJzCBmQYDVR0j -BIGRMIGOgBSEgWnsoYtd5GEx/MGJvKxuIuROJ6FjpGEwXzELMAkGA1UEBhMCQVUx +AQUAA4GNADCBiQKBgQC3TVwiPfNClgadKYuX50szBlIaVWDd+UFHsakbGk0bgqlu +YKgC/cmbjgOyrmsEC2HbJISceTz9CK6mCewEgGFWuq6gjYi4UnSFk1o6h6WJV86A +tLpeVti7lN9/04IW7XHyxuhvS71V+JWlqfu3zboyaVoMIlHDrPFtRiAh7vTTjQID +AQABo4HMMIHJMB0GA1UdDgQWBBQrVExlI4rixsrub6IMDDsLPNB4ezCBmQYDVR0j +BIGRMIGOgBQrVExlI4rixsrub6IMDDsLPNB4e6FjpGEwXzELMAkGA1UEBhMCQVUx EzARBgNVBAgTClNvbWUtU3RhdGUxITAfBgNVBAoTGEludGVybmV0IFdpZGdpdHMg UHR5IEx0ZDEYMBYGA1UEAxMPbG9naW4ueWFob28uY29tghEA11WP2vXxEFuyEygr -cHcpozAMBgNVHRMEBTADAQH/MA0GCSqGSIb3DQEBBQUAA4GBAKNpIrzTOxIykKZt -EE6HU2nW1lrWUkIMjwjL8ntw7QI4JLMDN1ADVIxWaGTeQ+U/eXFou6dDNAYVAijK -ONDXgOItxW2YvSw0wOZsZj6INX2x88/0yRH+19TqaL/r+Y1D1h/0zefkHgfXufnY -Ex7BHju/rGBTp6R1mr+Tlh1tewva +cHcpozAMBgNVHRMEBTADAQH/MA0GCSqGSIb3DQEBBQUAA4GBAFB5SF2ujZzH9KMj +m4ZDTsyy94/YQZdwgLncKUYTxmZe4BdX+42j799pCG+UeQGwqz9hU/soPgibAvGT +1KCEGQ6qtWSqKJYmC8VKenYvvEFIySj5cbSFmId5aNwhjl8AYoLuM0E+2FRVJQ6a +pWyzYUIOqhsCkt9hEPsDVP4hIhP+ -----END CERTIFICATE----- diff --git a/tests/auto/qsslcertificate/more-certificates/blacklisted4.pem b/tests/auto/qsslcertificate/more-certificates/blacklisted4.pem index 64c7d41516..53761bb36a 100644 --- a/tests/auto/qsslcertificate/more-certificates/blacklisted4.pem +++ b/tests/auto/qsslcertificate/more-certificates/blacklisted4.pem @@ -2,18 +2,18 @@ MIIDDzCCAnigAwIBAgIQOSpDTw4H3x+KowXeNODCKTANBgkqhkiG9w0BAQUFADBf MQswCQYDVQQGEwJBVTETMBEGA1UECBMKU29tZS1TdGF0ZTEhMB8GA1UEChMYSW50 ZXJuZXQgV2lkZ2l0cyBQdHkgTHRkMRgwFgYDVQQDEw9sb2dpbi55YWhvby5jb20w -HhcNMTEwMzI0MTMwOTE1WhcNMTEwNDIzMTMwOTE1WjBfMQswCQYDVQQGEwJBVTET +HhcNMTEwODMwMTAyMTE5WhcNMjEwODI3MTAyMTE5WjBfMQswCQYDVQQGEwJBVTET MBEGA1UECBMKU29tZS1TdGF0ZTEhMB8GA1UEChMYSW50ZXJuZXQgV2lkZ2l0cyBQ dHkgTHRkMRgwFgYDVQQDEw9sb2dpbi55YWhvby5jb20wgZ8wDQYJKoZIhvcNAQEB -BQADgY0AMIGJAoGBANO2gz9x2H92xz5OvZSEul9gHxqqd+kdjeoS2exyvjC9wzqb -gYXqNmAsbtNp4WmieEQFd0riCAEkIAn8JpHTCsMHN4rHhS+W+4D5a/drI2jfnZEF -orNYJG1PHSQV/rvh6d7wkVdT+0SYOjrFTAA2biGWaK3W9ztf2yX577w+uQtBAgMB -AAGjgcswgcgwHQYDVR0OBBYEFJjDp8Prs7oReRmskIeFixp0vDkGMIGYBgNVHSME -gZAwgY2AFJjDp8Prs7oReRmskIeFixp0vDkGoWOkYTBfMQswCQYDVQQGEwJBVTET +BQADgY0AMIGJAoGBAML+Z5hpY4VfSeTPbMCGaqe5shwcw3yW/egYY6cXcfxtUkjs +Eai48hP/sqtQeFwi3puJ7HO2iGUX72/UnO0t9qwEGtGOHS1qqAYdTcncY5pTpO9L +e4Tn6CkPwFE4VNXVU96xPlUjP/KBZ43VH6gW3M1xDI0DmNh2QUXHN5ErQE8nAgMB +AAGjgcswgcgwHQYDVR0OBBYEFI+gG6PT7vQtUVn2xf+wCYZV5Ht8MIGYBgNVHSME +gZAwgY2AFI+gG6PT7vQtUVn2xf+wCYZV5Ht8oWOkYTBfMQswCQYDVQQGEwJBVTET MBEGA1UECBMKU29tZS1TdGF0ZTEhMB8GA1UEChMYSW50ZXJuZXQgV2lkZ2l0cyBQ dHkgTHRkMRgwFgYDVQQDEw9sb2dpbi55YWhvby5jb22CEDkqQ08OB98fiqMF3jTg -wikwDAYDVR0TBAUwAwEB/zANBgkqhkiG9w0BAQUFAAOBgQAZyo0Q3leeM1+lxeCd -Wp0ZYHMSW11ANc6nuMWOmJC+nIQGlyGiP3IqeUvIfekwboV638bahVPwcl2HYWsS -/l01Bgyd25Zn6VTQBfMK01dILyxscjVwdHuojzYBN05sl+qkVoqQr5EroQQbgDc9 -6I88p6Kjajv3IusCwfK6wlqISw== +wikwDAYDVR0TBAUwAwEB/zANBgkqhkiG9w0BAQUFAAOBgQA3eZG/dOXrL7YBPCA8 +joDGfhra98T1iCpul4/L/L4dt/9+QVAu+agbZmHWLYzuAvuB1zj8go0BLIE7b4ap +HPLFYXV3iAWjIRhNEix4FWohlds1B+IwpvWdsl3Op1pZfHQ0yq8wFGawdQTAKUII +lLu1cd6E8B6pCfWwSr+9h6gnTg== -----END CERTIFICATE----- diff --git a/tests/auto/qsslcertificate/more-certificates/blacklisted5.pem b/tests/auto/qsslcertificate/more-certificates/blacklisted5.pem index c7ddbf2839..81211ee694 100644 --- a/tests/auto/qsslcertificate/more-certificates/blacklisted5.pem +++ b/tests/auto/qsslcertificate/more-certificates/blacklisted5.pem @@ -2,18 +2,18 @@ MIIDDzCCAnigAwIBAgIQPnXO1GtpMCEhiDCuhqgqcTANBgkqhkiG9w0BAQUFADBf MQswCQYDVQQGEwJBVTETMBEGA1UECBMKU29tZS1TdGF0ZTEhMB8GA1UEChMYSW50 ZXJuZXQgV2lkZ2l0cyBQdHkgTHRkMRgwFgYDVQQDEw9sb2dpbi55YWhvby5jb20w -HhcNMTEwMzI0MTMwOTQ4WhcNMTEwNDIzMTMwOTQ4WjBfMQswCQYDVQQGEwJBVTET +HhcNMTEwODMwMTAyMTQ4WhcNMjEwODI3MTAyMTQ4WjBfMQswCQYDVQQGEwJBVTET MBEGA1UECBMKU29tZS1TdGF0ZTEhMB8GA1UEChMYSW50ZXJuZXQgV2lkZ2l0cyBQ dHkgTHRkMRgwFgYDVQQDEw9sb2dpbi55YWhvby5jb20wgZ8wDQYJKoZIhvcNAQEB -BQADgY0AMIGJAoGBALkiHG9TgTw/00CMW8D23NBDAa3331AL5kTkAaXbAWg2R/1o -yKQfXq3hgHbyWGPccUT+tU6FmaBf3bIndLK7iGx81RGzGgXeoQ5mpgnJ50iCeW73 -G99VlVwutPia7d9qqui84YdcG9t+P2Fuxv+xRqAB6lKOaa4qTPIbH50PgwOvAgMB -AAGjgcswgcgwHQYDVR0OBBYEFBWJrs8bnZ5fikfaLbTxK0ssj69MMIGYBgNVHSME -gZAwgY2AFBWJrs8bnZ5fikfaLbTxK0ssj69MoWOkYTBfMQswCQYDVQQGEwJBVTET +BQADgY0AMIGJAoGBAL5IeUbbQ7HxCBLQaOASV2HyI1tRwPm/7JNsRfh5ipM1sCWE +xnPoqFznX6ZUKi8d61/EIycwUd+FvOp9zoRxDlngoRdhqMCTTG3JfxNf6ZXJPCYd +qPjOKAkMwyG8bbhGCsoCws9b2rpN9536qVXc2QR39F9/ZE5t73oKtEd1fyNnAgMB +AAGjgcswgcgwHQYDVR0OBBYEFNXCkfGdW3WYzBBqB2jWppl6sL99MIGYBgNVHSME +gZAwgY2AFNXCkfGdW3WYzBBqB2jWppl6sL99oWOkYTBfMQswCQYDVQQGEwJBVTET MBEGA1UECBMKU29tZS1TdGF0ZTEhMB8GA1UEChMYSW50ZXJuZXQgV2lkZ2l0cyBQ dHkgTHRkMRgwFgYDVQQDEw9sb2dpbi55YWhvby5jb22CED51ztRraTAhIYgwroao -KnEwDAYDVR0TBAUwAwEB/zANBgkqhkiG9w0BAQUFAAOBgQCIfqqs1a7RzdmV8U00 -v/xAsxscKvQvmu6BK+HwvY5iL2pSwXTYgRLJLoj5QGOd3mmgOFsyW3BPSCP1+fVE -M1ROhU2u8wHub+hGGds18Fx6F4yZjdh8pNUoOUR9A0Ym+VDJr2p50oUNTTy0RbH8 -9ns/gbemx84cjF9DD2G5stQhYg== +KnEwDAYDVR0TBAUwAwEB/zANBgkqhkiG9w0BAQUFAAOBgQCOeih7N7fmkqECWZD/ +bYsFLtbKOwD4YMPIV2wayvaLg2dFwqhBkGml+5ulOh5KTiUh0/nnGmGAU/3K9nt5 +TCMjwMGHm/C5pp7THQriiY8Qw0QVtnFiJGnjblhAbJVIvBJJ42/Qq7T4IzEwqShW +hO2g1M0MUGiOw4vyXJRGc4dg2w== -----END CERTIFICATE----- diff --git a/tests/auto/qsslcertificate/more-certificates/blacklisted6.pem b/tests/auto/qsslcertificate/more-certificates/blacklisted6.pem index bc2be2adcf..4264a678f1 100644 --- a/tests/auto/qsslcertificate/more-certificates/blacklisted6.pem +++ b/tests/auto/qsslcertificate/more-certificates/blacklisted6.pem @@ -2,18 +2,18 @@ MIIDETCCAnqgAwIBAgIRAOkCi5V45BXcGnEKK4gVREcwDQYJKoZIhvcNAQEFBQAw XzELMAkGA1UEBhMCQVUxEzARBgNVBAgTClNvbWUtU3RhdGUxITAfBgNVBAoTGElu dGVybmV0IFdpZGdpdHMgUHR5IEx0ZDEYMBYGA1UEAxMPbG9naW4uc2t5cGUuY29t -MB4XDTExMDMyNDEzMTAxNloXDTExMDQyMzEzMTAxNlowXzELMAkGA1UEBhMCQVUx +MB4XDTExMDgzMDEwMjIxOFoXDTIxMDgyNzEwMjIxOFowXzELMAkGA1UEBhMCQVUx EzARBgNVBAgTClNvbWUtU3RhdGUxITAfBgNVBAoTGEludGVybmV0IFdpZGdpdHMg UHR5IEx0ZDEYMBYGA1UEAxMPbG9naW4uc2t5cGUuY29tMIGfMA0GCSqGSIb3DQEB -AQUAA4GNADCBiQKBgQDFq06qqRl86pP7GRX3m7FMMSaSU6zlNGAo+WPoRfYAzB6x -5KpvlfxMCo3T/nWtInX3Bw9TBWCZSweQ2GEjggO0irjw5UX3MiToLxK+rwzWztm9 -H3LBxTWR0cOOa78kRFvNQ1onvNHbs8fJzXjG7b2IJDOIwG1HAT1LK80oPXZc1wID -AQABo4HMMIHJMB0GA1UdDgQWBBTiGNxw0ImW/wfW0mD3eA65PY5CAzCBmQYDVR0j -BIGRMIGOgBTiGNxw0ImW/wfW0mD3eA65PY5CA6FjpGEwXzELMAkGA1UEBhMCQVUx +AQUAA4GNADCBiQKBgQDAAkuUFRdz1bm95jFsyQRb4PBrly4pJK4f5pSZy99eY8FM +iZbr7brnkiheN4qeJfS1dv/B/B4kAVoGD2Y0KmpZ5ZZYmm3TxopoP0Yeg6juWNKa +iFlfKQIvk0GEmD8oGfEqW1+72p040jAuTn+OQx+7VpydqB/RJoY8qK3zEXbB7wID +AQABo4HMMIHJMB0GA1UdDgQWBBSE9drle8VwSlwYIX5mKaIEvQYX/zCBmQYDVR0j +BIGRMIGOgBSE9drle8VwSlwYIX5mKaIEvQYX/6FjpGEwXzELMAkGA1UEBhMCQVUx EzARBgNVBAgTClNvbWUtU3RhdGUxITAfBgNVBAoTGEludGVybmV0IFdpZGdpdHMg UHR5IEx0ZDEYMBYGA1UEAxMPbG9naW4uc2t5cGUuY29tghEA6QKLlXjkFdwacQor -iBVERzAMBgNVHRMEBTADAQH/MA0GCSqGSIb3DQEBBQUAA4GBAHdb1QY/oxuro/4x -GX9jbm930ysoeXkWZSKVtVxoxrPIferu8jVpb1SLRjGcMnmjJoNWNFpvnbZgoYei -f3wdSWun7ndyQBh61k8eM7UABDOUXUHOsHuHj7s1koMKtet4gykmMfd6VxBkwBvN -ZXOll4X+TKe8nrxbnGUByIwQaRM+ +iBVERzAMBgNVHRMEBTADAQH/MA0GCSqGSIb3DQEBBQUAA4GBACm4/Q6e001Fg9uu +ieqHOAxfBafkOsXtgKqTFFdpt9Hbmo9j/BfvrtvfFN5Ph4fV46useGjW79P1IeNK ++KqcaqOKy2q6j1em4j8C5Mx6S4ksZJC25jIPEM7cdxiDGcV505X5mynlu1+WkZAf +nQhnJpA8o3p462ON4S+GXTfOLfoN -----END CERTIFICATE----- diff --git a/tests/auto/qsslcertificate/more-certificates/blacklisted7.pem b/tests/auto/qsslcertificate/more-certificates/blacklisted7.pem index 19d4353fab..03ab7d46b0 100644 --- a/tests/auto/qsslcertificate/more-certificates/blacklisted7.pem +++ b/tests/auto/qsslcertificate/more-certificates/blacklisted7.pem @@ -2,18 +2,18 @@ MIIDGjCCAoOgAwIBAgIRAJI51TSPQNFpWnRUcOHyP0MwDQYJKoZIhvcNAQEFBQAw YjELMAkGA1UEBhMCQVUxEzARBgNVBAgTClNvbWUtU3RhdGUxITAfBgNVBAoTGElu dGVybmV0IFdpZGdpdHMgUHR5IEx0ZDEbMBkGA1UEAxMSYWRkb25zLm1vemlsbGEu -b3JnMB4XDTExMDMyNDEzMTA0NFoXDTExMDQyMzEzMTA0NFowYjELMAkGA1UEBhMC +b3JnMB4XDTExMDgzMDEwMjIzOVoXDTIxMDgyNzEwMjIzOVowYjELMAkGA1UEBhMC QVUxEzARBgNVBAgTClNvbWUtU3RhdGUxITAfBgNVBAoTGEludGVybmV0IFdpZGdp dHMgUHR5IEx0ZDEbMBkGA1UEAxMSYWRkb25zLm1vemlsbGEub3JnMIGfMA0GCSqG -SIb3DQEBAQUAA4GNADCBiQKBgQC1lsoAcZTwF8Pf0E9do5avLdobB/O7EhhrCMs2 -/EMO07aIlrLwl3UP/Fmu/cAkKuX8Mx+Eif9x+XT3ZqGKGYKiqPTJcNfeZvgwbn0j -wXDtEo4DuURrwtBU9okS+v4dF6F4RtHQKAGcsXoOjhR7ah71kve+PG2GG0sJ167V -klK1xwIDAQABo4HPMIHMMB0GA1UdDgQWBBRgGDJ4Qp0WFyLIzm4Nz5wgqDSSxjCB -nAYDVR0jBIGUMIGRgBRgGDJ4Qp0WFyLIzm4Nz5wgqDSSxqFmpGQwYjELMAkGA1UE +SIb3DQEBAQUAA4GNADCBiQKBgQC9Yo3DJvs+vewelK5qoK+0Xn4zeRIQ/wJCrQBg +5tNXja+NZsHb0/enlwAZ3dAwCfI0G12mTowgSuZyDX7oN2+G+k6Q5LPnGhj1E5s5 +OJ+ZYsAjTdU0SCAPquva55+jyhqo5w/B5Il7w84mppUrAZgqEGhYkhXeDOULe1Vm +4iLMQwIDAQABo4HPMIHMMB0GA1UdDgQWBBSb8lAIgOnUitVOuZIx3s+5MN1sBzCB +nAYDVR0jBIGUMIGRgBSb8lAIgOnUitVOuZIx3s+5MN1sB6FmpGQwYjELMAkGA1UE BhMCQVUxEzARBgNVBAgTClNvbWUtU3RhdGUxITAfBgNVBAoTGEludGVybmV0IFdp ZGdpdHMgUHR5IEx0ZDEbMBkGA1UEAxMSYWRkb25zLm1vemlsbGEub3JnghEAkjnV -NI9A0WladFRw4fI/QzAMBgNVHRMEBTADAQH/MA0GCSqGSIb3DQEBBQUAA4GBACeE -DHMQ+LWEuoa/6z2EgrgM1k9rvBbUtCR+rjTuyzVW4OLXdpiVwZPOAiKphpq7q8Sb -TQ3zwsCoPLLJk5VolwcPfcD8Y2/tYK3NCYl+HzGxxnzPDFVaZM5Jh8RI861Hc00D -hVoQaptPK/V/lr0KEevqjhusAdFZbwlWA923zASa +NI9A0WladFRw4fI/QzAMBgNVHRMEBTADAQH/MA0GCSqGSIb3DQEBBQUAA4GBAFpg +tcp6ynOZ/hwr2axTYK+4rtXmTUJdsg7NUHhXSwGANAuYuc7PYwqtmz3B2W90t3TA +D3pNMRBEXrBXufC0p9vu/hQgb+mdQ7DG6j1Gkkpq4Sq/Puv1bO96KpAufmevnWWB +48kzCgAdfk/N04k7kdPHCp5MjjgmY3kGdsg+jroj -----END CERTIFICATE----- diff --git a/tests/auto/qsslcertificate/more-certificates/blacklisted8.pem b/tests/auto/qsslcertificate/more-certificates/blacklisted8.pem index aedf3f7010..acef06ffb0 100644 --- a/tests/auto/qsslcertificate/more-certificates/blacklisted8.pem +++ b/tests/auto/qsslcertificate/more-certificates/blacklisted8.pem @@ -2,18 +2,18 @@ MIIDDjCCAnegAwIBAgIRALC3Ez7Qlvm1b66RyHS9OsAwDQYJKoZIhvcNAQEFBQAw XjELMAkGA1UEBhMCQVUxEzARBgNVBAgTClNvbWUtU3RhdGUxITAfBgNVBAoTGElu dGVybmV0IFdpZGdpdHMgUHR5IEx0ZDEXMBUGA1UEAxMObG9naW4ubGl2ZS5jb20w -HhcNMTEwMzI0MTMxMTA2WhcNMTEwNDIzMTMxMTA2WjBeMQswCQYDVQQGEwJBVTET +HhcNMTEwODMwMTAyMzA0WhcNMjEwODI3MTAyMzA0WjBeMQswCQYDVQQGEwJBVTET MBEGA1UECBMKU29tZS1TdGF0ZTEhMB8GA1UEChMYSW50ZXJuZXQgV2lkZ2l0cyBQ dHkgTHRkMRcwFQYDVQQDEw5sb2dpbi5saXZlLmNvbTCBnzANBgkqhkiG9w0BAQEF -AAOBjQAwgYkCgYEA3OVNj9ijzMewvDeZYzgCWoKtyjclyIHxrQfHZpcexaKbxUap -1MtF6L0ayjtRWpiBYuPteUSy/Ja4Oh6zZz8K6z5rVgXhmy3xPIYuOoWaTKEOhb0Z -oHTBtGh8aWWai1XWw37HIm2FP8cmfgdH4lZwVvpTZIUxYidsyqyjB9IrhiMCAwEA -AaOByzCByDAdBgNVHQ4EFgQU4CcQcIvEhJC0tqHlNFMkv6MlDN4wgZgGA1UdIwSB -kDCBjYAU4CcQcIvEhJC0tqHlNFMkv6MlDN6hYqRgMF4xCzAJBgNVBAYTAkFVMRMw +AAOBjQAwgYkCgYEA5JK77+1zFatj8xeItZaDW5XaU+ssc5jq2Ww4ANaxJi+wdRVU +qVLauEJPKEXC51fuYHa7U8yoSTgJZA7JL07cdSxgsVj8RR4Uf5k4Jf5Vdz5w8+TT +W33I3zurA2xB+wfup2VPmS8Alg07w6POrzlQYgtcUcELZhjcdypk96NOdPECAwEA +AaOByzCByDAdBgNVHQ4EFgQUTWM20msyZUcNEYOyNbgevBPIoF8wgZgGA1UdIwSB +kDCBjYAUTWM20msyZUcNEYOyNbgevBPIoF+hYqRgMF4xCzAJBgNVBAYTAkFVMRMw EQYDVQQIEwpTb21lLVN0YXRlMSEwHwYDVQQKExhJbnRlcm5ldCBXaWRnaXRzIFB0 eSBMdGQxFzAVBgNVBAMTDmxvZ2luLmxpdmUuY29tghEAsLcTPtCW+bVvrpHIdL06 -wDAMBgNVHRMEBTADAQH/MA0GCSqGSIb3DQEBBQUAA4GBAMNzIStXDNSNQ8ayxrcj -4RrUMsHWUG/6XPrgfYqCP5TfPGAa5qBfNb9LfUbiS4b0flJVN1RlHVwwRo0yf9v4 -LGg0dSuPQAOWlLeUR1GminO1jHZw7E4dYfR7QEmiiOgaQU+CbxLsf5vCaKInN9Gu -jv/5xytVCbMoLoZ4EBVb0tka +wDAMBgNVHRMEBTADAQH/MA0GCSqGSIb3DQEBBQUAA4GBACQqnu1KywflnNiqIU01 +95z/qjmZTvSWafM/HLOFUg8ls7g32l5gCCrsc8ypiCff+S3+9teYQOII7oW3hzw4 +BH10m0LTRxGig5U9XVkH4076SALkPoky1z+onMmLk7AE96kSJ+rq30VvcSSl9BaW +DwcQGIhCZANgZrNW9AJ+cweQ -----END CERTIFICATE----- diff --git a/tests/auto/qsslcertificate/more-certificates/blacklisted9.pem b/tests/auto/qsslcertificate/more-certificates/blacklisted9.pem index d179b29288..cc99b08e5f 100644 --- a/tests/auto/qsslcertificate/more-certificates/blacklisted9.pem +++ b/tests/auto/qsslcertificate/more-certificates/blacklisted9.pem @@ -2,18 +2,18 @@ MIIDDjCCAnegAwIBAgIRANjzX063hystqwaS4xU4L7AwDQYJKoZIhvcNAQEFBQAw XjELMAkGA1UEBhMCQVUxEzARBgNVBAgTClNvbWUtU3RhdGUxITAfBgNVBAoTGElu dGVybmV0IFdpZGdpdHMgUHR5IEx0ZDEXMBUGA1UEAxMOZ2xvYmFsIHRydXN0ZWUw -HhcNMTEwMzI0MTMxMTM3WhcNMTEwNDIzMTMxMTM3WjBeMQswCQYDVQQGEwJBVTET +HhcNMTEwODMwMTAyMzI1WhcNMjEwODI3MTAyMzI1WjBeMQswCQYDVQQGEwJBVTET MBEGA1UECBMKU29tZS1TdGF0ZTEhMB8GA1UEChMYSW50ZXJuZXQgV2lkZ2l0cyBQ dHkgTHRkMRcwFQYDVQQDEw5nbG9iYWwgdHJ1c3RlZTCBnzANBgkqhkiG9w0BAQEF -AAOBjQAwgYkCgYEArHCVym7AEZDBhDkrUSG3Q94a+caNcCk5fE6ltZHiZHv096xr -cixHYvSGvms780bkI+oot2xI/e9awwkV+7VjWNvr0HrajzBWeimwk+myjP+3ddMY -Kmr0eI6bmvmPHtOFJE5Ar8/62FwD0wlLogRIx56JtXcCpkiUQktJVPz2gtMCAwEA -AaOByzCByDAdBgNVHQ4EFgQUUJwC/qSGBmcB+DVrd43ovRLdLmQwgZgGA1UdIwSB -kDCBjYAUUJwC/qSGBmcB+DVrd43ovRLdLmShYqRgMF4xCzAJBgNVBAYTAkFVMRMw +AAOBjQAwgYkCgYEAw0CpZXrd6oI8/PHo8/bnNwB7UA7OKsRFuqKljr9F5lCJAVkT +zRDlXuTDeXGfQiYhJTF7GRunPRJ7O5SsflwoxktH/F91yFpgxY5DqRZ1ZHdZgW3b +W0uweBxJv9684ihXY4YR3Yznf0js7YAgVd8a3qhOUODiC/Beb8tmDBNL2c0CAwEA +AaOByzCByDAdBgNVHQ4EFgQU/rUvQ2rG7pg2muUiLm6V93ZgmGcwgZgGA1UdIwSB +kDCBjYAU/rUvQ2rG7pg2muUiLm6V93ZgmGehYqRgMF4xCzAJBgNVBAYTAkFVMRMw EQYDVQQIEwpTb21lLVN0YXRlMSEwHwYDVQQKExhJbnRlcm5ldCBXaWRnaXRzIFB0 eSBMdGQxFzAVBgNVBAMTDmdsb2JhbCB0cnVzdGVlghEA2PNfTreHKy2rBpLjFTgv -sDAMBgNVHRMEBTADAQH/MA0GCSqGSIb3DQEBBQUAA4GBACAYxI+r3+JNelL6SBB0 -Pda3LkbCm+schP64NBYDdGl2Kus2b2QZ83T7xENBFEhyNoXvc6pRI4/Oh6JDxmG1 -7WmqOVStS/4JeAu6ygiyI1ImRKq2/MvJx/kaKh6IiXanB5nW1U+fhDV6kMOEfpwV -i6FBibpHboPQoqzPPRe7qHSL +sDAMBgNVHRMEBTADAQH/MA0GCSqGSIb3DQEBBQUAA4GBALvmmUx47DcUAIsPkI0Y +DTvcXV6k2JHwdrdlPsrn9A5TLppfxPNrDMiweitr8cMkKEtkm6LRTt2yvDFcMIwy +/+F5+XO0k9sKde6xHfWvOvndIycj3Lt4tIRW8jUauJENyMa4M57qpqkgkJEmflkI +/pb9fQZbfg70o9wvbNK0RONo -----END CERTIFICATE----- -- cgit v1.2.3 From 46ff3a4b1f0ee9fc87bafe2679f322aab689889c Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Fri, 19 Aug 2011 11:58:18 +0200 Subject: Correctly position aliased lines with flat caps The code was mispositioning lines by half a pixel, as it added half a pixel offset and then rounded in addition. This submit fixes this and also removes certain artifacts when drawing rects at .5 pixel positions. Lance now doesn't show any significant differences to the 4.7 rendering anymore. Task-number: QTBUG-20199 Reviewed-by: Aavit (cherry picked from commit 49409f612c47f30434aa809e4d2c963f1a6bb88a) Change-Id: Iab3936e688eba16b82f5cdb4f36f54af807d78ea Reviewed-on: http://codereview.qt.nokia.com/3260 Reviewed-by: Lars Knoll Reviewed-by: Qt Sanity Bot --- src/gui/painting/qcosmeticstroker.cpp | 50 ++++++++++++++++++----------------- src/gui/painting/qcosmeticstroker_p.h | 10 ++++--- 2 files changed, 32 insertions(+), 28 deletions(-) diff --git a/src/gui/painting/qcosmeticstroker.cpp b/src/gui/painting/qcosmeticstroker.cpp index dbe957e68d..3528e6f215 100644 --- a/src/gui/painting/qcosmeticstroker.cpp +++ b/src/gui/painting/qcosmeticstroker.cpp @@ -425,13 +425,12 @@ void QCosmeticStroker::calculateLastPoint(qreal rx1, qreal ry1, qreal rx2, qreal swapped = true; qSwap(y1, y2); qSwap(x1, x2); - --x1; --x2; --y1; --y2; } int xinc = F16Dot16FixedDiv(x2 - x1, y2 - y1); int x = x1 << 10; - int y = (y1+32) >> 6; - int ys = (y2+32) >> 6; + int y = y1 >> 6; + int ys = y2 >> 6; if (y != ys) { x += ( ((((y << 6) + 32 - y1))) * xinc ) >> 6; @@ -457,13 +456,12 @@ void QCosmeticStroker::calculateLastPoint(qreal rx1, qreal ry1, qreal rx2, qreal swapped = true; qSwap(x1, x2); qSwap(y1, y2); - --x1; --x2; --y1; --y2; } int yinc = F16Dot16FixedDiv(y2 - y1, x2 - x1); int y = y1 << 10; - int x = (x1+32) >> 6; - int xs = (x2+32) >> 6; + int x = x1 >> 6; + int xs = x2 >> 6; if (x != xs) { y += ( ((((x << 6) + 32 - x1))) * yinc ) >> 6; @@ -716,10 +714,11 @@ static void drawLine(QCosmeticStroker *stroker, qreal rx1, qreal ry1, qreal rx2, QCosmeticStroker::Point last = stroker->lastPixel; -// qDebug() << "stroke" << x1/64. << y1/64. << x2/64. << y2/64. << capString(caps); +// qDebug() << "stroke" << x1/64. << y1/64. << x2/64. << y2/64.; if (dx < dy) { // vertical + QCosmeticStroker::Direction dir = QCosmeticStroker::TopToBottom; bool swapped = false; if (y1 > y2) { @@ -727,30 +726,31 @@ static void drawLine(QCosmeticStroker *stroker, qreal rx1, qreal ry1, qreal rx2, qSwap(y1, y2); qSwap(x1, x2); caps = swapCaps(caps); - --x1; --x2; --y1; --y2; + dir = QCosmeticStroker::BottomToTop; } int xinc = F16Dot16FixedDiv(x2 - x1, y2 - y1); int x = x1 << 10; + if ((stroker->lastDir ^ QCosmeticStroker::VerticalMask) == dir) + caps |= swapped ? QCosmeticStroker::CapEnd : QCosmeticStroker::CapBegin; + capAdjust(caps, y1, y2, x, xinc); - int y = (y1+32) >> 6; - int ys = (y2+32) >> 6; + int y = y1 >> 6; + int ys = y2 >> 6; if (y != ys) { x += ( ((((y << 6) + 32 - y1))) * xinc ) >> 6; // calculate first and last pixel and perform dropout control - QCosmeticStroker::Direction dir = QCosmeticStroker::TopToBottom; QCosmeticStroker::Point first; first.x = x >> 16; first.y = y; last.x = (x + (ys - y - 1)*xinc) >> 16; last.y = ys - 1; - if (swapped) { + if (swapped) qSwap(first, last); - dir = QCosmeticStroker::BottomToTop; - } + bool axisAligned = qAbs(xinc) < (1 << 14); if (stroker->lastPixel.x >= 0) { if (first.x == stroker->lastPixel.x && @@ -765,7 +765,7 @@ static void drawLine(QCosmeticStroker *stroker, qreal rx1, qreal ry1, qreal rx2, } else if (stroker->lastDir != dir && (((axisAligned && stroker->lastAxisAligned) && stroker->lastPixel.x != first.x && stroker->lastPixel.y != first.y) || - (qAbs(stroker->lastPixel.x - first.x) > 1 && + (qAbs(stroker->lastPixel.x - first.x) > 1 || qAbs(stroker->lastPixel.y - first.y) > 1))) { // have a missing pixel, insert it if (swapped) { @@ -793,37 +793,39 @@ static void drawLine(QCosmeticStroker *stroker, qreal rx1, qreal ry1, qreal rx2, if (!dx) return; + QCosmeticStroker::Direction dir = QCosmeticStroker::LeftToRight; + bool swapped = false; if (x1 > x2) { swapped = true; qSwap(x1, x2); qSwap(y1, y2); caps = swapCaps(caps); - --x1; --x2; --y1; --y2; + dir = QCosmeticStroker::RightToLeft; } int yinc = F16Dot16FixedDiv(y2 - y1, x2 - x1); int y = y1 << 10; - capAdjust(caps, x1, x2, y, yinc); + if ((stroker->lastDir ^ QCosmeticStroker::HorizontalMask) == dir) + caps |= swapped ? QCosmeticStroker::CapEnd : QCosmeticStroker::CapBegin; - int x = (x1+32) >> 6; - int xs = (x2+32) >> 6; + capAdjust(caps, x1, x2, y, yinc); + int x = x1 >> 6; + int xs = x2 >> 6; if (x != xs) { y += ( ((((x << 6) + 32 - x1))) * yinc ) >> 6; // calculate first and last pixel to perform dropout control - QCosmeticStroker::Direction dir = QCosmeticStroker::LeftToRight; QCosmeticStroker::Point first; first.x = x; first.y = y >> 16; last.x = xs - 1; last.y = (y + (xs - x - 1)*yinc) >> 16; - if (swapped) { + if (swapped) qSwap(first, last); - dir = QCosmeticStroker::RightToLeft; - } + bool axisAligned = qAbs(yinc) < (1 << 14); if (stroker->lastPixel.x >= 0) { if (first.x == stroker->lastPixel.x && first.y == stroker->lastPixel.y) { @@ -837,7 +839,7 @@ static void drawLine(QCosmeticStroker *stroker, qreal rx1, qreal ry1, qreal rx2, } else if (stroker->lastDir != dir && (((axisAligned && stroker->lastAxisAligned) && stroker->lastPixel.x != first.x && stroker->lastPixel.y != first.y) || - (qAbs(stroker->lastPixel.x - first.x) > 1 && + (qAbs(stroker->lastPixel.x - first.x) > 1 || qAbs(stroker->lastPixel.y - first.y) > 1))) { // have a missing pixel, insert it if (swapped) { diff --git a/src/gui/painting/qcosmeticstroker_p.h b/src/gui/painting/qcosmeticstroker_p.h index d7bd79ad15..53cdf2c0ac 100644 --- a/src/gui/painting/qcosmeticstroker_p.h +++ b/src/gui/painting/qcosmeticstroker_p.h @@ -78,10 +78,12 @@ public: // used to avoid drop outs or duplicated points enum Direction { - TopToBottom, - BottomToTop, - LeftToRight, - RightToLeft + TopToBottom = 0x1, + BottomToTop = 0x2, + LeftToRight = 0x4, + RightToLeft = 0x8, + VerticalMask = 0x3, + HorizontalMask = 0xc }; QCosmeticStroker(QRasterPaintEngineState *s, const QRect &dr) -- cgit v1.2.3 From 3526560d60ef82cd04e4fdf2e0ab751c0aca9731 Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Fri, 19 Aug 2011 12:17:06 +0200 Subject: Add QLocale::toUpper/Lower The toUpper/Lower() methods in QString should not be locale dependent, as this can lead to rather hard to find bugs in at least a turkish locale. Rather have explicit, locale dependend case conversions available in QLocale. Reviewed-by: Denis Dzyubenko (cherry picked from commit da0e1e101bb4c44c25b6523357fa81ad1b2d6539) Change-Id: I1cc3f341bef17ad573a736dc94c9c5d514ace54e Reviewed-on: http://codereview.qt.nokia.com/3259 Reviewed-by: Lars Knoll Reviewed-by: Qt Sanity Bot --- src/corelib/tools/qlocale.cpp | 38 ++++++++++++++++++++++++++++++++++++++ src/corelib/tools/qlocale.h | 3 +++ src/corelib/tools/qstring.cpp | 30 ++++++++---------------------- tests/auto/qstring/tst_qstring.cpp | 20 ++++++++++++-------- 4 files changed, 61 insertions(+), 30 deletions(-) diff --git a/src/corelib/tools/qlocale.cpp b/src/corelib/tools/qlocale.cpp index 4648ca155d..36c4ae75a5 100644 --- a/src/corelib/tools/qlocale.cpp +++ b/src/corelib/tools/qlocale.cpp @@ -88,6 +88,8 @@ Q_GLOBAL_STATIC(QLocalePrivate, globalLocalePrivate) #ifdef QT_USE_ICU extern bool qt_initIcu(const QString &localeName); +extern bool qt_u_strToUpper(const QString &str, QString *out, const QLocale &locale); +extern bool qt_u_strToLower(const QString &str, QString *out, const QLocale &locale); #endif /****************************************************************************** @@ -2170,6 +2172,42 @@ Qt::LayoutDirection QLocale::textDirection() const return Qt::LeftToRight; } +/*! + \since 4.8 + + Returns an uppercase copy of \a str. +*/ +QString QLocale::toUpper(const QString &str) const +{ +#ifdef QT_USE_ICU + { + QString result; + if (qt_u_strToUpper(str, &result, *this)) + return result; + // else fall through and use Qt's toUpper + } +#endif + return str.toUpper(); +} + +/*! + \since 4.8 + + Returns a lowercase copy of \a str. +*/ +QString QLocale::toLower(const QString &str) const +{ +#ifdef QT_USE_ICU + { + QString result; + if (qt_u_strToLower(str, &result, *this)) + return result; + // else fall through and use Qt's toUpper + } +#endif + return str.toLower(); +} + /*! \since 4.5 diff --git a/src/corelib/tools/qlocale.h b/src/corelib/tools/qlocale.h index 8a5d526e8d..55dd55b984 100644 --- a/src/corelib/tools/qlocale.h +++ b/src/corelib/tools/qlocale.h @@ -724,6 +724,9 @@ public: Qt::LayoutDirection textDirection() const; + QString toUpper(const QString &str) const; + QString toLower(const QString &str) const; + QString currencySymbol(CurrencySymbolFormat = CurrencySymbol) const; QString toCurrencyString(qlonglong, const QString &symbol = QString()) const; QString toCurrencyString(qulonglong, const QString &symbol = QString()) const; diff --git a/src/corelib/tools/qstring.cpp b/src/corelib/tools/qstring.cpp index 9ce5eead8c..78b1b59210 100644 --- a/src/corelib/tools/qstring.cpp +++ b/src/corelib/tools/qstring.cpp @@ -105,8 +105,6 @@ QTextCodec *QString::codecForCStrings; #ifdef QT_USE_ICU // qlocale_icu.cpp extern bool qt_ucol_strcoll(const QChar *source, int sourceLength, const QChar *target, int targetLength, int *result); -extern bool qt_u_strToUpper(const QString &str, QString *out, const QLocale &locale); -extern bool qt_u_strToLower(const QString &str, QString *out, const QLocale &locale); #endif @@ -4878,7 +4876,10 @@ QString QString::rightJustified(int width, QChar fill, bool truncate) const \snippet doc/src/snippets/qstring/main.cpp 75 - \sa toUpper() + The case conversion will always happen in the 'C' locale. For locale dependent + case folding use QLocale::toLower() + + \sa toUpper(), QLocale::toLower() */ QString QString::toLower() const @@ -4889,15 +4890,6 @@ QString QString::toLower() const if (!d->size) return *this; -#ifdef QT_USE_ICU - { - QString result; - if (qt_u_strToLower(*this, &result, QLocale())) - return result; - // else fall through and use Qt's toUpper - } -#endif - const ushort *e = d->data() + d->size; // this avoids one out of bounds check in the loop @@ -4978,7 +4970,10 @@ QString QString::toCaseFolded() const \snippet doc/src/snippets/qstring/main.cpp 81 - \sa toLower() + The case conversion will always happen in the 'C' locale. For locale dependent + case folding use QLocale::toUpper() + + \sa toLower(), QLocale::toLower() */ QString QString::toUpper() const @@ -4989,15 +4984,6 @@ QString QString::toUpper() const if (!d->size) return *this; -#ifdef QT_USE_ICU - { - QString result; - if (qt_u_strToUpper(*this, &result, QLocale())) - return result; - // else fall through and use Qt's toUpper - } -#endif - const ushort *e = d->data() + d->size; // this avoids one out of bounds check in the loop diff --git a/tests/auto/qstring/tst_qstring.cpp b/tests/auto/qstring/tst_qstring.cpp index f7a725c164..cf68bda31f 100644 --- a/tests/auto/qstring/tst_qstring.cpp +++ b/tests/auto/qstring/tst_qstring.cpp @@ -5086,24 +5086,28 @@ void tst_QString::toUpperLower_icu() QLocale::setDefault(QLocale(QLocale::Turkish, QLocale::Turkey)); + QCOMPARE(s.toUpper(), QString::fromLatin1("I")); + QCOMPARE(s.toLower(), QString::fromLatin1("i")); + // turkish locale has a capital I with a dot (U+0130, utf8 c4b0) + QLocale l; - QCOMPARE(s.toUpper(), QString::fromUtf8("\xc4\xb0")); - QCOMPARE(QString::fromUtf8("\xc4\xb0").toLower(), s); + QCOMPARE(l.toUpper(s), QString::fromUtf8("\xc4\xb0")); + QCOMPARE(l.toLower(QString::fromUtf8("\xc4\xb0")), s); // nothing should happen here - QCOMPARE(s.toLower(), s); - QCOMPARE(QString::fromLatin1("I").toUpper(), QString::fromLatin1("I")); + QCOMPARE(l.toLower(s), s); + QCOMPARE(l.toUpper(QString::fromLatin1("I")), QString::fromLatin1("I")); // U+0131, utf8 c4b1 is the lower-case i without a dot QString sup = QString::fromUtf8("\xc4\xb1"); - QCOMPARE(sup.toUpper(), QString::fromLatin1("I")); - QCOMPARE(QString::fromLatin1("I").toLower(), sup); + QCOMPARE(l.toUpper(sup), QString::fromLatin1("I")); + QCOMPARE(l.toLower(QString::fromLatin1("I")), sup); // nothing should happen here - QCOMPARE(sup.toLower(), sup); - QCOMPARE(QString::fromLatin1("i").toLower(), QString::fromLatin1("i")); + QCOMPARE(l.toLower(sup), sup); + QCOMPARE(l.toLower(QString::fromLatin1("i")), QString::fromLatin1("i")); // the cleanup function will restore the default locale } -- cgit v1.2.3 From f0d7e705ee66f82dfd32ce93670eba4f9186c4c0 Mon Sep 17 00:00:00 2001 From: Jason McDonald Date: Wed, 31 Aug 2011 14:14:06 +1000 Subject: Remove XFAIL from selftests for some platforms The selftest for assert messages calls QEXPECT_FAIL if the assert message doesn't exactly match the expected output. This is because Q_ASSERT uses __FILE__, which is compiler-dependant. The expected output for this test contains various hard-coded unix paths meaning that the test never passes on any platform. This commit removes those paths from the test data so that the test passes for compilers that don't put path information in __FILE__. This commit also makes the XFAIL message more accurate -- absolute paths in assert messages don't come from QTestLib, they come from Q_ASSERT's use of __FILE__. Change-Id: I9aae212379b43a29ae83715717cc978b4b619420 Reviewed-on: http://codereview.qt.nokia.com/3908 Reviewed-by: Qt Sanity Bot Reviewed-by: Rohan McGovern --- tests/auto/selftests/expected_assert.lightxml | 2 +- tests/auto/selftests/expected_assert.txt | 2 +- tests/auto/selftests/expected_assert.xml | 2 +- tests/auto/selftests/expected_assert.xunitxml | 4 ++-- tests/auto/selftests/tst_selftests.cpp | 15 +++++++++------ 5 files changed, 14 insertions(+), 11 deletions(-) diff --git a/tests/auto/selftests/expected_assert.lightxml b/tests/auto/selftests/expected_assert.lightxml index 9062ca69a8..c9a1978e9e 100644 --- a/tests/auto/selftests/expected_assert.lightxml +++ b/tests/auto/selftests/expected_assert.lightxml @@ -10,7 +10,7 @@ - + diff --git a/tests/auto/selftests/expected_assert.txt b/tests/auto/selftests/expected_assert.txt index 0203f2b74e..f57eb55604 100644 --- a/tests/auto/selftests/expected_assert.txt +++ b/tests/auto/selftests/expected_assert.txt @@ -2,7 +2,7 @@ Config: Using QTest library 4.3.0, Qt 4.3.0 PASS : tst_Assert::initTestCase() PASS : tst_Assert::testNumber1() -QFATAL : tst_Assert::testNumber2() ASSERT: "false" in file /home/fenglich/dev/qt-4.3/tests/auto/selftests/assert/tst_assert.cpp, line 29 +QFATAL : tst_Assert::testNumber2() ASSERT: "false" in file tst_assert.cpp, line 62 FAIL! : tst_Assert::testNumber2() Received a fatal error. Loc: [Unknown file(0)] Totals: 2 passed, 1 failed, 0 skipped diff --git a/tests/auto/selftests/expected_assert.xml b/tests/auto/selftests/expected_assert.xml index 3a7152c71a..60085aa2b9 100644 --- a/tests/auto/selftests/expected_assert.xml +++ b/tests/auto/selftests/expected_assert.xml @@ -12,7 +12,7 @@ - + diff --git a/tests/auto/selftests/expected_assert.xunitxml b/tests/auto/selftests/expected_assert.xunitxml index 2a7d5ebce8..87617003c5 100644 --- a/tests/auto/selftests/expected_assert.xunitxml +++ b/tests/auto/selftests/expected_assert.xunitxml @@ -7,10 +7,10 @@ - + - + diff --git a/tests/auto/selftests/tst_selftests.cpp b/tests/auto/selftests/tst_selftests.cpp index 320d993426..cb5cd077b6 100644 --- a/tests/auto/selftests/tst_selftests.cpp +++ b/tests/auto/selftests/tst_selftests.cpp @@ -416,13 +416,16 @@ void tst_Selftests::doRunSubTest(QString const& subdir, QString const& logger, Q const QString output(QString::fromLatin1(line)); const QString expected(QString::fromLatin1(exp.at(i)).replace("@INSERT_QT_VERSION_HERE@", QT_VERSION_STR)); + // Q_ASSERT uses __FILE__. Some compilers include the absolute path in + // __FILE__, while others do not. if (line.contains("ASSERT") && output != expected) { - QEXPECT_FAIL("assert", "QTestLib prints out the absolute path.", Continue); - QEXPECT_FAIL("assert xml", "QTestLib prints out the absolute path.", Continue); - QEXPECT_FAIL("assert xml flush", "QTestLib prints out the absolute path.", Continue); - QEXPECT_FAIL("assert lightxml", "QTestLib prints out the absolute path.", Continue); - QEXPECT_FAIL("assert lightxml flush", "QTestLib prints out the absolute path.", Continue); - QEXPECT_FAIL("assert xunitxml", "QTestLib prints out the absolute path.", Continue); + const char msg[] = "Q_ASSERT prints out the absolute path on this platform."; + QEXPECT_FAIL("assert", msg, Continue); + QEXPECT_FAIL("assert xml", msg, Continue); + QEXPECT_FAIL("assert xml flush", msg, Continue); + QEXPECT_FAIL("assert lightxml", msg, Continue); + QEXPECT_FAIL("assert lightxml flush", msg, Continue); + QEXPECT_FAIL("assert xunitxml", msg, Continue); } /* On some platforms we compile without RTTI, and as a result we never throw an exception. */ -- cgit v1.2.3 From 1a07ca938358784ce3250e03657fb4ea7fbbc84b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aur=C3=A9lien=20G=C3=A2teau?= Date: Wed, 10 Nov 2010 22:58:18 +0100 Subject: Fix warning about initialization order Merge-request: 1254 Reviewed-by: Gabriel de Dietrich (cherry picked from commit b4ddcbbf1ce067a823815c07a357a065be731d48) Change-Id: I809de3c201f47cd8936845447ad60b00cf4c0db7 Reviewed-on: http://codereview.qt.nokia.com/3930 Reviewed-by: Qt Sanity Bot Reviewed-by: Gabriel de Dietrich --- src/gui/widgets/qmenu_p.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/gui/widgets/qmenu_p.h b/src/gui/widgets/qmenu_p.h index 0e6379990f..82bd932be7 100644 --- a/src/gui/widgets/qmenu_p.h +++ b/src/gui/widgets/qmenu_p.h @@ -154,6 +154,9 @@ public: #endif scroll(0), eventLoop(0), tearoff(0), tornoff(0), tearoffHighlighted(0), hasCheckableItems(0), sloppyAction(0), doChildEffects(false) +#ifdef QT3_SUPPORT + ,emitHighlighted(false) +#endif #ifdef Q_WS_MAC ,mac_menu(0) #endif @@ -162,9 +165,6 @@ public: #endif #ifdef Q_WS_S60 ,symbian_menu(0) -#endif -#ifdef QT3_SUPPORT - ,emitHighlighted(false) #endif { } ~QMenuPrivate() -- cgit v1.2.3 From b7832ce2f84d3ea2010c04ab69db8f3350a62bd8 Mon Sep 17 00:00:00 2001 From: Aurelien Gateau Date: Thu, 7 Oct 2010 15:23:42 +0200 Subject: Hide QMenuAction This will help abstracting the platform specific parts of QMenuBarPrivate in a common interface. Merge-request: 1254 Reviewed-by: Gabriel de Dietrich (cherry picked from commit 68d633cc840c5526a0ad77985404f53ada6ba91a) Change-Id: I733b8dfb71ae0dc78536cfe48b466394206d1de3 Reviewed-on: http://codereview.qt.nokia.com/3931 Reviewed-by: Qt Sanity Bot Reviewed-by: Gabriel de Dietrich --- src/gui/widgets/qmenu_mac.mm | 4 ++-- src/gui/widgets/qmenu_symbian.cpp | 4 ++-- src/gui/widgets/qmenu_wince.cpp | 4 ++-- src/gui/widgets/qmenubar.cpp | 2 +- src/gui/widgets/qmenubar_p.h | 6 +++--- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/gui/widgets/qmenu_mac.mm b/src/gui/widgets/qmenu_mac.mm index 9db068c77f..56658b3718 100644 --- a/src/gui/widgets/qmenu_mac.mm +++ b/src/gui/widgets/qmenu_mac.mm @@ -1639,7 +1639,7 @@ QMenuBarPrivate::QMacMenuBarPrivate::~QMacMenuBarPrivate() } void -QMenuBarPrivate::QMacMenuBarPrivate::addAction(QAction *a, QMacMenuAction *before) +QMenuBarPrivate::QMacMenuBarPrivate::addAction(QAction *a, QAction *before) { if (a->isSeparator() || !menu) return; @@ -1649,7 +1649,7 @@ QMenuBarPrivate::QMacMenuBarPrivate::addAction(QAction *a, QMacMenuAction *befor #ifndef QT_MAC_USE_COCOA action->command = qt_mac_menu_static_cmd_id++; #endif - addAction(action, before); + addAction(action, findAction(before)); } void diff --git a/src/gui/widgets/qmenu_symbian.cpp b/src/gui/widgets/qmenu_symbian.cpp index 56eca9a425..4250601f98 100644 --- a/src/gui/widgets/qmenu_symbian.cpp +++ b/src/gui/widgets/qmenu_symbian.cpp @@ -398,12 +398,12 @@ void QMenuPrivate::QSymbianMenuPrivate::rebuild(bool) { } -void QMenuBarPrivate::QSymbianMenuBarPrivate::addAction(QAction *a, QSymbianMenuAction *before) +void QMenuBarPrivate::QSymbianMenuBarPrivate::addAction(QAction *a, QAction *before) { QSymbianMenuAction *action = new QSymbianMenuAction; action->action = a; action->command = qt_symbian_menu_static_cmd_id++; - addAction(action, before); + addAction(action, findAction(before)); } void QMenuBarPrivate::QSymbianMenuBarPrivate::addAction(QSymbianMenuAction *action, QSymbianMenuAction *before) diff --git a/src/gui/widgets/qmenu_wince.cpp b/src/gui/widgets/qmenu_wince.cpp index 1157fff8a2..b0c6c1bd12 100644 --- a/src/gui/widgets/qmenu_wince.cpp +++ b/src/gui/widgets/qmenu_wince.cpp @@ -504,12 +504,12 @@ void QMenuPrivate::QWceMenuPrivate::removeAction(QWceMenuAction *action) rebuild(); } -void QMenuBarPrivate::QWceMenuBarPrivate::addAction(QAction *a, QWceMenuAction *before) +void QMenuBarPrivate::QWceMenuBarPrivate::addAction(QAction *a, QAction *before) { QWceMenuAction *action = new QWceMenuAction; action->action = a; action->command = qt_wce_menu_static_cmd_id++; - addAction(action, before); + addAction(action, findAction(before)); } void QMenuBarPrivate::QWceMenuBarPrivate::addAction(QWceMenuAction *action, QWceMenuAction *before) diff --git a/src/gui/widgets/qmenubar.cpp b/src/gui/widgets/qmenubar.cpp index 56a1f04cc6..0c311723b3 100644 --- a/src/gui/widgets/qmenubar.cpp +++ b/src/gui/widgets/qmenubar.cpp @@ -1287,7 +1287,7 @@ void QMenuBar::actionEvent(QActionEvent *e) if (!nativeMenuBar) return; if(e->type() == QEvent::ActionAdded) - nativeMenuBar->addAction(e->action(), nativeMenuBar->findAction(e->before())); + nativeMenuBar->addAction(e->action(), e->before()); else if(e->type() == QEvent::ActionRemoved) nativeMenuBar->removeAction(e->action()); else if(e->type() == QEvent::ActionChanged) diff --git a/src/gui/widgets/qmenubar_p.h b/src/gui/widgets/qmenubar_p.h index 1ac694eead..341b1f7ca2 100644 --- a/src/gui/widgets/qmenubar_p.h +++ b/src/gui/widgets/qmenubar_p.h @@ -181,7 +181,7 @@ public: QMacMenuBarPrivate(); ~QMacMenuBarPrivate(); - void addAction(QAction *, QMacMenuAction* =0); + void addAction(QAction *, QAction* =0); void addAction(QMacMenuAction *, QMacMenuAction* =0); void syncAction(QMacMenuAction *); inline void syncAction(QAction *a) { syncAction(findAction(a)); } @@ -220,7 +220,7 @@ public: QWceMenuBarPrivate(QMenuBarPrivate *menubar); ~QWceMenuBarPrivate(); - void addAction(QAction *, QWceMenuAction* =0); + void addAction(QAction *, QAction* =0); void addAction(QWceMenuAction *, QWceMenuAction* =0); void syncAction(QWceMenuAction *); inline void syncAction(QAction *a) { syncAction(findAction(a)); } @@ -250,7 +250,7 @@ public: QMenuBarPrivate *d; QSymbianMenuBarPrivate(QMenuBarPrivate *menubar); ~QSymbianMenuBarPrivate(); - void addAction(QAction *, QSymbianMenuAction* =0); + void addAction(QAction *, QAction* =0); void addAction(QSymbianMenuAction *, QSymbianMenuAction* =0); void syncAction(QSymbianMenuAction *); inline void syncAction(QAction *a) { syncAction(findAction(a)); } -- cgit v1.2.3 From 6c97b066a958d840c70d7b0b5417a015b710c4d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aur=C3=A9lien=20G=C3=A2teau?= Date: Wed, 10 Nov 2010 23:37:56 +0100 Subject: Introduce QAbstractPlatformMenuBar Merge-request: 1254 Reviewed-by: Gabriel de Dietrich (cherry picked from commit 9aeadca09ab4e27ebf299873f90490d585b4fb7f) Change-Id: Ib0f035ac15ad0cc6be52807e8101f5dcfb5b041b Reviewed-on: http://codereview.qt.nokia.com/3932 Reviewed-by: Gabriel de Dietrich --- src/gui/widgets/qabstractplatformmenubar_p.h | 95 +++++++++++++++++++ src/gui/widgets/qmenubar.cpp | 134 +++++++++++++++++++++++++-- src/gui/widgets/qmenubar_p.h | 33 ++++++- src/gui/widgets/qmenubar_x11.cpp | 114 +++++++++++++++++++++++ src/gui/widgets/qmenubar_x11_p.h | 84 +++++++++++++++++ src/gui/widgets/widgets.pri | 8 ++ 6 files changed, 457 insertions(+), 11 deletions(-) create mode 100644 src/gui/widgets/qabstractplatformmenubar_p.h create mode 100644 src/gui/widgets/qmenubar_x11.cpp create mode 100644 src/gui/widgets/qmenubar_x11_p.h diff --git a/src/gui/widgets/qabstractplatformmenubar_p.h b/src/gui/widgets/qabstractplatformmenubar_p.h new file mode 100644 index 0000000000..86e212be9d --- /dev/null +++ b/src/gui/widgets/qabstractplatformmenubar_p.h @@ -0,0 +1,95 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtGui module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#ifndef QABSTRACTPLATFORMMENUBAR_P_H +#define QABSTRACTPLATFORMMENUBAR_P_H + +#include + +#ifndef QT_NO_MENUBAR + +QT_BEGIN_NAMESPACE + +class QAction; +class QActionEvent; +class QEvent; +class QMenuBar; +class QObject; +class QWidget; + +/*! + The platform-specific implementation of a menubar +*/ +class QAbstractPlatformMenuBar +{ +public: + virtual ~QAbstractPlatformMenuBar() {} + + virtual void init(QMenuBar *) = 0; + + virtual void setVisible(bool visible) = 0; + + virtual void actionEvent(QActionEvent *) = 0; + + virtual void handleReparent(QWidget *oldParent, QWidget *newParent, QWidget *oldWindow, QWidget *newWindow) = 0; + + virtual bool allowCornerWidgets() const = 0; + + virtual void popupAction(QAction *) = 0; + + virtual void setNativeMenuBar(bool) = 0; + + virtual bool isNativeMenuBar() const = 0; + + /*! + Return true if the native menubar is capable of listening to the + shortcut keys. If false is returned, QMenuBar will trigger actions on + shortcut itself. + */ + virtual bool shortcutsHandledByNativeMenuBar() const = 0; + + virtual bool menuBarEventFilter(QObject *, QEvent *event) = 0; +}; + +QT_END_NAMESPACE + +#endif // QT_NO_MENUBAR + +#endif // QABSTRACTPLATFORMMENUBAR_P_H diff --git a/src/gui/widgets/qmenubar.cpp b/src/gui/widgets/qmenubar.cpp index 0c311723b3..ff09b6e3e7 100644 --- a/src/gui/widgets/qmenubar.cpp +++ b/src/gui/widgets/qmenubar.cpp @@ -66,6 +66,9 @@ #include "qmenu_p.h" #include "qmenubar_p.h" #include "qdebug.h" +#ifdef Q_WS_X11 +#include "qmenubar_x11_p.h" +#endif #ifdef Q_WS_WINCE extern bool qt_wince_is_mobile(); //defined in qguifunctions_wce.cpp @@ -173,7 +176,11 @@ void QMenuBarPrivate::updateGeometries() return; int q_width = q->width()-(q->style()->pixelMetric(QStyle::PM_MenuBarPanelWidth, 0, q)*2); int q_start = -1; - if(leftWidget || rightWidget) { + if( +#ifdef Q_WS_X11 + platformMenuBar->allowCornerWidgets() && +#endif + (leftWidget || rightWidget)) { int vmargin = q->style()->pixelMetric(QStyle::PM_MenuBarVMargin, 0, q) + q->style()->pixelMetric(QStyle::PM_MenuBarPanelWidth, 0, q); int hmargin = q->style()->pixelMetric(QStyle::PM_MenuBarHMargin, 0, q) @@ -204,13 +211,23 @@ void QMenuBarPrivate::updateGeometries() calcActionRects(q_width, q_start); currentAction = 0; #ifndef QT_NO_SHORTCUT - if(itemsDirty) { + if( +#ifdef Q_WS_X11 + !platformMenuBar->shortcutsHandledByNativeMenuBar() && +#endif + itemsDirty) { for(int j = 0; j < shortcutIndexMap.size(); ++j) q->releaseShortcut(shortcutIndexMap.value(j)); shortcutIndexMap.resize(0); // faster than clear for(int i = 0; i < actions.count(); i++) shortcutIndexMap.append(q->grabShortcut(QKeySequence::mnemonic(actions.at(i)->text()))); } +#endif +#ifdef Q_WS_X11 + if(q->isNativeMenuBar()) {//nothing to see here folks, move along.. + itemsDirty = false; + return; + } #endif itemsDirty = false; @@ -743,6 +760,11 @@ void QMenuBarPrivate::init() QApplication::setAttribute(Qt::AA_DontUseNativeMenuBar, true); } #endif +#ifdef Q_WS_X11 + platformMenuBar = new QX11MenuBar; + platformMenuBar->init(q); +#endif + q->setBackgroundRole(QPalette::Button); oldWindow = oldParent = 0; #ifdef QT3_SUPPORT @@ -750,6 +772,10 @@ void QMenuBarPrivate::init() #endif #ifdef QT_SOFTKEYS_ENABLED menuBarAction = 0; +#endif +#ifdef Q_WS_X11 + cornerWidgetToolBar = 0; + cornerWidgetContainer = 0; #endif handleReparent(); q->setMouseTracking(q->style()->styleHint(QStyle::SH_MenuBar_MouseTracking, 0, q)); @@ -821,6 +847,10 @@ QMenuBar::~QMenuBar() Q_D(QMenuBar); d->symbianDestroyMenuBar(); #endif +#ifdef Q_WS_X11 + Q_D(QMenuBar); + delete d->cornerWidgetToolBar; +#endif } /*! @@ -1072,6 +1102,10 @@ void QMenuBar::paintEvent(QPaintEvent *e) */ void QMenuBar::setVisible(bool visible) { +#ifdef Q_WS_X11 + Q_D(QMenuBar); + d->platformMenuBar->setVisible(visible); +#else #if defined(Q_WS_MAC) || defined(Q_OS_WINCE) || defined(Q_WS_S60) if (isNativeMenuBar()) { if (!visible) @@ -1080,6 +1114,7 @@ void QMenuBar::setVisible(bool visible) } #endif QWidget::setVisible(visible); +#endif // Q_WS_X11 } /*! @@ -1275,6 +1310,9 @@ void QMenuBar::actionEvent(QActionEvent *e) { Q_D(QMenuBar); d->itemsDirty = true; +#ifdef Q_WS_X11 + d->platformMenuBar->actionEvent(e); +#endif #if defined (Q_WS_MAC) || defined(Q_OS_WINCE) || defined(Q_WS_S60) if (isNativeMenuBar()) { #ifdef Q_WS_MAC @@ -1369,6 +1407,10 @@ void QMenuBarPrivate::handleReparent() newWindow->installEventFilter(q); } +#ifdef Q_WS_X11 + platformMenuBar->handleReparent(oldParent, newParent, oldWindow, newWindow); +#endif + oldParent = newParent; oldWindow = newWindow; @@ -1566,6 +1608,11 @@ bool QMenuBar::event(QEvent *e) bool QMenuBar::eventFilter(QObject *object, QEvent *event) { Q_D(QMenuBar); +#ifdef Q_WS_X11 + if (d->platformMenuBar->menuBarEventFilter(object, event)) { + return true; + } +#endif if (object == parent() && object) { #ifdef QT3_SUPPORT if (d->doAutoResize && event->type() == QEvent::Resize) { @@ -1659,7 +1706,7 @@ QRect QMenuBar::actionGeometry(QAction *act) const QSize QMenuBar::minimumSizeHint() const { Q_D(const QMenuBar); -#if defined(Q_WS_MAC) || defined(Q_WS_WINCE) || defined(Q_WS_S60) +#if defined(Q_WS_MAC) || defined(Q_WS_WINCE) || defined(Q_WS_S60) || defined(Q_WS_X11) const bool as_gui_menubar = !isNativeMenuBar(); #else const bool as_gui_menubar = true; @@ -1682,6 +1729,9 @@ QSize QMenuBar::minimumSizeHint() const ret += QSize(2*fw + hmargin, 2*fw + vmargin); } int margin = 2*vmargin + 2*fw + spaceBelowMenuBar; +#ifdef Q_WS_X11 + if (d->platformMenuBar->allowCornerWidgets()) { +#endif if(d->leftWidget) { QSize sz = d->leftWidget->minimumSizeHint(); ret.setWidth(ret.width() + sz.width()); @@ -1694,6 +1744,9 @@ QSize QMenuBar::minimumSizeHint() const if(sz.height() + margin > ret.height()) ret.setHeight(sz.height() + margin); } +#ifdef Q_WS_X11 + } +#endif if(as_gui_menubar) { QStyleOptionMenuItem opt; opt.rect = rect(); @@ -1715,7 +1768,7 @@ QSize QMenuBar::minimumSizeHint() const QSize QMenuBar::sizeHint() const { Q_D(const QMenuBar); -#if defined(Q_WS_MAC) || defined(Q_WS_WINCE) || defined(Q_WS_S60) +#if defined(Q_WS_MAC) || defined(Q_WS_WINCE) || defined(Q_WS_S60) || defined(Q_WS_X11) const bool as_gui_menubar = !isNativeMenuBar(); #else const bool as_gui_menubar = true; @@ -1741,6 +1794,9 @@ QSize QMenuBar::sizeHint() const ret += QSize(fw + hmargin, fw + vmargin); } int margin = 2*vmargin + 2*fw + spaceBelowMenuBar; +#ifdef Q_WS_X11 + if(d->platformMenuBar->allowCornerWidgets()) { +#endif if(d->leftWidget) { QSize sz = d->leftWidget->sizeHint(); ret.setWidth(ret.width() + sz.width()); @@ -1753,6 +1809,9 @@ QSize QMenuBar::sizeHint() const if(sz.height() + margin > ret.height()) ret.setHeight(sz.height() + margin); } +#ifdef Q_WS_X11 + } +#endif if(as_gui_menubar) { QStyleOptionMenuItem opt; opt.rect = rect(); @@ -1774,7 +1833,7 @@ QSize QMenuBar::sizeHint() const int QMenuBar::heightForWidth(int) const { Q_D(const QMenuBar); -#if defined(Q_WS_MAC) || defined(Q_WS_WINCE) || defined(Q_WS_S60) +#if defined(Q_WS_MAC) || defined(Q_WS_WINCE) || defined(Q_WS_S60) || defined(Q_WS_X11) const bool as_gui_menubar = !isNativeMenuBar(); #else const bool as_gui_menubar = true; @@ -1794,10 +1853,16 @@ int QMenuBar::heightForWidth(int) const height += 2*vmargin; } int margin = 2*vmargin + 2*fw + spaceBelowMenuBar; +#ifdef Q_WS_X11 + if(d->platformMenuBar->allowCornerWidgets()) { +#endif if(d->leftWidget) height = qMax(d->leftWidget->sizeHint().height() + margin, height); if(d->rightWidget) height = qMax(d->rightWidget->sizeHint().height() + margin, height); +#ifdef Q_WS_X11 + } +#endif if(as_gui_menubar) { QStyleOptionMenuItem opt; opt.init(this); @@ -1817,7 +1882,15 @@ void QMenuBarPrivate::_q_internalShortcutActivated(int id) { Q_Q(QMenuBar); QAction *act = actions.at(id); - setCurrentAction(act, true, true); +#ifdef Q_WS_X11 + if (q->isNativeMenuBar()) { + platformMenuBar->popupAction(act); + } else { +#endif + setCurrentAction(act, true, true); +#ifdef Q_WS_X11 + } +#endif if (act && !act->menu()) { activateAction(act, QAction::Trigger); //100 is the same as the default value in QPushButton::animateClick @@ -1838,6 +1911,39 @@ void QMenuBarPrivate::_q_updateLayout() } } +#ifdef Q_WS_X11 +void QMenuBarPrivate::updateCornerWidgetToolBar() +{ + Q_Q(QMenuBar); + if (!cornerWidgetToolBar) { + QMainWindow *window = qobject_cast(q->window()); + if (!window) { + qWarning() << "Menubar parent is not a QMainWindow, not showing corner widgets"; + return; + } + cornerWidgetToolBar = window->addToolBar(QApplication::translate("QMenuBar", "Corner Toolbar")); + cornerWidgetToolBar->setObjectName(QLatin1String("CornerToolBar")); + cornerWidgetContainer = new QWidget; + cornerWidgetToolBar->addWidget(cornerWidgetContainer); + new QHBoxLayout(cornerWidgetContainer); + } else { + QLayout *layout = cornerWidgetContainer->layout(); + while (layout->count() > 0) { + layout->takeAt(0); + } + } + if (leftWidget) { + leftWidget->setParent(cornerWidgetContainer); + cornerWidgetContainer->layout()->addWidget(leftWidget); + } + if (rightWidget) { + rightWidget->setParent(cornerWidgetContainer); + cornerWidgetContainer->layout()->addWidget(rightWidget); + } +} +#endif + + /*! \fn void QMenuBar::setCornerWidget(QWidget *widget, Qt::Corner corner) @@ -1870,10 +1976,18 @@ void QMenuBar::setCornerWidget(QWidget *w, Qt::Corner corner) return; } +#ifdef Q_WS_X11 + if(!d->platformMenuBar->allowCornerWidgets()) { + d->updateCornerWidgetToolBar(); + } else { +#endif if (w) { w->setParent(this); w->installEventFilter(this); } +#ifdef Q_WS_X11 + } +#endif d->_q_updateLayout(); } @@ -1923,6 +2037,9 @@ QWidget *QMenuBar::cornerWidget(Qt::Corner corner) const void QMenuBar::setNativeMenuBar(bool nativeMenuBar) { Q_D(QMenuBar); +#ifdef Q_WS_X11 + d->platformMenuBar->setNativeMenuBar(nativeMenuBar); +#else if (d->nativeMenuBar == -1 || (nativeMenuBar != bool(d->nativeMenuBar))) { d->nativeMenuBar = nativeMenuBar; #ifdef Q_WS_MAC @@ -1947,15 +2064,20 @@ void QMenuBar::setNativeMenuBar(bool nativeMenuBar) setVisible(true); #endif } +#endif // Q_WS_X11 } bool QMenuBar::isNativeMenuBar() const { Q_D(const QMenuBar); +#ifdef Q_WS_X11 + return d->platformMenuBar->isNativeMenuBar(); +#else if (d->nativeMenuBar == -1) { return !QApplication::instance()->testAttribute(Qt::AA_DontUseNativeMenuBar); } return d->nativeMenuBar; +#endif } /*! diff --git a/src/gui/widgets/qmenubar_p.h b/src/gui/widgets/qmenubar_p.h index 341b1f7ca2..9a1f75884a 100644 --- a/src/gui/widgets/qmenubar_p.h +++ b/src/gui/widgets/qmenubar_p.h @@ -47,7 +47,7 @@ // ------------- // // This file is not part of the Qt API. It exists purely as an -// implementation detail. This header file may change from version to +// platformMenuBarementation detail. This header file may change from version to // version without notice, or even be removed. // // We mean it. @@ -61,6 +61,10 @@ #include "qguifunctions_wince.h" #endif +#ifdef Q_WS_X11 +#include "qabstractplatformmenubar_p.h" +#endif + #ifndef QT_NO_MENUBAR #ifdef Q_WS_S60 class CCoeControl; @@ -71,21 +75,27 @@ class CEikMenuBar; QT_BEGIN_NAMESPACE #ifndef QT_NO_MENUBAR +class QToolBar; class QMenuBarExtension; class QMenuBarPrivate : public QWidgetPrivate { Q_DECLARE_PUBLIC(QMenuBar) public: QMenuBarPrivate() : itemsDirty(0), currentAction(0), mouseDown(0), - closePopupMode(0), defaultPopDown(1), popupState(0), keyboardState(0), altPressed(0), - nativeMenuBar(-1), doChildEffects(false) + closePopupMode(0), defaultPopDown(1), popupState(0), keyboardState(0), altPressed(0) +#ifndef Q_WS_X11 + , nativeMenuBar(-1) +#endif + , doChildEffects(false) #ifdef QT3_SUPPORT , doAutoResize(false) #endif #ifdef Q_WS_MAC , mac_menubar(0) #endif - +#ifdef Q_WS_X11 + , platformMenuBar(0) +#endif #ifdef Q_WS_WINCE , wce_menubar(0), wceClassicMenu(false) #endif @@ -96,6 +106,9 @@ public: { } ~QMenuBarPrivate() { +#ifdef Q_WS_X11 + delete platformMenuBar; +#endif #ifdef Q_WS_MAC delete mac_menubar; #endif @@ -136,8 +149,9 @@ public: uint keyboardState : 1, altPressed : 1; QPointer keyboardFocusWidget; - +#ifndef Q_WS_X11 int nativeMenuBar : 3; // Only has values -1, 0, and 1 +#endif //firing of events void activateAction(QAction *, QAction::ActionEvent); @@ -173,6 +187,9 @@ public: #ifdef QT3_SUPPORT bool doAutoResize; #endif +#ifdef Q_WS_X11 + QAbstractPlatformMenuBar *platformMenuBar; +#endif #ifdef Q_WS_MAC //mac menubar binding struct QMacMenuBarPrivate { @@ -273,6 +290,12 @@ public: #ifdef QT_SOFTKEYS_ENABLED QAction *menuBarAction; #endif + +#ifdef Q_WS_X11 + void updateCornerWidgetToolBar(); + QToolBar *cornerWidgetToolBar; + QWidget *cornerWidgetContainer; +#endif }; #endif diff --git a/src/gui/widgets/qmenubar_x11.cpp b/src/gui/widgets/qmenubar_x11.cpp new file mode 100644 index 0000000000..ca227a6c4c --- /dev/null +++ b/src/gui/widgets/qmenubar_x11.cpp @@ -0,0 +1,114 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtGui module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include "qmenubar_x11_p.h" + +#ifndef QT_NO_MENUBAR + +#include "qapplication.h" +#include "qdebug.h" +#include "qevent.h" +#include "qmenu.h" +#include "qmenubar.h" + +QT_BEGIN_NAMESPACE + +QX11MenuBar::~QX11MenuBar() +{ +} + +void QX11MenuBar::init(QMenuBar *_menuBar) +{ + nativeMenuBar = -1; + menuBar = _menuBar; +} + +void QX11MenuBar::setVisible(bool visible) +{ + menuBar->QWidget::setVisible(visible); +} + +void QX11MenuBar::actionEvent(QActionEvent *e) +{ + Q_UNUSED(e); +} + +void QX11MenuBar::handleReparent(QWidget *oldParent, QWidget *newParent, QWidget *oldWindow, QWidget *newWindow) +{ + Q_UNUSED(oldParent) + Q_UNUSED(newParent) + Q_UNUSED(oldWindow) + Q_UNUSED(newWindow) +} + +bool QX11MenuBar::allowCornerWidgets() const +{ + return true; +} + +void QX11MenuBar::popupAction(QAction *) +{ +} + +void QX11MenuBar::setNativeMenuBar(bool value) +{ + if (nativeMenuBar == -1 || (value != bool(nativeMenuBar))) { + nativeMenuBar = value; + } +} + +bool QX11MenuBar::isNativeMenuBar() const +{ + return false; +} + +bool QX11MenuBar::shortcutsHandledByNativeMenuBar() const +{ + return false; +} + +bool QX11MenuBar::menuBarEventFilter(QObject *, QEvent *) +{ + return false; +} + +QT_END_NAMESPACE + +#endif // QT_NO_MENUBAR diff --git a/src/gui/widgets/qmenubar_x11_p.h b/src/gui/widgets/qmenubar_x11_p.h new file mode 100644 index 0000000000..dbe0223255 --- /dev/null +++ b/src/gui/widgets/qmenubar_x11_p.h @@ -0,0 +1,84 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtGui module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#ifndef QX11MENUBAR_P_H +#define QX11MENUBAR_P_H + +#ifndef QT_NO_MENUBAR + +#include "qabstractplatformmenubar_p.h" + +QT_BEGIN_NAMESPACE + +class QMenuBar; + +class QX11MenuBar : public QAbstractPlatformMenuBar +{ +public: + ~QX11MenuBar(); + + virtual void init(QMenuBar *); + + virtual void setVisible(bool visible); + + virtual void actionEvent(QActionEvent *e); + + virtual void handleReparent(QWidget *oldParent, QWidget *newParent, QWidget *oldWindow, QWidget *newWindow); + + virtual bool allowCornerWidgets() const; + + virtual void popupAction(QAction*); + + virtual void setNativeMenuBar(bool); + virtual bool isNativeMenuBar() const; + + virtual bool shortcutsHandledByNativeMenuBar() const; + virtual bool menuBarEventFilter(QObject *, QEvent *event); + +private: + QMenuBar *menuBar; + int nativeMenuBar : 3; // Only has values -1, 0, and 1 +}; + +QT_END_NAMESPACE + +#endif // QT_NO_MENUBAR + +#endif /* QX11MENUBAR_P_H */ diff --git a/src/gui/widgets/widgets.pri b/src/gui/widgets/widgets.pri index 669b83830f..6b3d6a984a 100644 --- a/src/gui/widgets/widgets.pri +++ b/src/gui/widgets/widgets.pri @@ -144,6 +144,14 @@ SOURCES += \ widgets/qplaintextedit.cpp \ widgets/qprintpreviewwidget.cpp +x11: { + HEADERS += \ + widgets/qabstractplatformmenubar_p.h + + SOURCES += \ + widgets/qmenubar_x11.cpp +} + !embedded:!qpa:mac { HEADERS += widgets/qmacnativewidget_mac.h \ widgets/qmaccocoaviewcontainer_mac.h -- cgit v1.2.3 From baeed7c6c35814e370edab5d9500cba651919d26 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aur=C3=A9lien=20G=C3=A2teau?= Date: Tue, 14 Jun 2011 18:04:26 +0200 Subject: Introduce menubar plugin system Merge-request: 1254 Reviewed-by: Gabriel de Dietrich (cherry picked from commit 31ff55bbeb84f10e75e997c75a63deda83e62507) Change-Id: I0644514299c16cabe19d1e6d024dd652b2d7bc4e Reviewed-on: http://codereview.qt.nokia.com/3933 Reviewed-by: Gabriel de Dietrich --- src/gui/widgets/qabstractplatformmenubar_p.h | 12 ++++++++++++ src/gui/widgets/qmenubar.cpp | 5 ++++- src/gui/widgets/qmenubar_x11.cpp | 24 ++++++++++++++++++++++++ src/gui/widgets/qmenubar_x11_p.h | 2 ++ 4 files changed, 42 insertions(+), 1 deletion(-) diff --git a/src/gui/widgets/qabstractplatformmenubar_p.h b/src/gui/widgets/qabstractplatformmenubar_p.h index 86e212be9d..cb4e5cba73 100644 --- a/src/gui/widgets/qabstractplatformmenubar_p.h +++ b/src/gui/widgets/qabstractplatformmenubar_p.h @@ -41,7 +41,9 @@ #ifndef QABSTRACTPLATFORMMENUBAR_P_H #define QABSTRACTPLATFORMMENUBAR_P_H +#include #include +#include #ifndef QT_NO_MENUBAR @@ -54,6 +56,16 @@ class QMenuBar; class QObject; class QWidget; +class QAbstractPlatformMenuBar; + +struct QPlatformMenuBarFactoryInterface : public QFactoryInterface +{ + virtual QAbstractPlatformMenuBar *create() = 0; +}; + +#define QPlatformMenuBarFactoryInterface_iid "com.nokia.qt.QPlatformMenuBarFactoryInterface" +Q_DECLARE_INTERFACE(QPlatformMenuBarFactoryInterface, QPlatformMenuBarFactoryInterface_iid) + /*! The platform-specific implementation of a menubar */ diff --git a/src/gui/widgets/qmenubar.cpp b/src/gui/widgets/qmenubar.cpp index ff09b6e3e7..018d9f06a3 100644 --- a/src/gui/widgets/qmenubar.cpp +++ b/src/gui/widgets/qmenubar.cpp @@ -55,6 +55,9 @@ #include #include #include +#ifdef Q_WS_X11 +#include +#endif #ifndef QT_NO_MENUBAR @@ -761,7 +764,7 @@ void QMenuBarPrivate::init() } #endif #ifdef Q_WS_X11 - platformMenuBar = new QX11MenuBar; + platformMenuBar = qt_guiPlatformMenuBarFactory()->create(); platformMenuBar->init(q); #endif diff --git a/src/gui/widgets/qmenubar_x11.cpp b/src/gui/widgets/qmenubar_x11.cpp index ca227a6c4c..37c085fc4a 100644 --- a/src/gui/widgets/qmenubar_x11.cpp +++ b/src/gui/widgets/qmenubar_x11.cpp @@ -48,6 +48,8 @@ #include "qmenu.h" #include "qmenubar.h" +#include + QT_BEGIN_NAMESPACE QX11MenuBar::~QX11MenuBar() @@ -109,6 +111,28 @@ bool QX11MenuBar::menuBarEventFilter(QObject *, QEvent *) return false; } +struct QX11MenuBarFactory : public QPlatformMenuBarFactoryInterface +{ + QAbstractPlatformMenuBar *create() { return new QX11MenuBar; } + virtual QStringList keys() const { return QStringList(); } +}; + +QPlatformMenuBarFactoryInterface *qt_guiPlatformMenuBarFactory() +{ + static QPlatformMenuBarFactoryInterface *factory = 0; + if (!factory) { +#ifndef QT_NO_LIBRARY + QFactoryLoader loader(QPlatformMenuBarFactoryInterface_iid, QLatin1String("/menubar")); + factory = qobject_cast(loader.instance(QLatin1String("default"))); +#endif // QT_NO_LIBRARY + if(!factory) { + static QX11MenuBarFactory def; + factory = &def; + } + } + return factory; +} + QT_END_NAMESPACE #endif // QT_NO_MENUBAR diff --git a/src/gui/widgets/qmenubar_x11_p.h b/src/gui/widgets/qmenubar_x11_p.h index dbe0223255..1c43b04406 100644 --- a/src/gui/widgets/qmenubar_x11_p.h +++ b/src/gui/widgets/qmenubar_x11_p.h @@ -77,6 +77,8 @@ private: int nativeMenuBar : 3; // Only has values -1, 0, and 1 }; +QPlatformMenuBarFactoryInterface *qt_guiPlatformMenuBarFactory(); + QT_END_NAMESPACE #endif // QT_NO_MENUBAR -- cgit v1.2.3 From 4a0bab33d62661c09d34dbfde7b1196449120da1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Tue, 30 Aug 2011 16:25:54 +0200 Subject: Fix build with Clang for libpng versions 1.4.0 to 1.5.2 Versions 1.4.0 to 1.5.2 of libpng declare png_longjmp_ptr to have a noreturn attribute if PNG_PEDANTIC_WARNINGS_SUPPORTED is enabled, but most declarations of longjmp in the wild do not add this attribute. This causes problems when the png_jmpbuf macro expands to calling png_set_longjmp_fn with a mismatched longjmp, as compilers such as Clang will treat this as an error. To work around this we override the png_jmpbuf macro to cast longjmp to a png_longjmp_ptr. See also http://llvm.org/bugs/show_bug.cgi?id=10338 Reviewed-by: Simon Hausmann Reviewed-by: Marius Storm-Olsen Change-Id: I197cfa12af76410310e409bc0fce7d4332ee66a6 Reviewed-on: http://codereview.qt.nokia.com/3929 Reviewed-by: Qt Sanity Bot Reviewed-by: Oswald Buddenhagen --- src/gui/image/qpnghandler.cpp | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/src/gui/image/qpnghandler.cpp b/src/gui/image/qpnghandler.cpp index f7d07a5b14..1714442eb6 100644 --- a/src/gui/image/qpnghandler.cpp +++ b/src/gui/image/qpnghandler.cpp @@ -58,6 +58,29 @@ #include #endif +#if PNG_LIBPNG_VER >= 10400 && PNG_LIBPNG_VER <= 10502 \ + && defined(PNG_PEDANTIC_WARNINGS_SUPPORTED) +/* + Versions 1.4.0 to 1.5.2 of libpng declare png_longjmp_ptr to + have a noreturn attribute if PNG_PEDANTIC_WARNINGS_SUPPORTED + is enabled, but most declarations of longjmp in the wild do + not add this attribute. This causes problems when the png_jmpbuf + macro expands to calling png_set_longjmp_fn with a mismatched + longjmp, as compilers such as Clang will treat this as an error. + + To work around this we override the png_jmpbuf macro to cast + longjmp to a png_longjmp_ptr. +*/ +# undef png_jmpbuf +# ifdef PNG_SETJMP_SUPPORTED +# define png_jmpbuf(png_ptr) \ + (*png_set_longjmp_fn((png_ptr), (png_longjmp_ptr)longjmp, sizeof(jmp_buf))) +# else +# define png_jmpbuf(png_ptr) \ + (LIBPNG_WAS_COMPILED_WITH__PNG_NO_SETJMP) +# endif +#endif + #ifdef Q_OS_WINCE #define CALLBACK_CALL_TYPE __cdecl #else -- cgit v1.2.3 From a3e8f1ab0cc38c0d2e631d3e7f9e6379982204b7 Mon Sep 17 00:00:00 2001 From: "Bradley T. Hughes" Date: Wed, 31 Aug 2011 15:19:07 +0200 Subject: Add src/v8/qtv8version.h to .gitignore Change-Id: I3e63a3b7cfc06ea4b71c55c1530433438c902aa7 Reviewed-on: http://codereview.qt.nokia.com/3979 Reviewed-by: Lars Knoll Reviewed-by: Qt Sanity Bot --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 5199d726b9..8ea5270519 100644 --- a/.gitignore +++ b/.gitignore @@ -126,6 +126,7 @@ src/openvg/qtopenvgversion.h src/sql/qtsqlversion.h src/testlib/qttestversion.h src/xml/qtxmlversion.h +src/v8/qtv8version.h # Test generated files QObject.log -- cgit v1.2.3 From a4878db8df3fbaf9d222ec1206813b16dcdd90c7 Mon Sep 17 00:00:00 2001 From: Corentin Chary Date: Wed, 31 Aug 2011 19:35:35 +0200 Subject: qssl: add support for QSsl::Opaque key This allow to use directly EVP_PKEY * with QSslKey (for example comming from a PKCS#11 dongle). Change-Id: Icb1ba5081506a831ec3d8cfffe13ce70939608ea Merge-request: 48 Reviewed-by: Peter Hartmann Reviewed-on: http://codereview.qt.nokia.com/4010 Reviewed-by: Qt Sanity Bot --- src/network/ssl/qssl.h | 1 + src/network/ssl/qsslkey.cpp | 46 ++++++++++++++++++++++++++++++---- src/network/ssl/qsslkey.h | 1 + src/network/ssl/qsslkey_p.h | 2 ++ src/network/ssl/qsslsocket_openssl.cpp | 26 +++++++++++-------- 5 files changed, 61 insertions(+), 15 deletions(-) diff --git a/src/network/ssl/qssl.h b/src/network/ssl/qssl.h index 7b76b64b4c..c8af346800 100644 --- a/src/network/ssl/qssl.h +++ b/src/network/ssl/qssl.h @@ -63,6 +63,7 @@ namespace QSsl { }; enum KeyAlgorithm { + Opaque, Rsa, Dsa }; diff --git a/src/network/ssl/qsslkey.cpp b/src/network/ssl/qsslkey.cpp index 29cfd0a77d..580b71bca9 100644 --- a/src/network/ssl/qsslkey.cpp +++ b/src/network/ssl/qsslkey.cpp @@ -89,6 +89,11 @@ void QSslKeyPrivate::clear(bool deep) q_DSA_free(dsa); dsa = 0; } + if (opaque) { + if (deep) + q_EVP_PKEY_free(opaque); + opaque = 0; + } } /*! @@ -264,6 +269,23 @@ QSslKey::QSslKey(QIODevice *device, QSsl::KeyAlgorithm algorithm, QSsl::Encoding passPhrase); } +/*! + Constructs a QSslKey from a valid native key \a handle. + \a type specifies whether the key is public or private. + + QSslKey will take ownership for this key and you must not + free the key using the native library. The algorithm used + when creating a key from a handle will always be QSsl::Opaque. +*/ +QSslKey::QSslKey(Qt::HANDLE handle, QSsl::KeyType type) + : d(new QSslKeyPrivate) +{ + d->opaque = reinterpret_cast(handle); + d->algorithm = QSsl::Opaque; + d->type = type; + d->isNull = !d->opaque; +} + /*! Constructs an identical copy of \a other. */ @@ -315,8 +337,9 @@ void QSslKey::clear() */ int QSslKey::length() const { - if (d->isNull) + if (d->isNull || d->algorithm == QSsl::Opaque) return -1; + return (d->algorithm == QSsl::Rsa) ? q_BN_num_bits(d->rsa->n) : q_BN_num_bits(d->dsa->p); } @@ -345,8 +368,9 @@ QSsl::KeyAlgorithm QSslKey::algorithm() const // ### autotest failure for non-empty passPhrase and private key QByteArray QSslKey::toDer(const QByteArray &passPhrase) const { - if (d->isNull) + if (d->isNull || d->algorithm == QSsl::Opaque) return QByteArray(); + return d->derFromPem(toPem(passPhrase)); } @@ -357,7 +381,7 @@ QByteArray QSslKey::toDer(const QByteArray &passPhrase) const */ QByteArray QSslKey::toPem(const QByteArray &passPhrase) const { - if (!QSslSocket::supportsSsl() || d->isNull) + if (!QSslSocket::supportsSsl() || d->isNull || d->algorithm == QSsl::Opaque) return QByteArray(); BIO *bio = q_BIO_new(q_BIO_s_mem()); @@ -417,7 +441,16 @@ QByteArray QSslKey::toPem(const QByteArray &passPhrase) const */ Qt::HANDLE QSslKey::handle() const { - return (d->algorithm == QSsl::Rsa) ? Qt::HANDLE(d->rsa) : Qt::HANDLE(d->dsa); + switch (d->algorithm) { + case QSsl::Opaque: + return Qt::HANDLE(d->opaque); + case QSsl::Rsa: + return Qt::HANDLE(d->rsa); + case QSsl::Dsa: + return Qt::HANDLE(d->dsa); + default: + return Qt::HANDLE(NULL); + } } /*! @@ -435,6 +468,8 @@ bool QSslKey::operator==(const QSslKey &other) const return false; if (length() != other.length()) return false; + if (algorithm() == QSsl::Opaque) + return handle() == other.handle(); return toDer() == other.toDer(); } @@ -450,7 +485,8 @@ QDebug operator<<(QDebug debug, const QSslKey &key) { debug << "QSslKey(" << (key.type() == QSsl::PublicKey ? "PublicKey" : "PrivateKey") - << ", " << (key.algorithm() == QSsl::Rsa ? "RSA" : "DSA") + << ", " << (key.algorithm() == QSsl::Opaque ? "OPAQUE" : + (key.algorithm() == QSsl::Rsa ? "RSA" : "DSA")) << ", " << key.length() << ')'; return debug; diff --git a/src/network/ssl/qsslkey.h b/src/network/ssl/qsslkey.h index 5ee1b4ad2f..7064d22eb4 100644 --- a/src/network/ssl/qsslkey.h +++ b/src/network/ssl/qsslkey.h @@ -73,6 +73,7 @@ public: QSsl::EncodingFormat format = QSsl::Pem, QSsl::KeyType type = QSsl::PrivateKey, const QByteArray &passPhrase = QByteArray()); + explicit QSslKey(Qt::HANDLE handle, QSsl::KeyType type = QSsl::PrivateKey); QSslKey(const QSslKey &other); ~QSslKey(); QSslKey &operator=(const QSslKey &other); diff --git a/src/network/ssl/qsslkey_p.h b/src/network/ssl/qsslkey_p.h index f4a77b3c3f..14075ecad0 100644 --- a/src/network/ssl/qsslkey_p.h +++ b/src/network/ssl/qsslkey_p.h @@ -67,6 +67,7 @@ public: inline QSslKeyPrivate() : rsa(0) , dsa(0) + , opaque(0) { clear(); } @@ -88,6 +89,7 @@ public: QSsl::KeyAlgorithm algorithm; RSA *rsa; DSA *dsa; + EVP_PKEY *opaque; QAtomicInt ref; diff --git a/src/network/ssl/qsslsocket_openssl.cpp b/src/network/ssl/qsslsocket_openssl.cpp index 300a5c84d5..2fae2ccdce 100644 --- a/src/network/ssl/qsslsocket_openssl.cpp +++ b/src/network/ssl/qsslsocket_openssl.cpp @@ -364,20 +364,27 @@ init_context: return false; } - // Load private key - pkey = q_EVP_PKEY_new(); - // before we were using EVP_PKEY_assign_R* functions and did not use EVP_PKEY_free. - // this lead to a memory leak. Now we use the *_set1_* functions which do not - // take ownership of the RSA/DSA key instance because the QSslKey already has ownership. - if (configuration.privateKey.algorithm() == QSsl::Rsa) - q_EVP_PKEY_set1_RSA(pkey, (RSA *)configuration.privateKey.handle()); - else - q_EVP_PKEY_set1_DSA(pkey, (DSA *)configuration.privateKey.handle()); + if (configuration.privateKey.algorithm() == QSsl::Opaque) { + pkey = reinterpret_cast(configuration.privateKey.handle()); + } else { + // Load private key + pkey = q_EVP_PKEY_new(); + // before we were using EVP_PKEY_assign_R* functions and did not use EVP_PKEY_free. + // this lead to a memory leak. Now we use the *_set1_* functions which do not + // take ownership of the RSA/DSA key instance because the QSslKey already has ownership. + if (configuration.privateKey.algorithm() == QSsl::Rsa) + q_EVP_PKEY_set1_RSA(pkey, (RSA *)configuration.privateKey.handle()); + else + q_EVP_PKEY_set1_DSA(pkey, (DSA *)configuration.privateKey.handle()); + } + if (!q_SSL_CTX_use_PrivateKey(ctx, pkey)) { q->setErrorString(QSslSocket::tr("Error loading private key, %1").arg(getErrorsFromOpenSsl())); emit q->error(QAbstractSocket::UnknownSocketError); return false; } + if (configuration.privateKey.algorithm() == QSsl::Opaque) + pkey = 0; // Don't free the private key, it belongs to QSslKey // Check if the certificate matches the private key. if (!q_SSL_CTX_check_private_key(ctx)) { @@ -1383,7 +1390,6 @@ void QSslSocketBackendPrivate::disconnected() q_EVP_PKEY_free(pkey); pkey = 0; } - } QSslCipher QSslSocketBackendPrivate::sessionCipher() const -- cgit v1.2.3 From b17e9b3d94dc041ed80854076d2053e2c750eb50 Mon Sep 17 00:00:00 2001 From: Jason McDonald Date: Tue, 30 Aug 2011 18:36:46 +1000 Subject: Simplify qtestlib logging code, part 1 Both the old and new XML loggers produce the Complete and Light XML log formats, while only the new logger produces Xunit XML logs. The disadvantage of the new logger is that it is more complex and doesn't produce a partial log if the test fails to terminate gracefully. This behaviour arises because Xunit format output cannot be written correctly until all tests have been executed. This commit removes the Complete and Light XML formats from the new logger, using the old logger to produce those formats and the new logger to produce only Xunit XML. Prior to this commit, the qtestlib selftests demonstrate that the old and new loggers produce identical output for Complete and Light XML. This commit also removes the undocumented -flush command-line option, which was used rather obscurely to select between the old and new loggers. The newer logger will be renamed to QXunitTestLogger in a subsequent commit. Change-Id: Id304f5b411bdd520409ee233f6bc34e8917942ab Reviewed-on: http://codereview.qt.nokia.com/3923 Reviewed-by: Qt Sanity Bot Reviewed-by: Rohan McGovern --- src/testlib/qtestcase.cpp | 3 - src/testlib/qtestlightxmlstreamer.cpp | 211 ------------------------------- src/testlib/qtestlightxmlstreamer.h | 72 ----------- src/testlib/qtestlog.cpp | 20 +-- src/testlib/qtestlog_p.h | 2 - src/testlib/qtestlogger.cpp | 96 ++++++-------- src/testlib/qtestlogger_p.h | 10 +- src/testlib/qtestxmlstreamer.cpp | 222 --------------------------------- src/testlib/qtestxmlstreamer.h | 72 ----------- src/testlib/testlib.pro | 4 - src/tools/uic/qclass_lib_map.h | 2 - tests/auto/selftests/tst_selftests.cpp | 10 +- 12 files changed, 46 insertions(+), 678 deletions(-) delete mode 100644 src/testlib/qtestlightxmlstreamer.cpp delete mode 100644 src/testlib/qtestlightxmlstreamer.h delete mode 100644 src/testlib/qtestxmlstreamer.cpp delete mode 100644 src/testlib/qtestxmlstreamer.h diff --git a/src/testlib/qtestcase.cpp b/src/testlib/qtestcase.cpp index 3802794281..d3176bbe09 100644 --- a/src/testlib/qtestcase.cpp +++ b/src/testlib/qtestcase.cpp @@ -1006,7 +1006,6 @@ Q_TESTLIB_EXPORT void qtest_qParseArgs(int argc, char *argv[], bool qml) " -xunitxml : Outputs results as XML XUnit document\n" " -xml : Outputs results as XML document\n" " -lightxml : Outputs results as stream of XML tags\n" - " -flush : Flushes the results\n" " -o filename: Writes all output into a file\n" " -silent : Only outputs warnings and failures\n" " -v1 : Print enter messages for each testfunction\n" @@ -1066,8 +1065,6 @@ Q_TESTLIB_EXPORT void qtest_qParseArgs(int argc, char *argv[], bool qml) QTestLog::setLogMode(QTestLog::XML); } else if (strcmp(argv[i], "-lightxml") == 0) { QTestLog::setLogMode(QTestLog::LightXML); - } else if (strcmp(argv[i], "-flush") == 0){ - QTestLog::setFlushMode(QTestLog::FlushOn); } else if (strcmp(argv[i], "-silent") == 0) { QTestLog::setVerboseLevel(-1); } else if (strcmp(argv[i], "-v1") == 0) { diff --git a/src/testlib/qtestlightxmlstreamer.cpp b/src/testlib/qtestlightxmlstreamer.cpp deleted file mode 100644 index 4aba2a2bf8..0000000000 --- a/src/testlib/qtestlightxmlstreamer.cpp +++ /dev/null @@ -1,211 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtTest module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qtestlightxmlstreamer.h" -#include "qtestelement.h" -#include "qtestelementattribute.h" -#include "qtestlogger_p.h" - -#include "QtTest/private/qtestlog_p.h" -#include "QtTest/private/qtestresult_p.h" -#include "QtTest/private/qxmltestlogger_p.h" - -#include - -QT_BEGIN_NAMESPACE - -QTestLightXmlStreamer::QTestLightXmlStreamer(QTestLogger *logger) - : QTestBasicStreamer(logger) -{ -} - -QTestLightXmlStreamer::~QTestLightXmlStreamer() -{} - -void QTestLightXmlStreamer::formatStart(const QTestElement *element, QTestCharBuffer *formatted) const -{ - if(!element || !formatted) - return; - - switch(element->elementType()){ - case QTest::LET_TestCase: { - QTestCharBuffer quotedTf; - QXmlTestLogger::xmlQuote("edTf, element->attributeValue(QTest::AI_Name)); - - QTest::qt_asprintf(formatted, "\n", quotedTf.constData()); - break; - } - case QTest::LET_Failure: { - QTestCharBuffer cdataDesc; - QXmlTestLogger::xmlCdata(&cdataDesc, element->attributeValue(QTest::AI_Description)); - - QTestCharBuffer location; - QTestCharBuffer quotedFile; - QXmlTestLogger::xmlQuote("edFile, element->attributeValue(QTest::AI_File)); - - QTest::qt_asprintf(&location, "%s=\"%s\" %s=\"%s\"", - element->attributeName(QTest::AI_File), - quotedFile.constData(), - element->attributeName(QTest::AI_Line), - element->attributeValue(QTest::AI_Line)); - - if (element->attribute(QTest::AI_Tag)) { - QTestCharBuffer cdataTag; - QXmlTestLogger::xmlCdata(&cdataTag, element->attributeValue(QTest::AI_Tag)); - QTest::qt_asprintf(formatted, "\n" - " \n" - " \n" - "\n", element->attributeValue(QTest::AI_Result), - location.constData(), cdataTag.constData(), cdataDesc.constData()); - } - else { - QTest::qt_asprintf(formatted, "\n" - " \n" - "\n", element->attributeValue(QTest::AI_Result), - location.constData(), cdataDesc.constData()); - } - break; - } - case QTest::LET_Error: { - // assuming type and attribute names don't need quoting - QTestCharBuffer quotedFile; - QTestCharBuffer cdataDesc; - QXmlTestLogger::xmlQuote("edFile, element->attributeValue(QTest::AI_File)); - QXmlTestLogger::xmlCdata(&cdataDesc, element->attributeValue(QTest::AI_Description)); - - QTestCharBuffer tagbuf; - if (element->attribute(QTest::AI_Tag)) { - QTestCharBuffer cdataTag; - QXmlTestLogger::xmlCdata(&cdataTag, element->attributeValue(QTest::AI_Tag)); - QTest::qt_asprintf(&tagbuf, " \n", cdataTag.constData()); - } - - QTest::qt_asprintf(formatted, "\n%s \n\n", - element->attributeValue(QTest::AI_Type), - element->attributeName(QTest::AI_File), - quotedFile.constData(), - element->attributeName(QTest::AI_Line), - element->attributeValue(QTest::AI_Line), - tagbuf.constData(), - cdataDesc.constData()); - break; - } - case QTest::LET_Benchmark: { - // assuming value and iterations don't need quoting - QTestCharBuffer quotedMetric; - QTestCharBuffer quotedTag; - QXmlTestLogger::xmlQuote("edMetric, element->attributeValue(QTest::AI_Metric)); - QXmlTestLogger::xmlQuote("edTag, element->attributeValue(QTest::AI_Tag)); - - QTest::qt_asprintf(formatted, "\n", - element->attributeName(QTest::AI_Metric), - quotedMetric.constData(), - element->attributeName(QTest::AI_Tag), - quotedTag.constData(), - element->attributeName(QTest::AI_Value), - element->attributeValue(QTest::AI_Value), - element->attributeName(QTest::AI_Iterations), - element->attributeValue(QTest::AI_Iterations) ); - break; - } - default: - formatted->data()[0] = '\0'; - } -} - -void QTestLightXmlStreamer::formatEnd(const QTestElement *element, QTestCharBuffer *formatted) const -{ - if(!element || !formatted) - return; - - if (element->elementType() == QTest::LET_TestCase) { - bool failed = false; - for (QTestElement* child = element->childElements(); child; child = child->nextElement()) { - if ( child->elementType() == QTest::LET_Failure - && child->attribute(QTest::AI_Result) - && ( !strcmp(child->attributeValue(QTest::AI_Result), "fail") - || !strcmp(child->attributeValue(QTest::AI_Result), "xpass")) - ) - { - failed = true; - break; - } - } - - // For passing functions, no Incident has been output yet. - // For failing functions, we already output one. - // Please note: we are outputting "pass" even if there was an xfail etc. - // This is by design (arguably bad design, but dangerous to change now!) - if (element->attribute(QTest::AI_Result) && !failed) { - QTest::qt_asprintf(formatted, "\n\n"); - } - else { - QTest::qt_asprintf(formatted, "\n"); - } - } else { - formatted->data()[0] = '\0'; - } -} - -void QTestLightXmlStreamer::formatBeforeAttributes(const QTestElement *element, QTestCharBuffer *formatted) const -{ - Q_UNUSED(element); - if (!formatted) - return; - - formatted->data()[0] = '\0'; -} - -void QTestLightXmlStreamer::output(QTestElement *element) const -{ - QTestCharBuffer buf; - QTest::qt_asprintf(&buf, "\n %s\n %s\n", - qVersion(), QTEST_VERSION_STR ); - outputString(buf.constData()); - - QTest::qt_asprintf(&buf, "\n"); - outputString(buf.constData()); - - QTestBasicStreamer::output(element); -} - -QT_END_NAMESPACE - diff --git a/src/testlib/qtestlightxmlstreamer.h b/src/testlib/qtestlightxmlstreamer.h deleted file mode 100644 index b3076c1623..0000000000 --- a/src/testlib/qtestlightxmlstreamer.h +++ /dev/null @@ -1,72 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtTest module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QTESTLIGHTXMLSTREAMER_H -#define QTESTLIGHTXMLSTREAMER_H - -#include - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Test) - -class QTestElement; -class QTestElementAttribute; - -class QTestLightXmlStreamer: public QTestBasicStreamer -{ - public: - QTestLightXmlStreamer(QTestLogger *logger); - ~QTestLightXmlStreamer(); - - void formatStart(const QTestElement *element, QTestCharBuffer *formatted) const; - void formatEnd(const QTestElement *element, QTestCharBuffer *formatted) const; - void formatBeforeAttributes(const QTestElement *element, QTestCharBuffer *formatted) const; - void output(QTestElement *element) const; -}; - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif diff --git a/src/testlib/qtestlog.cpp b/src/testlib/qtestlog.cpp index 0a87a4ce14..77ddae65be 100644 --- a/src/testlib/qtestlog.cpp +++ b/src/testlib/qtestlog.cpp @@ -83,7 +83,6 @@ namespace QTest { static IgnoreResultList *ignoreResultList = 0; static QTestLog::LogMode logMode = QTestLog::Plain; - static QTestLog::FlushMode flushMode = QTestLog::NoFlush; static int verbosity = 0; static int maxWarnings = 2002; @@ -173,22 +172,16 @@ namespace QTest { QTest::testLogger = new QPlainTestLogger; break; case QTestLog::XML: - if (QTest::flushMode == QTestLog::FlushOn) - QTest::testLogger = new QXmlTestLogger(QXmlTestLogger::Complete); - else - QTest::testLogger = new QTestLogger(QTestLogger::TLF_XML); + QTest::testLogger = new QXmlTestLogger(QXmlTestLogger::Complete); break; case QTestLog::LightXML: - if (QTest::flushMode == QTestLog::FlushOn) - QTest::testLogger = new QXmlTestLogger(QXmlTestLogger::Light); - else - QTest::testLogger = new QTestLogger(QTestLogger::TLF_LightXml); + QTest::testLogger = new QXmlTestLogger(QXmlTestLogger::Light); break; case QTestLog::XunitXML: - QTest::testLogger = new QTestLogger(QTestLogger::TLF_XunitXml); + QTest::testLogger = new QTestLogger(); + break; } } - } void QTestLog::enterTestFunction(const char* function) @@ -368,9 +361,4 @@ void QTestLog::setMaxWarnings(int m) QTest::maxWarnings = m <= 0 ? INT_MAX : m + 2; } -void QTestLog::setFlushMode(FlushMode mode) -{ - QTest::flushMode = mode; -} - QT_END_NAMESPACE diff --git a/src/testlib/qtestlog_p.h b/src/testlib/qtestlog_p.h index 9b580eb8cc..c667289b66 100644 --- a/src/testlib/qtestlog_p.h +++ b/src/testlib/qtestlog_p.h @@ -63,7 +63,6 @@ class Q_TESTLIB_EXPORT QTestLog { public: enum LogMode { Plain = 0, XML, LightXML, XunitXML }; - enum FlushMode { NoFlush = 0, FlushOn }; static void enterTestFunction(const char* function); static void leaveTestFunction(); @@ -95,7 +94,6 @@ public: static void setMaxWarnings(int max); - static void setFlushMode(FlushMode mode); private: QTestLog(); ~QTestLog(); diff --git a/src/testlib/qtestlogger.cpp b/src/testlib/qtestlogger.cpp index 385fb866c2..1665dde6e7 100644 --- a/src/testlib/qtestlogger.cpp +++ b/src/testlib/qtestlogger.cpp @@ -42,8 +42,6 @@ #include "qtestlogger_p.h" #include "qtestelement.h" #include "qtestxunitstreamer.h" -#include "qtestxmlstreamer.h" -#include "qtestlightxmlstreamer.h" #include "QtTest/qtestcase.h" #include "QtTest/private/qtestresult_p.h" @@ -53,12 +51,11 @@ QT_BEGIN_NAMESPACE -QTestLogger::QTestLogger(int fm) +QTestLogger::QTestLogger() : listOfTestcases(0) , currentLogElement(0) , errorLogElement(0) , logFormatter(0) - , format( (TestLoggerFormat)fm ) , testCounter(0) , failureCounter(0) , errorCounter(0) @@ -67,11 +64,7 @@ QTestLogger::QTestLogger(int fm) QTestLogger::~QTestLogger() { - if(format == TLF_XunitXml) - delete currentLogElement; - else - delete listOfTestcases; - + delete currentLogElement; delete logFormatter; } @@ -79,71 +72,57 @@ void QTestLogger::startLogging(const char *filename) { QAbstractTestLogger::startLogging(filename); - switch(format){ - case TLF_LightXml: - logFormatter = new QTestLightXmlStreamer(this); - break; - case TLF_XML: - logFormatter = new QTestXmlStreamer(this); - break; - case TLF_XunitXml: - logFormatter = new QTestXunitStreamer(this); - delete errorLogElement; - errorLogElement = new QTestElement(QTest::LET_SystemError); - break; - } + logFormatter = new QTestXunitStreamer(this); + delete errorLogElement; + errorLogElement = new QTestElement(QTest::LET_SystemError); } void QTestLogger::stopLogging() { QTestElement *iterator = listOfTestcases; - if(format == TLF_XunitXml ){ - char buf[10]; + char buf[10]; - currentLogElement = new QTestElement(QTest::LET_TestSuite); - currentLogElement->addAttribute(QTest::AI_Name, QTestResult::currentTestObjectName()); + currentLogElement = new QTestElement(QTest::LET_TestSuite); + currentLogElement->addAttribute(QTest::AI_Name, QTestResult::currentTestObjectName()); - QTest::qt_snprintf(buf, sizeof(buf), "%i", testCounter); - currentLogElement->addAttribute(QTest::AI_Tests, buf); + QTest::qt_snprintf(buf, sizeof(buf), "%i", testCounter); + currentLogElement->addAttribute(QTest::AI_Tests, buf); - QTest::qt_snprintf(buf, sizeof(buf), "%i", failureCounter); - currentLogElement->addAttribute(QTest::AI_Failures, buf); + QTest::qt_snprintf(buf, sizeof(buf), "%i", failureCounter); + currentLogElement->addAttribute(QTest::AI_Failures, buf); - QTest::qt_snprintf(buf, sizeof(buf), "%i", errorCounter); - currentLogElement->addAttribute(QTest::AI_Errors, buf); + QTest::qt_snprintf(buf, sizeof(buf), "%i", errorCounter); + currentLogElement->addAttribute(QTest::AI_Errors, buf); - QTestElement *property; - QTestElement *properties = new QTestElement(QTest::LET_Properties); + QTestElement *property; + QTestElement *properties = new QTestElement(QTest::LET_Properties); - property = new QTestElement(QTest::LET_Property); - property->addAttribute(QTest::AI_Name, "QTestVersion"); - property->addAttribute(QTest::AI_PropertyValue, QTEST_VERSION_STR); - properties->addLogElement(property); + property = new QTestElement(QTest::LET_Property); + property->addAttribute(QTest::AI_Name, "QTestVersion"); + property->addAttribute(QTest::AI_PropertyValue, QTEST_VERSION_STR); + properties->addLogElement(property); - property = new QTestElement(QTest::LET_Property); - property->addAttribute(QTest::AI_Name, "QtVersion"); - property->addAttribute(QTest::AI_PropertyValue, qVersion()); - properties->addLogElement(property); + property = new QTestElement(QTest::LET_Property); + property->addAttribute(QTest::AI_Name, "QtVersion"); + property->addAttribute(QTest::AI_PropertyValue, qVersion()); + properties->addLogElement(property); - currentLogElement->addLogElement(properties); + currentLogElement->addLogElement(properties); - currentLogElement->addLogElement(iterator); + currentLogElement->addLogElement(iterator); - /* For correct indenting, make sure every testcase knows its parent */ - QTestElement* testcase = iterator; - while (testcase) { - testcase->setParent(currentLogElement); - testcase = testcase->nextElement(); - } + /* For correct indenting, make sure every testcase knows its parent */ + QTestElement* testcase = iterator; + while (testcase) { + testcase->setParent(currentLogElement); + testcase = testcase->nextElement(); + } - currentLogElement->addLogElement(errorLogElement); + currentLogElement->addLogElement(errorLogElement); - QTestElement *it = currentLogElement; - logFormatter->output(it); - }else{ - logFormatter->output(iterator); - } + QTestElement *it = currentLogElement; + logFormatter->output(it); QAbstractTestLogger::stopLogging(); } @@ -187,8 +166,7 @@ void QTestLogger::addIncident(IncidentTypes type, const char *description, break; } - if (type == QAbstractTestLogger::Fail || type == QAbstractTestLogger::XPass - || ((format != TLF_XunitXml) && (type == QAbstractTestLogger::XFail))) { + if (type == QAbstractTestLogger::Fail || type == QAbstractTestLogger::XPass) { QTestElement *failureElement = new QTestElement(QTest::LET_Failure); failureElement->addAttribute(QTest::AI_Result, typeBuf); if(file) @@ -241,7 +219,7 @@ void QTestLogger::addIncident(IncidentTypes type, const char *description, Since XFAIL does not add a failure to the testlog in xunitxml, add a message, so we still have some information about the expected failure. */ - if (format == TLF_XunitXml && type == QAbstractTestLogger::XFail) { + if (type == QAbstractTestLogger::XFail) { QTestLogger::addMessage(QAbstractTestLogger::Info, description, file, line); } } diff --git a/src/testlib/qtestlogger_p.h b/src/testlib/qtestlogger_p.h index 5e5b0f2f3f..b9c9f2b6b6 100644 --- a/src/testlib/qtestlogger_p.h +++ b/src/testlib/qtestlogger_p.h @@ -63,16 +63,9 @@ class QTestElement; class QTestLogger : public QAbstractTestLogger { public: - QTestLogger(int fm = 0); + QTestLogger(); ~QTestLogger(); - enum TestLoggerFormat - { - TLF_XML = 0, - TLF_LightXml = 1, - TLF_XunitXml = 2 - }; - void startLogging(const char *filename); void stopLogging(); @@ -92,7 +85,6 @@ class QTestLogger : public QAbstractTestLogger QTestElement *currentLogElement; QTestElement *errorLogElement; QTestBasicStreamer *logFormatter; - TestLoggerFormat format; int testCounter; int failureCounter; diff --git a/src/testlib/qtestxmlstreamer.cpp b/src/testlib/qtestxmlstreamer.cpp deleted file mode 100644 index 47c4463b5a..0000000000 --- a/src/testlib/qtestxmlstreamer.cpp +++ /dev/null @@ -1,222 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtTest module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qtestxmlstreamer.h" -#include "qtestelement.h" -#include "qtestelementattribute.h" -#include "qtestlogger_p.h" - -#include "QtTest/private/qtestlog_p.h" -#include "QtTest/private/qtestresult_p.h" -#include "QtTest/private/qxmltestlogger_p.h" - -#include -#include - -QT_BEGIN_NAMESPACE - -QTestXmlStreamer::QTestXmlStreamer(QTestLogger *logger) - : QTestBasicStreamer(logger) -{ -} - -QTestXmlStreamer::~QTestXmlStreamer() -{} - -void QTestXmlStreamer::formatStart(const QTestElement *element, QTestCharBuffer *formatted) const -{ - if(!element || !formatted) - return; - - switch(element->elementType()){ - case QTest::LET_TestCase: { - QTestCharBuffer quotedTf; - QXmlTestLogger::xmlQuote("edTf, element->attributeValue(QTest::AI_Name)); - - QTest::qt_asprintf(formatted, "\n", quotedTf.constData()); - break; - } - case QTest::LET_Failure: { - QTestCharBuffer cdataDesc; - QXmlTestLogger::xmlCdata(&cdataDesc, element->attributeValue(QTest::AI_Description)); - - QTestCharBuffer location; - QTestCharBuffer quotedFile; - QXmlTestLogger::xmlQuote("edFile, element->attributeValue(QTest::AI_File)); - - QTest::qt_asprintf(&location, "%s=\"%s\" %s=\"%s\"", - element->attributeName(QTest::AI_File), - quotedFile.constData(), - element->attributeName(QTest::AI_Line), - element->attributeValue(QTest::AI_Line)); - - if (element->attribute(QTest::AI_Tag)) { - QTestCharBuffer cdataTag; - QXmlTestLogger::xmlCdata(&cdataTag, element->attributeValue(QTest::AI_Tag)); - QTest::qt_asprintf(formatted, "\n" - " \n" - " \n" - "\n", element->attributeValue(QTest::AI_Result), - location.constData(), cdataTag.constData(), cdataDesc.constData()); - } - else { - QTest::qt_asprintf(formatted, "\n" - " \n" - "\n", element->attributeValue(QTest::AI_Result), - location.constData(), cdataDesc.constData()); - } - break; - } - case QTest::LET_Error: { - // assuming type and attribute names don't need quoting - QTestCharBuffer quotedFile; - QTestCharBuffer cdataDesc; - QXmlTestLogger::xmlQuote("edFile, element->attributeValue(QTest::AI_File)); - QXmlTestLogger::xmlCdata(&cdataDesc, element->attributeValue(QTest::AI_Description)); - - QTestCharBuffer tagbuf; - if (element->attribute(QTest::AI_Tag)) { - QTestCharBuffer cdataTag; - QXmlTestLogger::xmlCdata(&cdataTag, element->attributeValue(QTest::AI_Tag)); - QTest::qt_asprintf(&tagbuf, " \n", cdataTag.constData()); - } - - QTest::qt_asprintf(formatted, "\n%s \n\n", - element->attributeValue(QTest::AI_Type), - element->attributeName(QTest::AI_File), - quotedFile.constData(), - element->attributeName(QTest::AI_Line), - element->attributeValue(QTest::AI_Line), - tagbuf.constData(), - cdataDesc.constData()); - break; - } - case QTest::LET_Benchmark: { - // assuming value and iterations don't need quoting - QTestCharBuffer quotedMetric; - QTestCharBuffer quotedTag; - QXmlTestLogger::xmlQuote("edMetric, element->attributeValue(QTest::AI_Metric)); - QXmlTestLogger::xmlQuote("edTag, element->attributeValue(QTest::AI_Tag)); - - QTest::qt_asprintf(formatted, "\n", - element->attributeName(QTest::AI_Metric), - quotedMetric.constData(), - element->attributeName(QTest::AI_Tag), - quotedTag.constData(), - element->attributeName(QTest::AI_Value), - element->attributeValue(QTest::AI_Value), - element->attributeName(QTest::AI_Iterations), - element->attributeValue(QTest::AI_Iterations) ); - break; - } - default: - formatted->data()[0] = '\0'; - } -} - -void QTestXmlStreamer::formatEnd(const QTestElement *element, QTestCharBuffer *formatted) const -{ - if(!element || !formatted) - return; - - if (element->elementType() == QTest::LET_TestCase) { - bool failed = false; - for (QTestElement* child = element->childElements(); child; child = child->nextElement()) { - if ( child->elementType() == QTest::LET_Failure - && child->attribute(QTest::AI_Result) - && ( !strcmp(child->attributeValue(QTest::AI_Result), "fail") - || !strcmp(child->attributeValue(QTest::AI_Result), "xpass")) - ) - { - failed = true; - break; - } - } - - // For passing functions, no Incident has been output yet. - // For failing functions, we already output one. - // Please note: we are outputting "pass" even if there was an xfail etc. - // This is by design (arguably bad design, but dangerous to change now!) - if (element->attribute(QTest::AI_Result) && !failed) { - QTest::qt_asprintf(formatted, "\n\n"); - } - else { - QTest::qt_asprintf(formatted, "\n"); - } - } else { - formatted->data()[0] = '\0'; - } -} - -void QTestXmlStreamer::formatBeforeAttributes(const QTestElement *element, QTestCharBuffer *formatted) const -{ - Q_UNUSED(element); - if (!formatted) - return; - - formatted->data()[0] = '\0'; -} - -void QTestXmlStreamer::output(QTestElement *element) const -{ - QTestCharBuffer buf; - QTestCharBuffer quotedTc; - QXmlTestLogger::xmlQuote("edTc, QTestResult::currentTestObjectName()); - - QTest::qt_asprintf(&buf, "\n\n", - quotedTc.constData()); - outputString(buf.constData()); - - QTest::qt_asprintf(&buf, "\n %s\n %s\n", - qVersion(), QTEST_VERSION_STR ); - outputString(buf.constData()); - - QTest::qt_asprintf(&buf, "\n"); - outputString(buf.constData()); - - QTestBasicStreamer::output(element); - - QTest::qt_asprintf(&buf, "\n"); - outputString(buf.constData()); -} - -QT_END_NAMESPACE - diff --git a/src/testlib/qtestxmlstreamer.h b/src/testlib/qtestxmlstreamer.h deleted file mode 100644 index 96e8246779..0000000000 --- a/src/testlib/qtestxmlstreamer.h +++ /dev/null @@ -1,72 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtTest module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QTESTXMLSTREAMER_H -#define QTESTXMLSTREAMER_H - -#include - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Test) - -class QTestElement; -class QTestElementAttribute; - -class QTestXmlStreamer: public QTestBasicStreamer -{ - public: - QTestXmlStreamer(QTestLogger *logger); - ~QTestXmlStreamer(); - - void formatStart(const QTestElement *element, QTestCharBuffer *formatted) const; - void formatEnd(const QTestElement *element, QTestCharBuffer *formatted) const; - void formatBeforeAttributes(const QTestElement *element, QTestCharBuffer *formatted) const; - void output(QTestElement *element) const; -}; - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif diff --git a/src/testlib/testlib.pro b/src/testlib/testlib.pro index 482c82cfd3..4133472738 100644 --- a/src/testlib/testlib.pro +++ b/src/testlib/testlib.pro @@ -31,12 +31,10 @@ HEADERS = qbenchmark.h \ qtest_gui.h \ qtest.h \ qtestkeyboard.h \ - qtestlightxmlstreamer.h \ qtestmouse.h \ qtestspontaneevent.h \ qtestsystem.h \ qtesttouch.h \ - qtestxmlstreamer.h \ qtestxunitstreamer.h SOURCES = qtestcase.cpp \ qtestlog.cpp \ @@ -57,8 +55,6 @@ SOURCES = qtestcase.cpp \ qtestelementattribute.cpp \ qtestbasicstreamer.cpp \ qtestxunitstreamer.cpp \ - qtestxmlstreamer.cpp \ - qtestlightxmlstreamer.cpp \ qtestlogger.cpp DEFINES *= QT_NO_CAST_TO_ASCII \ QT_NO_CAST_FROM_ASCII \ diff --git a/src/tools/uic/qclass_lib_map.h b/src/tools/uic/qclass_lib_map.h index f86f458d45..a4b71defd0 100644 --- a/src/tools/uic/qclass_lib_map.h +++ b/src/tools/uic/qclass_lib_map.h @@ -527,11 +527,9 @@ QT_CLASS_LIB(QTestMouseEvent, QtTest, qtestevent.h) QT_CLASS_LIB(QTestDelayEvent, QtTest, qtestevent.h) QT_CLASS_LIB(QTestEventList, QtTest, qtestevent.h) QT_CLASS_LIB(QTestEventLoop, QtTest, qtesteventloop.h) -QT_CLASS_LIB(QTestLightXmlStreamer, QtTest, qtestlightxmlstreamer.h) QT_CLASS_LIB(QEventSizeOfChecker, QtTest, qtestspontaneevent.h) QT_CLASS_LIB(QEventSizeOfChecker, QtTest, qtestspontaneevent.h) QT_CLASS_LIB(QSpontaneKeyEvent, QtTest, qtestspontaneevent.h) -QT_CLASS_LIB(QTestXmlStreamer, QtTest, qtestxmlstreamer.h) QT_CLASS_LIB(QTestXunitStreamer, QtTest, qtestxunitstreamer.h) QT_CLASS_LIB(QDBusAbstractAdaptor, QtDBus, qdbusabstractadaptor.h) QT_CLASS_LIB(QDBusAbstractInterfaceBase, QtDBus, qdbusabstractinterface.h) diff --git a/tests/auto/selftests/tst_selftests.cpp b/tests/auto/selftests/tst_selftests.cpp index cb5cd077b6..138e47927f 100644 --- a/tests/auto/selftests/tst_selftests.cpp +++ b/tests/auto/selftests/tst_selftests.cpp @@ -173,12 +173,10 @@ Logger::Logger(QString const& _name, QString const& _testdata_suffix, QStringLis static QList allLoggers() { return QList() - << Logger("plain", "txt", QStringList()) - << Logger("xml", "xml", QStringList() << "-xml") - << Logger("xml flush", "xml", QStringList() << "-xml" << "-flush") - << Logger("xunitxml", "xunitxml", QStringList() << "-xunitxml") - << Logger("lightxml", "lightxml", QStringList() << "-lightxml") - << Logger("lightxml flush", "lightxml", QStringList() << "-lightxml" << "-flush") + << Logger("plain", "txt", QStringList()) + << Logger("xml", "xml", QStringList() << "-xml") + << Logger("xunitxml", "xunitxml", QStringList() << "-xunitxml") + << Logger("lightxml", "lightxml", QStringList() << "-lightxml") ; } -- cgit v1.2.3 From d88b335d08bdf67edd21310f8202a3e62cbde085 Mon Sep 17 00:00:00 2001 From: Jason McDonald Date: Wed, 31 Aug 2011 17:08:28 +1000 Subject: Simplify qtestlib logging code, part 2 Rename the QTestLogger class to QXunitTestLogger. Change-Id: I7b93f9de4f4744e53997ccc001a745c36f375599 Reviewed-on: http://codereview.qt.nokia.com/3924 Reviewed-by: Qt Sanity Bot Reviewed-by: Rohan McGovern --- src/testlib/qtestbasicstreamer.cpp | 6 +- src/testlib/qtestbasicstreamer.h | 8 +- src/testlib/qtestlog.cpp | 4 +- src/testlib/qtestlogger.cpp | 321 ------------------------------------- src/testlib/qtestlogger_p.h | 96 ----------- src/testlib/qtestxunitstreamer.cpp | 2 +- src/testlib/qtestxunitstreamer.h | 4 +- src/testlib/qxunittestlogger.cpp | 321 +++++++++++++++++++++++++++++++++++++ src/testlib/qxunittestlogger_p.h | 96 +++++++++++ src/testlib/testlib.pro | 2 +- 10 files changed, 430 insertions(+), 430 deletions(-) delete mode 100644 src/testlib/qtestlogger.cpp delete mode 100644 src/testlib/qtestlogger_p.h create mode 100644 src/testlib/qxunittestlogger.cpp create mode 100644 src/testlib/qxunittestlogger_p.h diff --git a/src/testlib/qtestbasicstreamer.cpp b/src/testlib/qtestbasicstreamer.cpp index d371b4d08e..1d272ea2c5 100644 --- a/src/testlib/qtestbasicstreamer.cpp +++ b/src/testlib/qtestbasicstreamer.cpp @@ -40,7 +40,7 @@ ****************************************************************************/ #include "qtestbasicstreamer.h" -#include "qtestlogger_p.h" +#include "qxunittestlogger_p.h" #include "qtestelement.h" #include "qtestelementattribute.h" #include "qtestassert.h" @@ -54,7 +54,7 @@ QT_BEGIN_NAMESPACE -QTestBasicStreamer::QTestBasicStreamer(QTestLogger *logger) +QTestBasicStreamer::QTestBasicStreamer(QXunitTestLogger *logger) :testLogger(logger) { QTEST_ASSERT(testLogger); @@ -156,7 +156,7 @@ void QTestBasicStreamer::outputString(const char *msg) const testLogger->outputString(msg); } -QTestLogger *QTestBasicStreamer::logger() const +QXunitTestLogger *QTestBasicStreamer::logger() const { return testLogger; } diff --git a/src/testlib/qtestbasicstreamer.h b/src/testlib/qtestbasicstreamer.h index 04bc40638f..d53db06225 100644 --- a/src/testlib/qtestbasicstreamer.h +++ b/src/testlib/qtestbasicstreamer.h @@ -52,20 +52,20 @@ QT_MODULE(Test) class QTestElement; class QTestElementAttribute; -class QTestLogger; +class QXunitTestLogger; struct QTestCharBuffer; class QTestBasicStreamer { public: - QTestBasicStreamer(QTestLogger *logger); + QTestBasicStreamer(QXunitTestLogger *logger); virtual ~QTestBasicStreamer(); virtual void output(QTestElement *element) const; void outputString(const char *msg) const; - QTestLogger *logger() const; + QXunitTestLogger *logger() const; protected: virtual void formatStart(const QTestElement *element, QTestCharBuffer *formatted) const; @@ -77,7 +77,7 @@ class QTestBasicStreamer virtual void outputElementAttributes(const QTestElement *element, QTestElementAttribute *attribute) const; private: - QTestLogger *testLogger; + QXunitTestLogger *testLogger; }; QT_END_NAMESPACE diff --git a/src/testlib/qtestlog.cpp b/src/testlib/qtestlog.cpp index 77ddae65be..410972db0f 100644 --- a/src/testlib/qtestlog.cpp +++ b/src/testlib/qtestlog.cpp @@ -45,7 +45,7 @@ #include "QtTest/private/qtestresult_p.h" #include "QtTest/private/qabstracttestlogger_p.h" #include "QtTest/private/qplaintestlogger_p.h" -#include "QtTest/private/qtestlogger_p.h" +#include "QtTest/private/qxunittestlogger_p.h" #include "QtTest/private/qxmltestlogger_p.h" #include #include @@ -178,7 +178,7 @@ namespace QTest { QTest::testLogger = new QXmlTestLogger(QXmlTestLogger::Light); break; case QTestLog::XunitXML: - QTest::testLogger = new QTestLogger(); + QTest::testLogger = new QXunitTestLogger(); break; } } diff --git a/src/testlib/qtestlogger.cpp b/src/testlib/qtestlogger.cpp deleted file mode 100644 index 1665dde6e7..0000000000 --- a/src/testlib/qtestlogger.cpp +++ /dev/null @@ -1,321 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtTest module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qtestlogger_p.h" -#include "qtestelement.h" -#include "qtestxunitstreamer.h" - -#include "QtTest/qtestcase.h" -#include "QtTest/private/qtestresult_p.h" -#include "QtTest/private/qbenchmark_p.h" - -#include - -QT_BEGIN_NAMESPACE - -QTestLogger::QTestLogger() - : listOfTestcases(0) - , currentLogElement(0) - , errorLogElement(0) - , logFormatter(0) - , testCounter(0) - , failureCounter(0) - , errorCounter(0) -{ -} - -QTestLogger::~QTestLogger() -{ - delete currentLogElement; - delete logFormatter; -} - -void QTestLogger::startLogging(const char *filename) -{ - QAbstractTestLogger::startLogging(filename); - - logFormatter = new QTestXunitStreamer(this); - delete errorLogElement; - errorLogElement = new QTestElement(QTest::LET_SystemError); -} - -void QTestLogger::stopLogging() -{ - QTestElement *iterator = listOfTestcases; - - char buf[10]; - - currentLogElement = new QTestElement(QTest::LET_TestSuite); - currentLogElement->addAttribute(QTest::AI_Name, QTestResult::currentTestObjectName()); - - QTest::qt_snprintf(buf, sizeof(buf), "%i", testCounter); - currentLogElement->addAttribute(QTest::AI_Tests, buf); - - QTest::qt_snprintf(buf, sizeof(buf), "%i", failureCounter); - currentLogElement->addAttribute(QTest::AI_Failures, buf); - - QTest::qt_snprintf(buf, sizeof(buf), "%i", errorCounter); - currentLogElement->addAttribute(QTest::AI_Errors, buf); - - QTestElement *property; - QTestElement *properties = new QTestElement(QTest::LET_Properties); - - property = new QTestElement(QTest::LET_Property); - property->addAttribute(QTest::AI_Name, "QTestVersion"); - property->addAttribute(QTest::AI_PropertyValue, QTEST_VERSION_STR); - properties->addLogElement(property); - - property = new QTestElement(QTest::LET_Property); - property->addAttribute(QTest::AI_Name, "QtVersion"); - property->addAttribute(QTest::AI_PropertyValue, qVersion()); - properties->addLogElement(property); - - currentLogElement->addLogElement(properties); - - currentLogElement->addLogElement(iterator); - - /* For correct indenting, make sure every testcase knows its parent */ - QTestElement* testcase = iterator; - while (testcase) { - testcase->setParent(currentLogElement); - testcase = testcase->nextElement(); - } - - currentLogElement->addLogElement(errorLogElement); - - QTestElement *it = currentLogElement; - logFormatter->output(it); - - QAbstractTestLogger::stopLogging(); -} - -void QTestLogger::enterTestFunction(const char *function) -{ - currentLogElement = new QTestElement(QTest::LET_TestCase); - currentLogElement->addAttribute(QTest::AI_Name, function); - currentLogElement->addToList(&listOfTestcases); - - ++testCounter; -} - -void QTestLogger::leaveTestFunction() -{ -} - -void QTestLogger::addIncident(IncidentTypes type, const char *description, - const char *file, int line) -{ - const char *typeBuf = 0; - char buf[100]; - - switch (type) { - case QAbstractTestLogger::XPass: - ++failureCounter; - typeBuf = "xpass"; - break; - case QAbstractTestLogger::Pass: - typeBuf = "pass"; - break; - case QAbstractTestLogger::XFail: - typeBuf = "xfail"; - break; - case QAbstractTestLogger::Fail: - ++failureCounter; - typeBuf = "fail"; - break; - default: - typeBuf = "??????"; - break; - } - - if (type == QAbstractTestLogger::Fail || type == QAbstractTestLogger::XPass) { - QTestElement *failureElement = new QTestElement(QTest::LET_Failure); - failureElement->addAttribute(QTest::AI_Result, typeBuf); - if(file) - failureElement->addAttribute(QTest::AI_File, file); - else - failureElement->addAttribute(QTest::AI_File, ""); - QTest::qt_snprintf(buf, sizeof(buf), "%i", line); - failureElement->addAttribute(QTest::AI_Line, buf); - failureElement->addAttribute(QTest::AI_Description, description); - addTag(failureElement); - currentLogElement->addLogElement(failureElement); - } - - /* - Only one result can be shown for the whole testfunction. - Check if we currently have a result, and if so, overwrite it - iff the new result is worse. - */ - QTestElementAttribute* resultAttr = - const_cast(currentLogElement->attribute(QTest::AI_Result)); - if (resultAttr) { - const char* oldResult = resultAttr->value(); - bool overwrite = false; - if (!strcmp(oldResult, "pass")) { - overwrite = true; - } - else if (!strcmp(oldResult, "xfail")) { - overwrite = (type == QAbstractTestLogger::XPass || type == QAbstractTestLogger::Fail); - } - else if (!strcmp(oldResult, "xpass")) { - overwrite = (type == QAbstractTestLogger::Fail); - } - if (overwrite) { - resultAttr->setPair(QTest::AI_Result, typeBuf); - } - } - else { - currentLogElement->addAttribute(QTest::AI_Result, typeBuf); - } - - if(file) - currentLogElement->addAttribute(QTest::AI_File, file); - else - currentLogElement->addAttribute(QTest::AI_File, ""); - - QTest::qt_snprintf(buf, sizeof(buf), "%i", line); - currentLogElement->addAttribute(QTest::AI_Line, buf); - - /* - Since XFAIL does not add a failure to the testlog in xunitxml, add a message, so we still - have some information about the expected failure. - */ - if (type == QAbstractTestLogger::XFail) { - QTestLogger::addMessage(QAbstractTestLogger::Info, description, file, line); - } -} - -void QTestLogger::addBenchmarkResult(const QBenchmarkResult &result) -{ - QTestElement *benchmarkElement = new QTestElement(QTest::LET_Benchmark); - - benchmarkElement->addAttribute( - QTest::AI_Metric, - QTest::benchmarkMetricName(QBenchmarkTestMethodData::current->result.metric)); - benchmarkElement->addAttribute(QTest::AI_Tag, result.context.tag.toAscii().data()); - benchmarkElement->addAttribute(QTest::AI_Value, QByteArray::number(result.value).constData()); - - char buf[100]; - QTest::qt_snprintf(buf, sizeof(buf), "%i", result.iterations); - benchmarkElement->addAttribute(QTest::AI_Iterations, buf); - currentLogElement->addLogElement(benchmarkElement); -} - -void QTestLogger::addTag(QTestElement* element) -{ - const char *tag = QTestResult::currentDataTag(); - const char *gtag = QTestResult::currentGlobalDataTag(); - const char *filler = (tag && gtag) ? ":" : ""; - if ((!tag || !tag[0]) && (!gtag || !gtag[0])) { - return; - } - - if (!tag) { - tag = ""; - } - if (!gtag) { - gtag = ""; - } - - QTestCharBuffer buf; - QTest::qt_asprintf(&buf, "%s%s%s", gtag, filler, tag); - element->addAttribute(QTest::AI_Tag, buf.constData()); -} - -void QTestLogger::addMessage(MessageTypes type, const char *message, const char *file, int line) -{ - QTestElement *errorElement = new QTestElement(QTest::LET_Error); - const char *typeBuf = 0; - - switch (type) { - case QAbstractTestLogger::Warn: - typeBuf = "warn"; - break; - case QAbstractTestLogger::QSystem: - typeBuf = "system"; - break; - case QAbstractTestLogger::QDebug: - typeBuf = "qdebug"; - break; - case QAbstractTestLogger::QWarning: - typeBuf = "qwarn"; - break; - case QAbstractTestLogger::QFatal: - typeBuf = "qfatal"; - break; - case QAbstractTestLogger::Skip: - typeBuf = "skip"; - break; - case QAbstractTestLogger::Info: - typeBuf = "info"; - break; - default: - typeBuf = "??????"; - break; - } - - errorElement->addAttribute(QTest::AI_Type, typeBuf); - errorElement->addAttribute(QTest::AI_Description, message); - addTag(errorElement); - - if(file) - errorElement->addAttribute(QTest::AI_File, file); - else - errorElement->addAttribute(QTest::AI_File, ""); - - char buf[100]; - QTest::qt_snprintf(buf, sizeof(buf), "%i", line); - errorElement->addAttribute(QTest::AI_Line, buf); - - currentLogElement->addLogElement(errorElement); - ++errorCounter; - - // Also add the message to the system error log (i.e. stderr), if one exists - if (errorLogElement) { - QTestElement *systemErrorElement = new QTestElement(QTest::LET_Error); - systemErrorElement->addAttribute(QTest::AI_Description, message); - errorLogElement->addLogElement(systemErrorElement); - } -} - -QT_END_NAMESPACE - diff --git a/src/testlib/qtestlogger_p.h b/src/testlib/qtestlogger_p.h deleted file mode 100644 index b9c9f2b6b6..0000000000 --- a/src/testlib/qtestlogger_p.h +++ /dev/null @@ -1,96 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtTest module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QTESTLOGGER_P_H -#define QTESTLOGGER_P_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -#include - -QT_BEGIN_NAMESPACE - -class QTestBasicStreamer; -class QTestElement; - -class QTestLogger : public QAbstractTestLogger -{ - public: - QTestLogger(); - ~QTestLogger(); - - void startLogging(const char *filename); - void stopLogging(); - - void enterTestFunction(const char *function); - void leaveTestFunction(); - - void addIncident(IncidentTypes type, const char *description, - const char *file = 0, int line = 0); - void addBenchmarkResult(const QBenchmarkResult &result); - void addTag(QTestElement* element); - - void addMessage(MessageTypes type, const char *message, - const char *file = 0, int line = 0); - - private: - QTestElement *listOfTestcases; - QTestElement *currentLogElement; - QTestElement *errorLogElement; - QTestBasicStreamer *logFormatter; - - int testCounter; - int failureCounter; - int errorCounter; -}; - -QT_END_NAMESPACE - -#endif // QTESTLOGGER_P_H diff --git a/src/testlib/qtestxunitstreamer.cpp b/src/testlib/qtestxunitstreamer.cpp index fb9699eef1..93b40de1cf 100644 --- a/src/testlib/qtestxunitstreamer.cpp +++ b/src/testlib/qtestxunitstreamer.cpp @@ -48,7 +48,7 @@ QT_BEGIN_NAMESPACE -QTestXunitStreamer::QTestXunitStreamer(QTestLogger *logger) +QTestXunitStreamer::QTestXunitStreamer(QXunitTestLogger *logger) : QTestBasicStreamer(logger) {} diff --git a/src/testlib/qtestxunitstreamer.h b/src/testlib/qtestxunitstreamer.h index 4d1cb2734a..4f2fc7f2da 100644 --- a/src/testlib/qtestxunitstreamer.h +++ b/src/testlib/qtestxunitstreamer.h @@ -50,12 +50,12 @@ QT_BEGIN_NAMESPACE QT_MODULE(Test) -class QTestLogger; +class QXunitTestLogger; class QTestXunitStreamer: public QTestBasicStreamer { public: - QTestXunitStreamer(QTestLogger *logger); + QTestXunitStreamer(QXunitTestLogger *logger); ~QTestXunitStreamer(); void formatStart(const QTestElement *element, QTestCharBuffer *formatted) const; diff --git a/src/testlib/qxunittestlogger.cpp b/src/testlib/qxunittestlogger.cpp new file mode 100644 index 0000000000..05a8c47c47 --- /dev/null +++ b/src/testlib/qxunittestlogger.cpp @@ -0,0 +1,321 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtTest module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qxunittestlogger_p.h" +#include "qtestelement.h" +#include "qtestxunitstreamer.h" + +#include "QtTest/qtestcase.h" +#include "QtTest/private/qtestresult_p.h" +#include "QtTest/private/qbenchmark_p.h" + +#include + +QT_BEGIN_NAMESPACE + +QXunitTestLogger::QXunitTestLogger() + : listOfTestcases(0) + , currentLogElement(0) + , errorLogElement(0) + , logFormatter(0) + , testCounter(0) + , failureCounter(0) + , errorCounter(0) +{ +} + +QXunitTestLogger::~QXunitTestLogger() +{ + delete currentLogElement; + delete logFormatter; +} + +void QXunitTestLogger::startLogging(const char *filename) +{ + QAbstractTestLogger::startLogging(filename); + + logFormatter = new QTestXunitStreamer(this); + delete errorLogElement; + errorLogElement = new QTestElement(QTest::LET_SystemError); +} + +void QXunitTestLogger::stopLogging() +{ + QTestElement *iterator = listOfTestcases; + + char buf[10]; + + currentLogElement = new QTestElement(QTest::LET_TestSuite); + currentLogElement->addAttribute(QTest::AI_Name, QTestResult::currentTestObjectName()); + + QTest::qt_snprintf(buf, sizeof(buf), "%i", testCounter); + currentLogElement->addAttribute(QTest::AI_Tests, buf); + + QTest::qt_snprintf(buf, sizeof(buf), "%i", failureCounter); + currentLogElement->addAttribute(QTest::AI_Failures, buf); + + QTest::qt_snprintf(buf, sizeof(buf), "%i", errorCounter); + currentLogElement->addAttribute(QTest::AI_Errors, buf); + + QTestElement *property; + QTestElement *properties = new QTestElement(QTest::LET_Properties); + + property = new QTestElement(QTest::LET_Property); + property->addAttribute(QTest::AI_Name, "QTestVersion"); + property->addAttribute(QTest::AI_PropertyValue, QTEST_VERSION_STR); + properties->addLogElement(property); + + property = new QTestElement(QTest::LET_Property); + property->addAttribute(QTest::AI_Name, "QtVersion"); + property->addAttribute(QTest::AI_PropertyValue, qVersion()); + properties->addLogElement(property); + + currentLogElement->addLogElement(properties); + + currentLogElement->addLogElement(iterator); + + /* For correct indenting, make sure every testcase knows its parent */ + QTestElement* testcase = iterator; + while (testcase) { + testcase->setParent(currentLogElement); + testcase = testcase->nextElement(); + } + + currentLogElement->addLogElement(errorLogElement); + + QTestElement *it = currentLogElement; + logFormatter->output(it); + + QAbstractTestLogger::stopLogging(); +} + +void QXunitTestLogger::enterTestFunction(const char *function) +{ + currentLogElement = new QTestElement(QTest::LET_TestCase); + currentLogElement->addAttribute(QTest::AI_Name, function); + currentLogElement->addToList(&listOfTestcases); + + ++testCounter; +} + +void QXunitTestLogger::leaveTestFunction() +{ +} + +void QXunitTestLogger::addIncident(IncidentTypes type, const char *description, + const char *file, int line) +{ + const char *typeBuf = 0; + char buf[100]; + + switch (type) { + case QAbstractTestLogger::XPass: + ++failureCounter; + typeBuf = "xpass"; + break; + case QAbstractTestLogger::Pass: + typeBuf = "pass"; + break; + case QAbstractTestLogger::XFail: + typeBuf = "xfail"; + break; + case QAbstractTestLogger::Fail: + ++failureCounter; + typeBuf = "fail"; + break; + default: + typeBuf = "??????"; + break; + } + + if (type == QAbstractTestLogger::Fail || type == QAbstractTestLogger::XPass) { + QTestElement *failureElement = new QTestElement(QTest::LET_Failure); + failureElement->addAttribute(QTest::AI_Result, typeBuf); + if(file) + failureElement->addAttribute(QTest::AI_File, file); + else + failureElement->addAttribute(QTest::AI_File, ""); + QTest::qt_snprintf(buf, sizeof(buf), "%i", line); + failureElement->addAttribute(QTest::AI_Line, buf); + failureElement->addAttribute(QTest::AI_Description, description); + addTag(failureElement); + currentLogElement->addLogElement(failureElement); + } + + /* + Only one result can be shown for the whole testfunction. + Check if we currently have a result, and if so, overwrite it + iff the new result is worse. + */ + QTestElementAttribute* resultAttr = + const_cast(currentLogElement->attribute(QTest::AI_Result)); + if (resultAttr) { + const char* oldResult = resultAttr->value(); + bool overwrite = false; + if (!strcmp(oldResult, "pass")) { + overwrite = true; + } + else if (!strcmp(oldResult, "xfail")) { + overwrite = (type == QAbstractTestLogger::XPass || type == QAbstractTestLogger::Fail); + } + else if (!strcmp(oldResult, "xpass")) { + overwrite = (type == QAbstractTestLogger::Fail); + } + if (overwrite) { + resultAttr->setPair(QTest::AI_Result, typeBuf); + } + } + else { + currentLogElement->addAttribute(QTest::AI_Result, typeBuf); + } + + if(file) + currentLogElement->addAttribute(QTest::AI_File, file); + else + currentLogElement->addAttribute(QTest::AI_File, ""); + + QTest::qt_snprintf(buf, sizeof(buf), "%i", line); + currentLogElement->addAttribute(QTest::AI_Line, buf); + + /* + Since XFAIL does not add a failure to the testlog in xunitxml, add a message, so we still + have some information about the expected failure. + */ + if (type == QAbstractTestLogger::XFail) { + QXunitTestLogger::addMessage(QAbstractTestLogger::Info, description, file, line); + } +} + +void QXunitTestLogger::addBenchmarkResult(const QBenchmarkResult &result) +{ + QTestElement *benchmarkElement = new QTestElement(QTest::LET_Benchmark); + + benchmarkElement->addAttribute( + QTest::AI_Metric, + QTest::benchmarkMetricName(QBenchmarkTestMethodData::current->result.metric)); + benchmarkElement->addAttribute(QTest::AI_Tag, result.context.tag.toAscii().data()); + benchmarkElement->addAttribute(QTest::AI_Value, QByteArray::number(result.value).constData()); + + char buf[100]; + QTest::qt_snprintf(buf, sizeof(buf), "%i", result.iterations); + benchmarkElement->addAttribute(QTest::AI_Iterations, buf); + currentLogElement->addLogElement(benchmarkElement); +} + +void QXunitTestLogger::addTag(QTestElement* element) +{ + const char *tag = QTestResult::currentDataTag(); + const char *gtag = QTestResult::currentGlobalDataTag(); + const char *filler = (tag && gtag) ? ":" : ""; + if ((!tag || !tag[0]) && (!gtag || !gtag[0])) { + return; + } + + if (!tag) { + tag = ""; + } + if (!gtag) { + gtag = ""; + } + + QTestCharBuffer buf; + QTest::qt_asprintf(&buf, "%s%s%s", gtag, filler, tag); + element->addAttribute(QTest::AI_Tag, buf.constData()); +} + +void QXunitTestLogger::addMessage(MessageTypes type, const char *message, const char *file, int line) +{ + QTestElement *errorElement = new QTestElement(QTest::LET_Error); + const char *typeBuf = 0; + + switch (type) { + case QAbstractTestLogger::Warn: + typeBuf = "warn"; + break; + case QAbstractTestLogger::QSystem: + typeBuf = "system"; + break; + case QAbstractTestLogger::QDebug: + typeBuf = "qdebug"; + break; + case QAbstractTestLogger::QWarning: + typeBuf = "qwarn"; + break; + case QAbstractTestLogger::QFatal: + typeBuf = "qfatal"; + break; + case QAbstractTestLogger::Skip: + typeBuf = "skip"; + break; + case QAbstractTestLogger::Info: + typeBuf = "info"; + break; + default: + typeBuf = "??????"; + break; + } + + errorElement->addAttribute(QTest::AI_Type, typeBuf); + errorElement->addAttribute(QTest::AI_Description, message); + addTag(errorElement); + + if(file) + errorElement->addAttribute(QTest::AI_File, file); + else + errorElement->addAttribute(QTest::AI_File, ""); + + char buf[100]; + QTest::qt_snprintf(buf, sizeof(buf), "%i", line); + errorElement->addAttribute(QTest::AI_Line, buf); + + currentLogElement->addLogElement(errorElement); + ++errorCounter; + + // Also add the message to the system error log (i.e. stderr), if one exists + if (errorLogElement) { + QTestElement *systemErrorElement = new QTestElement(QTest::LET_Error); + systemErrorElement->addAttribute(QTest::AI_Description, message); + errorLogElement->addLogElement(systemErrorElement); + } +} + +QT_END_NAMESPACE + diff --git a/src/testlib/qxunittestlogger_p.h b/src/testlib/qxunittestlogger_p.h new file mode 100644 index 0000000000..5c295dfaa1 --- /dev/null +++ b/src/testlib/qxunittestlogger_p.h @@ -0,0 +1,96 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtTest module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QTESTLOGGER_P_H +#define QTESTLOGGER_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include + +QT_BEGIN_NAMESPACE + +class QTestBasicStreamer; +class QTestElement; + +class QXunitTestLogger : public QAbstractTestLogger +{ + public: + QXunitTestLogger(); + ~QXunitTestLogger(); + + void startLogging(const char *filename); + void stopLogging(); + + void enterTestFunction(const char *function); + void leaveTestFunction(); + + void addIncident(IncidentTypes type, const char *description, + const char *file = 0, int line = 0); + void addBenchmarkResult(const QBenchmarkResult &result); + void addTag(QTestElement* element); + + void addMessage(MessageTypes type, const char *message, + const char *file = 0, int line = 0); + + private: + QTestElement *listOfTestcases; + QTestElement *currentLogElement; + QTestElement *errorLogElement; + QTestBasicStreamer *logFormatter; + + int testCounter; + int failureCounter; + int errorCounter; +}; + +QT_END_NAMESPACE + +#endif // QTESTLOGGER_P_H diff --git a/src/testlib/testlib.pro b/src/testlib/testlib.pro index 4133472738..6ca67e3967 100644 --- a/src/testlib/testlib.pro +++ b/src/testlib/testlib.pro @@ -55,7 +55,7 @@ SOURCES = qtestcase.cpp \ qtestelementattribute.cpp \ qtestbasicstreamer.cpp \ qtestxunitstreamer.cpp \ - qtestlogger.cpp + qxunittestlogger.cpp DEFINES *= QT_NO_CAST_TO_ASCII \ QT_NO_CAST_FROM_ASCII \ QTESTLIB_MAKEDLL \ -- cgit v1.2.3 From 964793718fee83d46103acb5deb0bde4fa78a9af Mon Sep 17 00:00:00 2001 From: Jason McDonald Date: Wed, 31 Aug 2011 18:53:46 +1000 Subject: Simplify qtestlib logging code, part 3 Collapse the QTestBasicStreamer class into QTestXunitStreamer. Change-Id: I349b8db432fd45f9352084f60b36b460f3b61f6a Reviewed-on: http://codereview.qt.nokia.com/3925 Reviewed-by: Rohan McGovern --- src/testlib/qtestbasicstreamer.cpp | 165 ------------------------------------- src/testlib/qtestbasicstreamer.h | 87 ------------------- src/testlib/qtestxunitstreamer.cpp | 32 +++++-- src/testlib/qtestxunitstreamer.h | 12 ++- src/testlib/qxunittestlogger_p.h | 4 +- src/testlib/testlib.pro | 2 - src/tools/uic/qclass_lib_map.h | 1 - 7 files changed, 37 insertions(+), 266 deletions(-) delete mode 100644 src/testlib/qtestbasicstreamer.cpp delete mode 100644 src/testlib/qtestbasicstreamer.h diff --git a/src/testlib/qtestbasicstreamer.cpp b/src/testlib/qtestbasicstreamer.cpp deleted file mode 100644 index 1d272ea2c5..0000000000 --- a/src/testlib/qtestbasicstreamer.cpp +++ /dev/null @@ -1,165 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtTest module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qtestbasicstreamer.h" -#include "qxunittestlogger_p.h" -#include "qtestelement.h" -#include "qtestelementattribute.h" -#include "qtestassert.h" - -#include -#include - -#ifndef Q_OS_WIN -#include -#endif - -QT_BEGIN_NAMESPACE - -QTestBasicStreamer::QTestBasicStreamer(QXunitTestLogger *logger) - :testLogger(logger) -{ - QTEST_ASSERT(testLogger); -} - -QTestBasicStreamer::~QTestBasicStreamer() -{} - -void QTestBasicStreamer::formatStart(const QTestElement *element, QTestCharBuffer *formatted) const -{ - if(!element || !formatted ) - return; - formatted->data()[0] = '\0'; -} - -void QTestBasicStreamer::formatEnd(const QTestElement *element, QTestCharBuffer *formatted) const -{ - if(!element || !formatted ) - return; - formatted->data()[0] = '\0'; -} - -void QTestBasicStreamer::formatBeforeAttributes(const QTestElement *element, QTestCharBuffer *formatted) const -{ - if(!element || !formatted ) - return; - formatted->data()[0] = '\0'; -} - -void QTestBasicStreamer::formatAfterAttributes(const QTestElement *element, QTestCharBuffer *formatted) const -{ - if(!element || !formatted ) - return; - formatted->data()[0] = '\0'; -} - -void QTestBasicStreamer::formatAttributes(const QTestElement *, const QTestElementAttribute *attribute, QTestCharBuffer *formatted) const -{ - if(!attribute || !formatted ) - return; - formatted->data()[0] = '\0'; -} - -void QTestBasicStreamer::output(QTestElement *element) const -{ - if(!element) - return; - - outputElements(element); -} - -void QTestBasicStreamer::outputElements(QTestElement *element, bool) const -{ - QTestCharBuffer buf; - bool hasChildren; - /* - Elements are in reverse order of occurrence, so start from the end and work - our way backwards. - */ - while (element && element->nextElement()) { - element = element->nextElement(); - } - while (element) { - hasChildren = element->childElements(); - - formatStart(element, &buf); - outputString(buf.data()); - - formatBeforeAttributes(element, &buf); - outputString(buf.data()); - - outputElementAttributes(element, element->attributes()); - - formatAfterAttributes(element, &buf); - outputString(buf.data()); - - if(hasChildren) - outputElements(element->childElements(), true); - - formatEnd(element, &buf); - outputString(buf.data()); - - element = element->previousElement(); - } -} - -void QTestBasicStreamer::outputElementAttributes(const QTestElement* element, QTestElementAttribute *attribute) const -{ - QTestCharBuffer buf; - while(attribute){ - formatAttributes(element, attribute, &buf); - outputString(buf.data()); - attribute = attribute->nextElement(); - } -} - -void QTestBasicStreamer::outputString(const char *msg) const -{ - testLogger->outputString(msg); -} - -QXunitTestLogger *QTestBasicStreamer::logger() const -{ - return testLogger; -} - -QT_END_NAMESPACE - diff --git a/src/testlib/qtestbasicstreamer.h b/src/testlib/qtestbasicstreamer.h deleted file mode 100644 index d53db06225..0000000000 --- a/src/testlib/qtestbasicstreamer.h +++ /dev/null @@ -1,87 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtTest module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QTESTBASICSTREAMER_H -#define QTESTBASICSTREAMER_H - -#include - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Test) - -class QTestElement; -class QTestElementAttribute; -class QXunitTestLogger; -struct QTestCharBuffer; - -class QTestBasicStreamer -{ - public: - QTestBasicStreamer(QXunitTestLogger *logger); - virtual ~QTestBasicStreamer(); - - virtual void output(QTestElement *element) const; - - void outputString(const char *msg) const; - - QXunitTestLogger *logger() const; - - protected: - virtual void formatStart(const QTestElement *element, QTestCharBuffer *formatted) const; - virtual void formatEnd(const QTestElement *element, QTestCharBuffer *formatted) const; - virtual void formatBeforeAttributes(const QTestElement *element, QTestCharBuffer *formatted) const; - virtual void formatAfterAttributes(const QTestElement *element, QTestCharBuffer *formatted) const; - virtual void formatAttributes(const QTestElement *element, const QTestElementAttribute *attribute, QTestCharBuffer *formatted) const; - virtual void outputElements(QTestElement *element, bool isChildElement = false) const; - virtual void outputElementAttributes(const QTestElement *element, QTestElementAttribute *attribute) const; - - private: - QXunitTestLogger *testLogger; -}; - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif diff --git a/src/testlib/qtestxunitstreamer.cpp b/src/testlib/qtestxunitstreamer.cpp index 93b40de1cf..f70945add0 100644 --- a/src/testlib/qtestxunitstreamer.cpp +++ b/src/testlib/qtestxunitstreamer.cpp @@ -40,7 +40,10 @@ ****************************************************************************/ #include "qtestxunitstreamer.h" +#include "qxunittestlogger_p.h" #include "qtestelement.h" +#include "qtestelementattribute.h" +#include "qtestassert.h" #include "QtTest/private/qtestlog_p.h" #include "QtTest/private/qtestresult_p.h" @@ -49,8 +52,10 @@ QT_BEGIN_NAMESPACE QTestXunitStreamer::QTestXunitStreamer(QXunitTestLogger *logger) - : QTestBasicStreamer(logger) -{} + : testLogger(logger) +{ + QTEST_ASSERT(testLogger); +} QTestXunitStreamer::~QTestXunitStreamer() {} @@ -165,8 +170,10 @@ void QTestXunitStreamer::formatAfterAttributes(const QTestElement *element, QTes void QTestXunitStreamer::output(QTestElement *element) const { + QTEST_ASSERT(element); + outputString("\n"); - QTestBasicStreamer::output(element); + outputElements(element); } void QTestXunitStreamer::outputElements(QTestElement *element, bool) const @@ -187,9 +194,6 @@ void QTestXunitStreamer::outputElements(QTestElement *element, bool) const formatStart(element, &buf); outputString(buf.data()); - formatBeforeAttributes(element, &buf); - outputString(buf.data()); - outputElementAttributes(element, element->attributes()); formatAfterAttributes(element, &buf); @@ -205,5 +209,19 @@ void QTestXunitStreamer::outputElements(QTestElement *element, bool) const } } -QT_END_NAMESPACE +void QTestXunitStreamer::outputElementAttributes(const QTestElement* element, QTestElementAttribute *attribute) const +{ + QTestCharBuffer buf; + while(attribute){ + formatAttributes(element, attribute, &buf); + outputString(buf.data()); + attribute = attribute->nextElement(); + } +} +void QTestXunitStreamer::outputString(const char *msg) const +{ + testLogger->outputString(msg); +} + +QT_END_NAMESPACE diff --git a/src/testlib/qtestxunitstreamer.h b/src/testlib/qtestxunitstreamer.h index 4f2fc7f2da..127c9b1780 100644 --- a/src/testlib/qtestxunitstreamer.h +++ b/src/testlib/qtestxunitstreamer.h @@ -42,7 +42,7 @@ #ifndef QTESTXUNITSTREAMER_H #define QTESTXUNITSTREAMER_H -#include +#include QT_BEGIN_HEADER @@ -50,9 +50,12 @@ QT_BEGIN_NAMESPACE QT_MODULE(Test) +class QTestElement; +class QTestElementAttribute; class QXunitTestLogger; +struct QTestCharBuffer; -class QTestXunitStreamer: public QTestBasicStreamer +class QTestXunitStreamer { public: QTestXunitStreamer(QXunitTestLogger *logger); @@ -64,10 +67,15 @@ class QTestXunitStreamer: public QTestBasicStreamer void formatAttributes(const QTestElement *element, const QTestElementAttribute *attribute, QTestCharBuffer *formatted) const; void output(QTestElement *element) const; void outputElements(QTestElement *element, bool isChildElement = false) const; + void outputElementAttributes(const QTestElement *element, QTestElementAttribute *attribute) const; + + void outputString(const char *msg) const; private: void displayXunitXmlHeader() const; static void indentForElement(const QTestElement* element, char* buf, int size); + + QXunitTestLogger *testLogger; }; QT_END_NAMESPACE diff --git a/src/testlib/qxunittestlogger_p.h b/src/testlib/qxunittestlogger_p.h index 5c295dfaa1..0607504310 100644 --- a/src/testlib/qxunittestlogger_p.h +++ b/src/testlib/qxunittestlogger_p.h @@ -57,7 +57,7 @@ QT_BEGIN_NAMESPACE -class QTestBasicStreamer; +class QTestXunitStreamer; class QTestElement; class QXunitTestLogger : public QAbstractTestLogger @@ -84,7 +84,7 @@ class QXunitTestLogger : public QAbstractTestLogger QTestElement *listOfTestcases; QTestElement *currentLogElement; QTestElement *errorLogElement; - QTestBasicStreamer *logFormatter; + QTestXunitStreamer *logFormatter; int testCounter; int failureCounter; diff --git a/src/testlib/testlib.pro b/src/testlib/testlib.pro index 6ca67e3967..d4dec9660e 100644 --- a/src/testlib/testlib.pro +++ b/src/testlib/testlib.pro @@ -18,7 +18,6 @@ HEADERS = qbenchmark.h \ qsignalspy.h \ qtestaccessible.h \ qtestassert.h \ - qtestbasicstreamer.h \ qtestcase.h \ qtestcoreelement.h \ qtestcorelist.h \ @@ -53,7 +52,6 @@ SOURCES = qtestcase.cpp \ qbenchmarkmetric.cpp \ qtestelement.cpp \ qtestelementattribute.cpp \ - qtestbasicstreamer.cpp \ qtestxunitstreamer.cpp \ qxunittestlogger.cpp DEFINES *= QT_NO_CAST_TO_ASCII \ diff --git a/src/tools/uic/qclass_lib_map.h b/src/tools/uic/qclass_lib_map.h index a4b71defd0..cf5a53deff 100644 --- a/src/tools/uic/qclass_lib_map.h +++ b/src/tools/uic/qclass_lib_map.h @@ -514,7 +514,6 @@ QT_CLASS_LIB(QTest, QtTest, qtest.h) QT_CLASS_LIB(QtTestGui, QtTest, qtest_gui.h) QT_CLASS_LIB(QTestAccessibilityEvent, QtTest, qtestaccessible.h) QT_CLASS_LIB(QTestAccessibility, QtTest, qtestaccessible.h) -QT_CLASS_LIB(QTestBasicStreamer, QtTest, qtestbasicstreamer.h) QT_CLASS_LIB(QTestCoreElement, QtTest, qtestcoreelement.h) QT_CLASS_LIB(QTestCoreList, QtTest, qtestcorelist.h) QT_CLASS_LIB(QTestData, QtTest, qtestdata.h) -- cgit v1.2.3 From 25a0cf881e6ca6dc8bd969e7047c3967796fcd94 Mon Sep 17 00:00:00 2001 From: Aaron McCarthy Date: Tue, 30 Aug 2011 10:50:55 +1000 Subject: Fix inclusion of .qmake.cache for modules with config tests. Qt modules with config tests generate a module level .qmake.cache with the results of the config tests. The existance of this file prevents qmake from walking up the directory tree and finding the Qt global cache file. This results in the system build not working as expected. For example running 'make' in the module would only build the contents of src and skip tests and examples. Fixed by adding a include statement to the end of the config test generated .qmake.cache. Change-Id: I68a5f2a96f4ee02076b6457ae085f45d894cd4ed Reviewed-on: http://codereview.qt.nokia.com/3830 Reviewed-by: Qt Sanity Bot Reviewed-by: Michael Goddard --- bin/qtmodule-configtests | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/bin/qtmodule-configtests b/bin/qtmodule-configtests index ab03908c84..4b4c5ae96c 100755 --- a/bin/qtmodule-configtests +++ b/bin/qtmodule-configtests @@ -299,9 +299,10 @@ if (abs_path($out_basedir) ne abs_path($qtbasedir)) { # Generate the new contents my $newContents = $existingContents; - # Strip out any existing config test results - $newContents =~ s/^config_test_.*$//gms; - $newContents =~ s/^# Compile time test results.*$//gms; + # Strip out any existing config test results or include statements + $newContents =~ s/^config_test_[^\$]*$//gm; + $newContents =~ s/^# Compile time test results[^\$]*$//gm; + $newContents =~ s/include\(\$\$PWD\/..\/.qmake.cache\)$//gm; # Add any remaining content and make sure we start on a new line if ($newContents and chop $newContents ne '\n') { @@ -318,6 +319,12 @@ if (abs_path($out_basedir) ne abs_path($qtbasedir)) { } } + # Remove blank lines + $newContents =~ s/^[\s]*$//gms; + + # Include top level .qmake.cache + $newContents = $newContents . "include(\$\$PWD/../.qmake.cache)\n"; + # and open the file open my $cacheFileHandle, ">$qmakeCachePath" or die "Unable to open $qmakeCachePath for writing: $!\n"; -- cgit v1.2.3 From d90da5d99134a5f89b25c93cfe2d15f4bc5ed0e5 Mon Sep 17 00:00:00 2001 From: Jason McDonald Date: Thu, 1 Sep 2011 11:13:14 +1000 Subject: Remove QXmlTestLogger constructor default param This class is never constructed with the parameter defaulted. Change-Id: If9c3f6562da1e48635a9cf5332bee7e9641255fa Reviewed-on: http://codereview.qt.nokia.com/4021 Reviewed-by: Qt Sanity Bot Reviewed-by: Rohan McGovern --- src/testlib/qxmltestlogger_p.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/testlib/qxmltestlogger_p.h b/src/testlib/qxmltestlogger_p.h index c08f5e469e..5a3fb27d78 100644 --- a/src/testlib/qxmltestlogger_p.h +++ b/src/testlib/qxmltestlogger_p.h @@ -63,7 +63,7 @@ class QXmlTestLogger : public QAbstractTestLogger public: enum XmlMode { Complete = 0, Light }; - QXmlTestLogger(XmlMode mode = Complete); + QXmlTestLogger(XmlMode mode); ~QXmlTestLogger(); void startLogging(const char *filename); -- cgit v1.2.3 From 9c51bd4fc83a2ee5f3e88c49a77e7eb5c50b29da Mon Sep 17 00:00:00 2001 From: Jason McDonald Date: Thu, 1 Sep 2011 14:24:53 +1000 Subject: Fix various trivial formatting issues. Change-Id: Ifa2a2dd2aa26dab178ec1334376db42fc3ebb355 Reviewed-on: http://codereview.qt.nokia.com/4029 Reviewed-by: Rohan McGovern --- src/testlib/qbenchmark.cpp | 12 +++++------ src/testlib/qbenchmark_p.h | 4 ++-- src/testlib/qbenchmarkevent_p.h | 4 ++-- src/testlib/qbenchmarkmeasurement.cpp | 22 +++++++++---------- src/testlib/qbenchmarkmeasurement_p.h | 4 ++-- src/testlib/qbenchmarkmetric.cpp | 2 +- src/testlib/qbenchmarkvalgrind.cpp | 8 +++---- src/testlib/qtestassert.h | 4 ++-- src/testlib/qtestcase.cpp | 40 +++++++++++++++++------------------ src/testlib/qtestcoreelement.h | 15 ++++++------- src/testlib/qtestcorelist.h | 6 +++--- src/testlib/qtestdata.cpp | 2 +- src/testlib/qtestelement.cpp | 10 ++++----- src/testlib/qtestelementattribute.cpp | 36 +++++++++++++++---------------- src/testlib/qtestkeyboard.h | 2 +- src/testlib/qtestmouse.h | 2 +- src/testlib/qtestxunitstreamer.cpp | 16 +++++++------- src/testlib/qxmltestlogger.cpp | 2 +- src/testlib/qxunittestlogger.cpp | 6 +++--- 19 files changed, 96 insertions(+), 101 deletions(-) diff --git a/src/testlib/qbenchmark.cpp b/src/testlib/qbenchmark.cpp index 2e8fa1ee99..8894d41bee 100644 --- a/src/testlib/qbenchmark.cpp +++ b/src/testlib/qbenchmark.cpp @@ -119,7 +119,6 @@ QBenchmarkTestMethodData *QBenchmarkTestMethodData::current; QBenchmarkTestMethodData::QBenchmarkTestMethodData() :resultAccepted(false), runOnce(false), iterationCount(-1) { - } QBenchmarkTestMethodData::~QBenchmarkTestMethodData() @@ -134,7 +133,6 @@ void QBenchmarkTestMethodData::beginDataRun() void QBenchmarkTestMethodData::endDataRun() { - } int QBenchmarkTestMethodData::adjustIterationCount(int suggestion) @@ -164,7 +162,7 @@ void QBenchmarkTestMethodData::setResult( accepted = true; } - // Test the result directly without calling the measurer if the minimum time + // Test the result directly without calling the measurer if the minimum time // has been specified on the command line with -minimumvalue. else if (QBenchmarkGlobalData::current->walltimeMinimum != -1) accepted = (value > QBenchmarkGlobalData::current->walltimeMinimum); @@ -196,7 +194,7 @@ QTest::QBenchmarkIterationController::QBenchmarkIterationController(RunMode runM { i = 0; if (runMode == RunOnce) - QBenchmarkTestMethodData::current->runOnce = true; + QBenchmarkTestMethodData::current->runOnce = true; QTest::beginBenchmarkMeasurement(); } @@ -265,16 +263,16 @@ void QTest::beginBenchmarkMeasurement() quint64 QTest::endBenchmarkMeasurement() { // the clock is ticking before the line below, don't add code here. - return QBenchmarkGlobalData::current->measurer->stop(); + return QBenchmarkGlobalData::current->measurer->stop(); } /*! Sets the benchmark result for this test function to \a result. - + Use this function if you want to report benchmark results without using the QBENCHMARK macro. Use \a metric to specify how QTestLib should interpret the results. - + The context for the result will be the test function name and any data tag from the _data function. This function can only be called once in each test function, subsequent calls will replace the diff --git a/src/testlib/qbenchmark_p.h b/src/testlib/qbenchmark_p.h index e5e07c0035..36e4b35493 100644 --- a/src/testlib/qbenchmark_p.h +++ b/src/testlib/qbenchmark_p.h @@ -58,7 +58,7 @@ #include #if (defined(Q_OS_LINUX) || defined Q_OS_MAC) && !defined(QT_NO_PROCESS) -#define QTESTLIB_USE_VALGRIND +#define QTESTLIB_USE_VALGRIND #else #undef QTESTLIB_USE_VALGRIND #endif @@ -119,7 +119,7 @@ public: , valid(true) { } - bool operator<(const QBenchmarkResult &other) const + bool operator<(const QBenchmarkResult &other) const { return (value / iterations) < (other.value / other.iterations); } diff --git a/src/testlib/qbenchmarkevent_p.h b/src/testlib/qbenchmarkevent_p.h index fc0729e82f..2cf17ea6a2 100644 --- a/src/testlib/qbenchmarkevent_p.h +++ b/src/testlib/qbenchmarkevent_p.h @@ -69,12 +69,12 @@ public: bool isMeasurementAccepted(qint64 measurement); int adjustIterationCount(int suggestion); int adjustMedianCount(int suggestion); - bool repeatCount() { return 1; } + bool repeatCount() { return 1; } QTest::QBenchmarkMetric metricType(); static bool eventCountingMechanism(void *message); static qint64 eventCounter; }; QT_END_NAMESPACE - + #endif // QBENCHMARKEVENT_H diff --git a/src/testlib/qbenchmarkmeasurement.cpp b/src/testlib/qbenchmarkmeasurement.cpp index 4aad71da34..2c14f5d3fe 100644 --- a/src/testlib/qbenchmarkmeasurement.cpp +++ b/src/testlib/qbenchmarkmeasurement.cpp @@ -60,7 +60,7 @@ qint64 QBenchmarkTimeMeasurer::checkpoint() } qint64 QBenchmarkTimeMeasurer::stop() -{ +{ return time.elapsed(); } @@ -70,8 +70,8 @@ bool QBenchmarkTimeMeasurer::isMeasurementAccepted(qint64 measurement) } int QBenchmarkTimeMeasurer::adjustIterationCount(int suggestion) -{ - return suggestion; +{ + return suggestion; } bool QBenchmarkTimeMeasurer::needsWarmupIteration() @@ -80,8 +80,8 @@ bool QBenchmarkTimeMeasurer::needsWarmupIteration() } int QBenchmarkTimeMeasurer::adjustMedianCount(int) -{ - return 1; +{ + return 1; } QTest::QBenchmarkMetric QBenchmarkTimeMeasurer::metricType() @@ -114,18 +114,18 @@ bool QBenchmarkTickMeasurer::isMeasurementAccepted(qint64) } int QBenchmarkTickMeasurer::adjustIterationCount(int) -{ - return 1; +{ + return 1; } int QBenchmarkTickMeasurer::adjustMedianCount(int) -{ - return 1; +{ + return 1; } bool QBenchmarkTickMeasurer::needsWarmupIteration() -{ - return true; +{ + return true; } QTest::QBenchmarkMetric QBenchmarkTickMeasurer::metricType() diff --git a/src/testlib/qbenchmarkmeasurement_p.h b/src/testlib/qbenchmarkmeasurement_p.h index 8242365f20..6d7d8c6c0d 100644 --- a/src/testlib/qbenchmarkmeasurement_p.h +++ b/src/testlib/qbenchmarkmeasurement_p.h @@ -72,8 +72,8 @@ public: virtual bool isMeasurementAccepted(qint64 measurement) = 0; virtual int adjustIterationCount(int suggestion) = 0; virtual int adjustMedianCount(int suggestion) = 0; - virtual bool repeatCount() { return 1; } - virtual bool needsWarmupIteration() { return false; } + virtual bool repeatCount() { return 1; } + virtual bool needsWarmupIteration() { return false; } virtual QTest::QBenchmarkMetric metricType() = 0; }; diff --git a/src/testlib/qbenchmarkmetric.cpp b/src/testlib/qbenchmarkmetric.cpp index d4efe84989..fb7f8f857a 100644 --- a/src/testlib/qbenchmarkmetric.cpp +++ b/src/testlib/qbenchmarkmetric.cpp @@ -46,7 +46,7 @@ \since 4.7 This enum lists all the things that can be benchmarked. - + \value FramesPerSecond Frames per second \value BitsPerSecond Bits per second \value BytesPerSecond Bytes per second diff --git a/src/testlib/qbenchmarkvalgrind.cpp b/src/testlib/qbenchmarkvalgrind.cpp index 4b260e8597..7e43d555e0 100644 --- a/src/testlib/qbenchmarkvalgrind.cpp +++ b/src/testlib/qbenchmarkvalgrind.cpp @@ -238,7 +238,7 @@ qint64 QBenchmarkCallgrindMeasurer::checkpoint() } qint64 QBenchmarkCallgrindMeasurer::stop() -{ +{ return checkpoint(); } @@ -249,17 +249,17 @@ bool QBenchmarkCallgrindMeasurer::isMeasurementAccepted(qint64 measurement) } int QBenchmarkCallgrindMeasurer::adjustIterationCount(int) -{ +{ return 1; } int QBenchmarkCallgrindMeasurer::adjustMedianCount(int) -{ +{ return 1; } bool QBenchmarkCallgrindMeasurer::needsWarmupIteration() -{ +{ return true; } diff --git a/src/testlib/qtestassert.h b/src/testlib/qtestassert.h index fa1ee0caec..24edab278d 100644 --- a/src/testlib/qtestassert.h +++ b/src/testlib/qtestassert.h @@ -50,9 +50,9 @@ QT_BEGIN_NAMESPACE QT_MODULE(Test) -#define QTEST_ASSERT(cond) do {if(!(cond))qt_assert(#cond,__FILE__,__LINE__);} while (0) +#define QTEST_ASSERT(cond) do { if (!(cond)) qt_assert(#cond,__FILE__,__LINE__); } while (0) -#define QTEST_ASSERT_X(cond, where, what) do {if(!(cond))qt_assert_x(where, what,__FILE__,__LINE__);} while (0) +#define QTEST_ASSERT_X(cond, where, what) do { if (!(cond)) qt_assert_x(where, what,__FILE__,__LINE__); } while (0) QT_END_NAMESPACE diff --git a/src/testlib/qtestcase.cpp b/src/testlib/qtestcase.cpp index d3176bbe09..666f0a7318 100644 --- a/src/testlib/qtestcase.cpp +++ b/src/testlib/qtestcase.cpp @@ -1059,7 +1059,7 @@ Q_TESTLIB_EXPORT void qtest_qParseArgs(int argc, char *argv[], bool qml) qPrintTestSlots(stdout); exit(0); } - } else if(strcmp(argv[i], "-xunitxml") == 0){ + } else if (strcmp(argv[i], "-xunitxml") == 0) { QTestLog::setLogMode(QTestLog::XunitXML); } else if (strcmp(argv[i], "-xml") == 0) { QTestLog::setLogMode(QTestLog::XML); @@ -1189,7 +1189,7 @@ Q_TESTLIB_EXPORT void qtest_qParseArgs(int argc, char *argv[], bool qml) // we load the QML files. So just store the data for now. int colon = -1; int offset; - for(offset = 0; *(argv[i]+offset); ++offset) { + for (offset = 0; *(argv[i]+offset); ++offset) { if (*(argv[i]+offset) == ':') { if (*(argv[i]+offset+1) == ':') { // "::" is used as a test name separator. @@ -1218,13 +1218,13 @@ Q_TESTLIB_EXPORT void qtest_qParseArgs(int argc, char *argv[], bool qml) int colon = -1; char buf[512], *data=0; int off; - for(off = 0; *(argv[i]+off); ++off) { + for (off = 0; *(argv[i]+off); ++off) { if (*(argv[i]+off) == ':') { colon = off; break; } } - if(colon != -1) { + if (colon != -1) { data = qstrdup(argv[i]+colon+1); } QTest::qt_snprintf(buf, qMin(512, off + 1), "%s", argv[i]); // copy text before the ':' into buf @@ -1425,7 +1425,7 @@ static bool qInvokeTestMethod(const char *slotName, const char *data=0) if (data && !foundFunction) { fprintf(stderr, "Unknown testdata for function %s: '%s'\n", slotName, data); fprintf(stderr, "Available testdata:\n"); - for(int i = 0; i < table.dataCount(); ++i) + for (int i = 0; i < table.dataCount(); ++i) fprintf(stderr, "%s\n", table.testData(i)->dataTag()); return false; } @@ -1476,7 +1476,7 @@ void *fetchData(QTestData *data, const char *tagName, int typeId) */ char *toHexRepresentation(const char *ba, int length) { - if(length == 0) + if (length == 0) return qstrdup(""); /* We output at maximum about maxLen characters in order to avoid @@ -1490,7 +1490,7 @@ char *toHexRepresentation(const char *ba, int length) const int len = qMin(maxLen, length); char *result = 0; - if(length > maxLen) { + if (length > maxLen) { const int size = len * 3 + 4; result = new char[size]; @@ -1511,7 +1511,7 @@ char *toHexRepresentation(const char *ba, int length) int i = 0; int o = 0; - while(true) { + while (true) { const char at = ba[i]; result[o] = toHex[(at >> 4) & 0x0F]; @@ -1520,7 +1520,7 @@ char *toHexRepresentation(const char *ba, int length) ++i; ++o; - if(i == len) + if (i == len) break; else { result[o] = ' '; @@ -1549,7 +1549,7 @@ static void qInvokeTestMethods(QObject *testObject) const bool previousFailed = QTestResult::testFailed(); QTestResult::finishedCurrentTestFunction(); - if(!QTestResult::skipCurrentTest() && !previousFailed) { + if (!QTestResult::skipCurrentTest() && !previousFailed) { if (QTest::testFuncs) { for (int i = 0; i != QTest::testFuncCount; i++) { @@ -1722,18 +1722,18 @@ int QTest::qExec(QObject *testObject, int argc, char **argv) #endif #ifdef Q_WS_MAC - bool macNeedsActivate = qApp && (qstrcmp(qApp->metaObject()->className(), "QApplication") == 0); + bool macNeedsActivate = qApp && (qstrcmp(qApp->metaObject()->className(), "QApplication") == 0); #ifdef QT_MAC_USE_COCOA - IOPMAssertionID powerID; + IOPMAssertionID powerID; #endif #endif #ifndef QT_NO_EXCEPTIONS try { #endif - #if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) - SetErrorMode(SetErrorMode(0) | SEM_NOGPFAULTERRORBOX); - #endif +#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) + SetErrorMode(SetErrorMode(0) | SEM_NOGPFAULTERRORBOX); +#endif #ifdef Q_WS_MAC // Starting with Qt 4.4, applications launched from the command line @@ -1742,13 +1742,13 @@ int QTest::qExec(QObject *testObject, int argc, char **argv) if (macNeedsActivate) { ProcessSerialNumber psn = { 0, kCurrentProcess }; SetFrontProcess(&psn); -# ifdef QT_MAC_USE_COCOA +#ifdef QT_MAC_USE_COCOA IOReturn ok = IOPMAssertionCreate(kIOPMAssertionTypeNoDisplaySleep, kIOPMAssertionLevelOn, &powerID); if (ok != kIOReturnSuccess) macNeedsActivate = false; // no need to release the assertion on exit. -# else +#else UpdateSystemActivity(1); // Wake the display. -# endif +#endif } #endif @@ -1810,7 +1810,7 @@ int QTest::qExec(QObject *testObject, int argc, char **argv) throw; return 1; } -# endif +#endif currentTestObject = 0; #ifdef QT_MAC_USE_COCOA @@ -1843,7 +1843,7 @@ int QTest::qExec(QObject *testObject, const QStringList &arguments) QVector args; args.reserve(argc); - for(int i = 0; i < argc; ++i) + for (int i = 0; i < argc; ++i) { args.append(arguments.at(i).toLocal8Bit().constData()); argv[i] = args.last().data(); diff --git a/src/testlib/qtestcoreelement.h b/src/testlib/qtestcoreelement.h index ecd088ad12..1d06c8d8cd 100644 --- a/src/testlib/qtestcoreelement.h +++ b/src/testlib/qtestcoreelement.h @@ -87,10 +87,7 @@ QTestCoreElement::~QTestCoreElement() template void QTestCoreElement::addAttribute(const QTest::AttributeIndex attributeIndex, const char *value) { - if(attributeIndex == -1) - return; - - if (attribute(attributeIndex)) + if (attributeIndex == -1 || attribute(attributeIndex)) return; QTestElementAttribute *testAttribute = new QTestElementAttribute; @@ -108,7 +105,7 @@ template const char *QTestCoreElement::attributeValue(QTest::AttributeIndex index) const { const QTestElementAttribute *attrb = attribute(index); - if(attrb) + if (attrb) return attrb->value(); return 0; @@ -118,7 +115,7 @@ template const char *QTestCoreElement::attributeName(QTest::AttributeIndex index) const { const QTestElementAttribute *attrb = attribute(index); - if(attrb) + if (attrb) return attrb->name(); return 0; @@ -139,7 +136,7 @@ const char *QTestCoreElement::elementName() const "system-err" }; - if(type != QTest::LET_Undefined) + if (type != QTest::LET_Undefined) return xmlElementNames[type]; return 0; @@ -155,8 +152,8 @@ template const QTestElementAttribute *QTestCoreElement::attribute(QTest::AttributeIndex index) const { QTestElementAttribute *iterator = listOfAttributes; - while(iterator){ - if(iterator->index() == index) + while (iterator) { + if (iterator->index() == index) return iterator; iterator = iterator->nextElement(); diff --git a/src/testlib/qtestcorelist.h b/src/testlib/qtestcorelist.h index 0790ea5c39..5027e4fcf9 100644 --- a/src/testlib/qtestcorelist.h +++ b/src/testlib/qtestcorelist.h @@ -70,8 +70,8 @@ class QTestCoreList template QTestCoreList::QTestCoreList() -:next(0) -,prev(0) + : next(0) + , prev(0) { } @@ -121,7 +121,7 @@ int QTestCoreList::count() int numOfElements = 0; T *it = next; - while(it){ + while (it) { ++numOfElements; it = it->nextElement(); } diff --git a/src/testlib/qtestdata.cpp b/src/testlib/qtestdata.cpp index d32a591eff..6797abf1d0 100644 --- a/src/testlib/qtestdata.cpp +++ b/src/testlib/qtestdata.cpp @@ -53,7 +53,7 @@ QT_BEGIN_NAMESPACE class QTestDataPrivate { public: - QTestDataPrivate(): tag(0), parent(0), data(0), dataCount(0) {} + QTestDataPrivate() : tag(0), parent(0), data(0), dataCount(0) {} char *tag; QTestTable *parent; diff --git a/src/testlib/qtestelement.cpp b/src/testlib/qtestelement.cpp index 3dc5ba60a8..a3c002f964 100644 --- a/src/testlib/qtestelement.cpp +++ b/src/testlib/qtestelement.cpp @@ -44,9 +44,9 @@ QT_BEGIN_NAMESPACE QTestElement::QTestElement(int type) - :QTestCoreElement(type), - listOfChildren(0), - parent(0) + : QTestCoreElement(type) + , listOfChildren(0) + , parent(0) { } @@ -57,10 +57,10 @@ QTestElement::~QTestElement() bool QTestElement::addLogElement(QTestElement *element) { - if(!element) + if (!element) return false; - if(element->elementType() != QTest::LET_Undefined){ + if (element->elementType() != QTest::LET_Undefined) { element->addToList(&listOfChildren); element->setParent(this); return true; diff --git a/src/testlib/qtestelementattribute.cpp b/src/testlib/qtestelementattribute.cpp index dcd518ca2a..9799ade577 100644 --- a/src/testlib/qtestelementattribute.cpp +++ b/src/testlib/qtestelementattribute.cpp @@ -50,37 +50,37 @@ QT_BEGIN_NAMESPACE This enum numbers the different tests. \value AI_Undefined - + \value AI_Name - + \value AI_Result - + \value AI_Tests - + \value AI_Failures - + \value AI_Errors - + \value AI_Type - + \value AI_Description - + \value AI_PropertyValue - + \value AI_QTestVersion - + \value AI_QtVersion - + \value AI_File - + \value AI_Line - + \value AI_Metric - + \value AI_Tag - + \value AI_Value - + \value AI_Iterations */ @@ -144,7 +144,7 @@ const char *QTestElementAttribute::name() const "iterations" }; - if(attributeIndex != QTest::AI_Undefined) + if (attributeIndex != QTest::AI_Undefined) return AttributeNames[attributeIndex]; return 0; @@ -162,7 +162,7 @@ bool QTestElementAttribute::isNull() const bool QTestElementAttribute::setPair(QTest::AttributeIndex index, const char *value) { - if(!value) + if (!value) return false; delete[] attributeValue; diff --git a/src/testlib/qtestkeyboard.h b/src/testlib/qtestkeyboard.h index 1a87e2515a..43fed84abc 100644 --- a/src/testlib/qtestkeyboard.h +++ b/src/testlib/qtestkeyboard.h @@ -75,7 +75,7 @@ namespace QTest if (delay == -1 || delay < defaultKeyDelay()) delay = defaultKeyDelay(); - if(delay > 0) + if (delay > 0) QTest::qWait(delay); QKeyEvent a(press ? QEvent::KeyPress : QEvent::KeyRelease, code, modifier, text, repeat); diff --git a/src/testlib/qtestmouse.h b/src/testlib/qtestmouse.h index cc076361c2..942b041eb1 100644 --- a/src/testlib/qtestmouse.h +++ b/src/testlib/qtestmouse.h @@ -76,7 +76,7 @@ namespace QTest if (delay == -1 || delay < defaultMouseDelay()) delay = defaultMouseDelay(); - if(delay > 0) + if (delay > 0) QTest::qWait(delay); if (pos.isNull()) diff --git a/src/testlib/qtestxunitstreamer.cpp b/src/testlib/qtestxunitstreamer.cpp index f70945add0..3e9c2feffc 100644 --- a/src/testlib/qtestxunitstreamer.cpp +++ b/src/testlib/qtestxunitstreamer.cpp @@ -80,7 +80,7 @@ void QTestXunitStreamer::indentForElement(const QTestElement* element, char* buf void QTestXunitStreamer::formatStart(const QTestElement *element, QTestCharBuffer *formatted) const { - if(!element || !formatted ) + if (!element || !formatted ) return; char indent[20]; @@ -104,7 +104,7 @@ void QTestXunitStreamer::formatEnd(const QTestElement *element, QTestCharBuffer if (!element || !formatted ) return; - if (!element->childElements()){ + if (!element->childElements()) { formatted->data()[0] = '\0'; return; } @@ -117,7 +117,7 @@ void QTestXunitStreamer::formatEnd(const QTestElement *element, QTestCharBuffer void QTestXunitStreamer::formatAttributes(const QTestElement* element, const QTestElementAttribute *attribute, QTestCharBuffer *formatted) const { - if(!attribute || !formatted ) + if (!attribute || !formatted ) return; QTest::AttributeIndex attrindex = attribute->index(); @@ -149,7 +149,7 @@ void QTestXunitStreamer::formatAttributes(const QTestElement* element, const QTe void QTestXunitStreamer::formatAfterAttributes(const QTestElement *element, QTestCharBuffer *formatted) const { - if(!element || !formatted ) + if (!element || !formatted ) return; // Errors are written as CDATA within system-err, comments elsewhere @@ -162,7 +162,7 @@ void QTestXunitStreamer::formatAfterAttributes(const QTestElement *element, QTes return; } - if(!element->childElements()) + if (!element->childElements()) QTest::qt_asprintf(formatted, "/>\n"); else QTest::qt_asprintf(formatted, ">\n"); @@ -190,7 +190,7 @@ void QTestXunitStreamer::outputElements(QTestElement *element, bool) const while (element) { hasChildren = element->childElements(); - if(element->elementType() != QTest::LET_Benchmark){ + if (element->elementType() != QTest::LET_Benchmark) { formatStart(element, &buf); outputString(buf.data()); @@ -199,7 +199,7 @@ void QTestXunitStreamer::outputElements(QTestElement *element, bool) const formatAfterAttributes(element, &buf); outputString(buf.data()); - if(hasChildren) + if (hasChildren) outputElements(element->childElements(), true); formatEnd(element, &buf); @@ -212,7 +212,7 @@ void QTestXunitStreamer::outputElements(QTestElement *element, bool) const void QTestXunitStreamer::outputElementAttributes(const QTestElement* element, QTestElementAttribute *attribute) const { QTestCharBuffer buf; - while(attribute){ + while (attribute) { formatAttributes(element, attribute, &buf); outputString(buf.data()); attribute = attribute->nextElement(); diff --git a/src/testlib/qxmltestlogger.cpp b/src/testlib/qxmltestlogger.cpp index 5ed7079ab6..ec153c8e17 100644 --- a/src/testlib/qxmltestlogger.cpp +++ b/src/testlib/qxmltestlogger.cpp @@ -115,7 +115,7 @@ void QXmlTestLogger::startLogging(const char *filename) outputString(buf.constData()); } - QTest::qt_asprintf(&buf, + QTest::qt_asprintf(&buf, "\n" " %s\n" " "QTEST_VERSION_STR"\n" diff --git a/src/testlib/qxunittestlogger.cpp b/src/testlib/qxunittestlogger.cpp index 05a8c47c47..69705b837b 100644 --- a/src/testlib/qxunittestlogger.cpp +++ b/src/testlib/qxunittestlogger.cpp @@ -169,7 +169,7 @@ void QXunitTestLogger::addIncident(IncidentTypes type, const char *description, if (type == QAbstractTestLogger::Fail || type == QAbstractTestLogger::XPass) { QTestElement *failureElement = new QTestElement(QTest::LET_Failure); failureElement->addAttribute(QTest::AI_Result, typeBuf); - if(file) + if (file) failureElement->addAttribute(QTest::AI_File, file); else failureElement->addAttribute(QTest::AI_File, ""); @@ -207,7 +207,7 @@ void QXunitTestLogger::addIncident(IncidentTypes type, const char *description, currentLogElement->addAttribute(QTest::AI_Result, typeBuf); } - if(file) + if (file) currentLogElement->addAttribute(QTest::AI_File, file); else currentLogElement->addAttribute(QTest::AI_File, ""); @@ -297,7 +297,7 @@ void QXunitTestLogger::addMessage(MessageTypes type, const char *message, const errorElement->addAttribute(QTest::AI_Description, message); addTag(errorElement); - if(file) + if (file) errorElement->addAttribute(QTest::AI_File, file); else errorElement->addAttribute(QTest::AI_File, ""); -- cgit v1.2.3 From 35bd983e0da5c645958fcdfcbf9abad16b6671da Mon Sep 17 00:00:00 2001 From: Gabriel de Dietrich Date: Thu, 1 Sep 2011 10:35:23 +0200 Subject: Update license headers This ammends commit 9aeadca09ab4e27ebf299873f90490d585b4fb7f Reviewed-by: Frederik Gladhorn Merge-request: 1254 (cherry picked from commit eee351a2af7e34dfc851a95820075842f856a8f2) Change-Id: Idd83457f87fea063843f8eaa47287531de7eb854 Reviewed-on: http://codereview.qt.nokia.com/4057 Reviewed-by: Frederik Gladhorn --- src/gui/widgets/qabstractplatformmenubar_p.h | 37 ++++++++++++++-------------- src/gui/widgets/qmenubar_x11.cpp | 37 ++++++++++++++-------------- src/gui/widgets/qmenubar_x11_p.h | 37 ++++++++++++++-------------- 3 files changed, 57 insertions(+), 54 deletions(-) diff --git a/src/gui/widgets/qabstractplatformmenubar_p.h b/src/gui/widgets/qabstractplatformmenubar_p.h index cb4e5cba73..10e6fdcab2 100644 --- a/src/gui/widgets/qabstractplatformmenubar_p.h +++ b/src/gui/widgets/qabstractplatformmenubar_p.h @@ -1,35 +1,35 @@ /**************************************************************************** ** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** ** This file is part of the QtGui module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. -** ** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ** ** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception +** rights. These rights are described in the Nokia Qt LGPL Exception ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. ** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. ** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. ** ** ** @@ -38,6 +38,7 @@ ** $QT_END_LICENSE$ ** ****************************************************************************/ + #ifndef QABSTRACTPLATFORMMENUBAR_P_H #define QABSTRACTPLATFORMMENUBAR_P_H diff --git a/src/gui/widgets/qmenubar_x11.cpp b/src/gui/widgets/qmenubar_x11.cpp index 37c085fc4a..25336d4378 100644 --- a/src/gui/widgets/qmenubar_x11.cpp +++ b/src/gui/widgets/qmenubar_x11.cpp @@ -1,35 +1,35 @@ /**************************************************************************** ** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** ** This file is part of the QtGui module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. -** ** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ** ** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception +** rights. These rights are described in the Nokia Qt LGPL Exception ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. ** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. ** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. ** ** ** @@ -38,6 +38,7 @@ ** $QT_END_LICENSE$ ** ****************************************************************************/ + #include "qmenubar_x11_p.h" #ifndef QT_NO_MENUBAR diff --git a/src/gui/widgets/qmenubar_x11_p.h b/src/gui/widgets/qmenubar_x11_p.h index 1c43b04406..41debd062a 100644 --- a/src/gui/widgets/qmenubar_x11_p.h +++ b/src/gui/widgets/qmenubar_x11_p.h @@ -1,35 +1,35 @@ /**************************************************************************** ** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** ** This file is part of the QtGui module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. -** ** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ** ** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception +** rights. These rights are described in the Nokia Qt LGPL Exception ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. ** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. ** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. ** ** ** @@ -38,6 +38,7 @@ ** $QT_END_LICENSE$ ** ****************************************************************************/ + #ifndef QX11MENUBAR_P_H #define QX11MENUBAR_P_H -- cgit v1.2.3 From 80559d6cd31de9f23976b410b0421406578bd4db Mon Sep 17 00:00:00 2001 From: "Bradley T. Hughes" Date: Thu, 1 Sep 2011 11:53:19 +0200 Subject: Remove declarations for QListData functions removed by 36c29ab MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This commit removed the function implementations, but not the declarations. This removes QListData::append2(T) but moves the optimized QListData::append2(T) implementation to QListData::append(T) Change-Id: I39b6dea31420a7cefe079b94a91a96eb16000d2a Reviewed-on: http://codereview.qt.nokia.com/4062 Reviewed-by: Qt Sanity Bot Reviewed-by: Samuel Rødal --- src/corelib/tools/qlist.cpp | 2 +- src/corelib/tools/qlist.h | 6 +----- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/src/corelib/tools/qlist.cpp b/src/corelib/tools/qlist.cpp index e0b69d4361..4c04385033 100644 --- a/src/corelib/tools/qlist.cpp +++ b/src/corelib/tools/qlist.cpp @@ -181,7 +181,7 @@ void **QListData::append() } // ensures that enough space is available to append the list -void **QListData::append2(const QListData& l) +void **QListData::append(const QListData& l) { return append(l.d->end - l.d->begin); } diff --git a/src/corelib/tools/qlist.h b/src/corelib/tools/qlist.h index f8f62cc8b2..7270ba98e7 100644 --- a/src/corelib/tools/qlist.h +++ b/src/corelib/tools/qlist.h @@ -79,9 +79,6 @@ struct Q_CORE_EXPORT QListData { Data *detach(int alloc); Data *detach_grow(int *i, int n); - Data *detach(); // remove in 5.0 - Data *detach2(); // remove in 5.0 - Data *detach3(); // remove in 5.0 void realloc(int alloc); static Data shared_null; Data *d; @@ -89,7 +86,6 @@ struct Q_CORE_EXPORT QListData { void **append(int n); void **append(); void **append(const QListData &l); - void **append2(const QListData &l); // remove in 5.0 void **prepend(); void **insert(int i); void remove(int i); @@ -802,7 +798,7 @@ Q_OUTOFLINE_TEMPLATE QList &QList::operator+=(const QList &l) } else { Node *n = (d->ref != 1) ? detach_helper_grow(INT_MAX, l.size()) - : reinterpret_cast(p.append2(l.p)); + : reinterpret_cast(p.append(l.p)); QT_TRY { node_copy(n, reinterpret_cast(p.end()), reinterpret_cast(l.p.begin())); -- cgit v1.2.3 From 2c8a4fae8441df9d0f6423d28c2b16e6e99b3d49 Mon Sep 17 00:00:00 2001 From: "Bradley T. Hughes" Date: Thu, 1 Sep 2011 11:58:22 +0200 Subject: Rename the private helper function QList::free() to QList::dealloc() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit As the comment suggests, renaming this function avoids confusion with libc's free(). Change-Id: Ia077b92c947d81ef9d78de940a1cd8ed022edb3c Reviewed-on: http://codereview.qt.nokia.com/4063 Reviewed-by: Qt Sanity Bot Reviewed-by: Samuel Rødal --- src/corelib/tools/qlist.h | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/corelib/tools/qlist.h b/src/corelib/tools/qlist.h index 7270ba98e7..b4c35b8d35 100644 --- a/src/corelib/tools/qlist.h +++ b/src/corelib/tools/qlist.h @@ -334,7 +334,7 @@ private: Node *detach_helper_grow(int i, int n); void detach_helper(int alloc); void detach_helper(); - void free(QListData::Data *d); + void dealloc(QListData::Data *d); void node_construct(Node *n, const T &t); void node_destruct(Node *n); @@ -422,7 +422,7 @@ Q_INLINE_TEMPLATE QList &QList::operator=(const QList &l) QListData::Data *o = l.d; o->ref.ref(); if (!d->ref.deref()) - free(d); + dealloc(d); d = o; if (!d->sharable) detach_helper(); @@ -679,7 +679,7 @@ Q_OUTOFLINE_TEMPLATE typename QList::Node *QList::detach_helper_grow(int i } if (!x->ref.deref()) - free(x); + dealloc(x); return reinterpret_cast(p.begin() + i); } @@ -698,7 +698,7 @@ Q_OUTOFLINE_TEMPLATE void QList::detach_helper(int alloc) } if (!x->ref.deref()) - free(x); + dealloc(x); } template @@ -711,7 +711,7 @@ template Q_OUTOFLINE_TEMPLATE QList::~QList() { if (!d->ref.deref()) - free(d); + dealloc(d); } template @@ -732,9 +732,8 @@ Q_OUTOFLINE_TEMPLATE bool QList::operator==(const QList &l) const return true; } -// ### Qt 5: rename freeData() to avoid confusion with std::free() template -Q_OUTOFLINE_TEMPLATE void QList::free(QListData::Data *data) +Q_OUTOFLINE_TEMPLATE void QList::dealloc(QListData::Data *data) { node_destruct(reinterpret_cast(data->array + data->begin), reinterpret_cast(data->array + data->end)); -- cgit v1.2.3 From c34b51eb52ab2d9e6af454d2cb5857fe30ef019d Mon Sep 17 00:00:00 2001 From: Kent Hansen Date: Thu, 1 Sep 2011 14:07:27 +0200 Subject: Don't build v8 when -no-v8 is passed to configure When v8 is enabled, QT_CONFIG contains "v8". There is no "no-v8", meaning that v8 was built regardless. Change-Id: I66740b23e5f7cae80740576ea0f13c3ad2f9ad40 Reviewed-on: http://codereview.qt.nokia.com/4073 Reviewed-by: Qt Sanity Bot Reviewed-by: Marius Storm-Olsen --- src/src.pro | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/src.pro b/src/src.pro index caac6426f3..55a0ad3034 100644 --- a/src/src.pro +++ b/src/src.pro @@ -8,7 +8,7 @@ SRC_SUBDIRS += src_corelib src_network src_sql src_testlib src_xml src_uitools nacl: SRC_SUBDIRS -= src_network src_testlib !symbian:contains(QT_CONFIG, dbus):SRC_SUBDIRS += src_dbus !contains(QT_CONFIG, no-gui): SRC_SUBDIRS += src_gui -!contains(QT_CONFIG, no-v8): SRC_SUBDIRS += src_v8 +contains(QT_CONFIG, v8): SRC_SUBDIRS += src_v8 !wince*:!symbian-abld:!symbian-sbsv2:include(tools/tools.pro) -- cgit v1.2.3 From 9bb0cc30ee8566e8c99865a657afd275d2d2f477 Mon Sep 17 00:00:00 2001 From: Kent Hansen Date: Thu, 1 Sep 2011 14:23:53 +0200 Subject: Check for V8 when auto-enabling Declarative module Declarative no longer used QtScript, it uses V8. This check in the configure script was stale. Change-Id: I3c598c0343fc421fdd191a256e07eaa6f4e80058 Reviewed-on: http://codereview.qt.nokia.com/4077 Reviewed-by: Oswald Buddenhagen Reviewed-by: Qt Sanity Bot --- configure | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure b/configure index 35ffeee6a0..83d5662912 100755 --- a/configure +++ b/configure @@ -7650,7 +7650,7 @@ if [ "$CFG_DECLARATIVE" = "yes" ]; then fi fi if [ "$CFG_DECLARATIVE" = "auto" ]; then - if [ "$CFG_SCRIPT" = "no" -o "$CFG_GUI" = "no" ]; then + if [ "$CFG_V8" = "no" -o "$CFG_GUI" = "no" ]; then CFG_DECLARATIVE=no else CFG_DECLARATIVE=yes -- cgit v1.2.3 From 74cadacdd5f571dfbab0e8b5f626bee79761c549 Mon Sep 17 00:00:00 2001 From: aavit Date: Thu, 1 Sep 2011 14:50:59 +0200 Subject: Add option to compare to different platform in lancelot autotest (cherry picked from commit b6b160d9ba1e0a5f1fbd67112f8c78ba48e7cad7) Conflicts: tests/baselineserver/src/baselineserver.cpp Change-Id: Ie8bdff26b8394bb6a5b6b48225b20833dbee0637 Reviewed-on: http://codereview.qt.nokia.com/4082 Reviewed-by: Qt Sanity Bot Reviewed-by: Jiang Jiang --- tests/auto/lancelot/paintcommands.cpp | 4 ++ tests/auto/lancelot/tst_lancelot.cpp | 21 ++++++- tests/baselineserver/shared/baselineprotocol.cpp | 46 +++++++++------ tests/baselineserver/shared/baselineprotocol.h | 13 +++-- tests/baselineserver/src/baselineserver.cpp | 74 +++++++++++++++--------- tests/baselineserver/src/baselineserver.h | 7 ++- tests/baselineserver/src/report.cpp | 49 ++++++++++------ tests/baselineserver/src/report.h | 1 + 8 files changed, 141 insertions(+), 74 deletions(-) diff --git a/tests/auto/lancelot/paintcommands.cpp b/tests/auto/lancelot/paintcommands.cpp index 8735baa3f0..9659659973 100644 --- a/tests/auto/lancelot/paintcommands.cpp +++ b/tests/auto/lancelot/paintcommands.cpp @@ -2306,7 +2306,11 @@ void PaintCommands::command_gradient_setRadialExtended(QRegExp re) "focal radius=%.2f, spread=%d\n", cx, cy, rad, fx, fy, frad, m_gradientSpread); +#if QT_VERSION >= 0x040800 QRadialGradient rg(QPointF(cx, cy), rad, QPointF(fx, fy), frad); +#else + QRadialGradient rg(QPointF(cx, cy), rad, QPointF(fx, fy)); +#endif rg.setStops(m_gradientStops); rg.setSpread(m_gradientSpread); rg.setCoordinateMode(m_gradientCoordinate); diff --git a/tests/auto/lancelot/tst_lancelot.cpp b/tests/auto/lancelot/tst_lancelot.cpp index cba5fab4d1..256ff29889 100644 --- a/tests/auto/lancelot/tst_lancelot.cpp +++ b/tests/auto/lancelot/tst_lancelot.cpp @@ -62,6 +62,7 @@ public: tst_Lancelot(); static bool simfail; + static PlatformInfo clientInfo; private: enum GraphicsEngine { @@ -98,6 +99,7 @@ private slots: }; bool tst_Lancelot::simfail = false; +PlatformInfo tst_Lancelot::clientInfo; tst_Lancelot::tst_Lancelot() { @@ -112,7 +114,7 @@ void tst_Lancelot::initTestCase() #if defined(Q_OS_SOMEPLATFORM) QSKIP("This test is not supported on this platform.", SkipAll); #endif - if (!proto.connect(QLatin1String("tst_Lancelot"), &dryRunMode)) + if (!proto.connect(QLatin1String("tst_Lancelot"), &dryRunMode, clientInfo)) QSKIP(qPrintable(proto.errorMessage()), SkipAll); #if defined(USE_RUNTIME_DIR) @@ -329,13 +331,26 @@ QTEST_MAIN(tst_Lancelot) int main(int argc, char *argv[]) { + tst_Lancelot::clientInfo = PlatformInfo::localHostInfo(); + char *fargv[20]; int fargc = 0; for (int i = 0; i < qMin(argc, 19); i++) { - if (!qstrcmp(argv[i], "-simfail")) + if (!qstrcmp(argv[i], "-simfail")) { tst_Lancelot::simfail = true; - else + } else if (!qstrcmp(argv[i], "-compareto") && i < argc-1) { + QString arg = QString::fromLocal8Bit(argv[++i]); + int split = arg.indexOf(QLC('=')); + if (split < 0) + continue; + QString key = arg.left(split).trimmed(); + QString value = arg.mid(split+1).trimmed(); + if (key.isEmpty() || value.isEmpty()) + continue; + tst_Lancelot::clientInfo.addOverride(key, value); + } else { fargv[fargc++] = argv[i]; + } } fargv[fargc] = 0; return rmain(fargc, fargv); diff --git a/tests/baselineserver/shared/baselineprotocol.cpp b/tests/baselineserver/shared/baselineprotocol.cpp index 0fe3aa22a9..630ca88e5b 100644 --- a/tests/baselineserver/shared/baselineprotocol.cpp +++ b/tests/baselineserver/shared/baselineprotocol.cpp @@ -83,7 +83,7 @@ void BaselineProtocol::sysSleep(int ms) } PlatformInfo::PlatformInfo() - : QMap(), replaceDefault(false) + : QMap(), adHoc(true) { } @@ -134,11 +134,15 @@ PlatformInfo PlatformInfo::localHostInfo() pi.insert(PI_GitCommit, QLS("Unknown")); QByteArray gb = qgetenv("PULSE_GIT_BRANCH"); - if (!gb.isEmpty()) + if (!gb.isEmpty()) { pi.insert(PI_PulseGitBranch, QString::fromLatin1(gb)); + pi.setAdHocRun(false); + } QByteArray tb = qgetenv("PULSE_TESTR_BRANCH"); - if (!tb.isEmpty()) + if (!tb.isEmpty()) { pi.insert(PI_PulseTestrBranch, QString::fromLatin1(tb)); + pi.setAdHocRun(false); + } return pi; } @@ -147,43 +151,49 @@ PlatformInfo PlatformInfo::localHostInfo() PlatformInfo::PlatformInfo(const PlatformInfo &other) : QMap(other) { - sigKeys = other.sigKeys; - replaceDefault = other.replaceDefault; + orides = other.orides; + adHoc = other.adHoc; } PlatformInfo &PlatformInfo::operator=(const PlatformInfo &other) { QMap::operator=(other); - sigKeys = other.sigKeys; - replaceDefault = other.replaceDefault; + orides = other.orides; + adHoc = other.adHoc; return *this; } -void PlatformInfo::addSignificantKeys(const QStringList &keys, bool replaceDefaultKeys) +void PlatformInfo::addOverride(const QString& key, const QString& value) +{ + orides.append(key); + orides.append(value); +} + + +QStringList PlatformInfo::overrides() const { - sigKeys = keys; - replaceDefault = replaceDefaultKeys; + return orides; } -QStringList PlatformInfo::addedKeys() const +void PlatformInfo::setAdHocRun(bool isAdHoc) { - return sigKeys; + adHoc = isAdHoc; } -bool PlatformInfo::addedKeysReplaceDefault() const +bool PlatformInfo::isAdHocRun() const { - return replaceDefault; + return adHoc; } QDataStream & operator<< (QDataStream &stream, const PlatformInfo &pi) { stream << static_cast&>(pi); - stream << pi.sigKeys << pi.replaceDefault; + stream << pi.orides << pi.adHoc; return stream; } @@ -191,7 +201,7 @@ QDataStream & operator<< (QDataStream &stream, const PlatformInfo &pi) QDataStream & operator>> (QDataStream &stream, PlatformInfo &pi) { stream >> static_cast&>(pi); - stream >> pi.sigKeys >> pi.replaceDefault; + stream >> pi.orides >> pi.adHoc; return stream; } @@ -346,7 +356,7 @@ BaselineProtocol::~BaselineProtocol() } -bool BaselineProtocol::connect(const QString &testCase, bool *dryrun) +bool BaselineProtocol::connect(const QString &testCase, bool *dryrun, const PlatformInfo& clientInfo) { errMsg.clear(); QByteArray serverName(qgetenv("QT_LANCELOT_SERVER")); @@ -362,7 +372,7 @@ bool BaselineProtocol::connect(const QString &testCase, bool *dryrun) } } - PlatformInfo pi = PlatformInfo::localHostInfo(); + PlatformInfo pi = clientInfo.isEmpty() ? PlatformInfo::localHostInfo() : clientInfo; pi.insert(PI_TestCase, testCase); QByteArray block; QDataStream ds(&block, QIODevice::ReadWrite); diff --git a/tests/baselineserver/shared/baselineprotocol.h b/tests/baselineserver/shared/baselineprotocol.h index 2d09e683d4..0b08e444fd 100644 --- a/tests/baselineserver/shared/baselineprotocol.h +++ b/tests/baselineserver/shared/baselineprotocol.h @@ -78,13 +78,14 @@ public: static PlatformInfo localHostInfo(); - void addSignificantKeys(const QStringList& keys, bool replaceDefaultKeys=false); - QStringList addedKeys() const; - bool addedKeysReplaceDefault() const; + void addOverride(const QString& key, const QString& value); + QStringList overrides() const; + bool isAdHocRun() const; + void setAdHocRun(bool isAdHoc); private: - QStringList sigKeys; - bool replaceDefault; + QStringList orides; + bool adHoc; friend QDataStream & operator<< (QDataStream &stream, const PlatformInfo &pi); friend QDataStream & operator>> (QDataStream &stream, PlatformInfo& pi); }; @@ -165,7 +166,7 @@ public: // For client: // For advanced client: - bool connect(const QString &testCase, bool *dryrun = 0); + bool connect(const QString &testCase, bool *dryrun = 0, const PlatformInfo& clientInfo = PlatformInfo()); bool requestBaselineChecksums(const QString &testFunction, ImageItemList *itemList); bool submitNewBaseline(const ImageItem &item, QByteArray *serverMsg); bool submitMismatch(const ImageItem &item, QByteArray *serverMsg); diff --git a/tests/baselineserver/src/baselineserver.cpp b/tests/baselineserver/src/baselineserver.cpp index 6ff0a0c72d..5ac78d4b32 100644 --- a/tests/baselineserver/src/baselineserver.cpp +++ b/tests/baselineserver/src/baselineserver.cpp @@ -172,27 +172,31 @@ const char *BaselineHandler::logtime() bool BaselineHandler::establishConnection() { - if (!proto.acceptConnection(&plat)) { + if (!proto.acceptConnection(&clientInfo)) { qWarning() << runId << logtime() << "Accepting new connection from" << proto.socket.peerAddress().toString() << "failed." << proto.errorMessage(); proto.sendBlock(BaselineProtocol::Abort, proto.errorMessage().toLatin1()); // In case the client can hear us, tell it what's wrong. proto.socket.disconnectFromHost(); return false; } QString logMsg; - foreach (QString key, plat.keys()) { + foreach (QString key, clientInfo.keys()) { if (key != PI_HostName && key != PI_HostAddress) - logMsg += key + QLS(": '") + plat.value(key) + QLS("', "); + logMsg += key + QLS(": '") + clientInfo.value(key) + QLS("', "); } - qDebug() << runId << logtime() << "Connection established with" << plat.value(PI_HostName) - << "[" << qPrintable(plat.value(PI_HostAddress)) << "]" << logMsg; + qDebug() << runId << logtime() << "Connection established with" << clientInfo.value(PI_HostName) + << "[" << qPrintable(clientInfo.value(PI_HostAddress)) << "]" << logMsg + << "Overrides:" << clientInfo.overrides() << "AdHoc-Run:" << clientInfo.isAdHocRun(); + + //### Temporarily override the client setting, for client compatibility: + if (!clientInfo.isAdHocRun()) + clientInfo.setAdHocRun(clientInfo.value(PI_PulseGitBranch).isEmpty() && clientInfo.value(PI_PulseTestrBranch).isEmpty()); settings->beginGroup("ClientFilters"); - if (!settings->childKeys().isEmpty() && !plat.value(PI_PulseGitBranch).isEmpty()) { // i.e. not adhoc client - // Abort if client does not match the filters + if (!clientInfo.isAdHocRun()) { // for CI runs, allow filtering of clients. TBD: different filters (settings file) per testCase foreach (QString filterKey, settings->childKeys()) { QString filter = settings->value(filterKey).toString(); - QString platVal = plat.value(filterKey); - if (filter.isEmpty() || platVal.isEmpty()) + QString platVal = clientInfo.value(filterKey); + if (filter.isEmpty()) continue; // tbd: add a syntax for specifying a "value-must-be-present" filter if (!platVal.contains(filter)) { qDebug() << runId << logtime() << "Did not pass client filter on" << filterKey << "; disconnecting."; @@ -206,7 +210,7 @@ bool BaselineHandler::establishConnection() proto.sendBlock(BaselineProtocol::Ack, QByteArray()); - report.init(this, runId, plat); + report.init(this, runId, clientInfo); return true; } @@ -297,6 +301,12 @@ void BaselineHandler::storeImage(const QByteArray &itemBlock, bool isBaseline) ImageItem item; ds >> item; + if (isBaseline && !clientInfo.overrides().isEmpty()) { + qDebug() << runId << logtime() << "Received baseline from client with override info, ignoring. Item:" << item.itemName; + proto.sendBlock(BaselineProtocol::UnknownError, "New baselines not accepted from client with override info."); + return; + } + QString prefix = pathForItem(item, isBaseline); qDebug() << runId << logtime() << "Received" << (isBaseline ? "baseline" : "mismatched") << "image for:" << item.itemName << "Storing in" << prefix; @@ -313,7 +323,7 @@ void BaselineHandler::storeImage(const QByteArray &itemBlock, bool isBaseline) cwd.mkpath(dir); item.image.save(prefix + QLS(FileFormat), FileFormat); - PlatformInfo itemData = plat; + PlatformInfo itemData = clientInfo; itemData.insert(PI_ImageChecksum, QString::number(item.imageChecksums.at(0), 16)); //# Only the first is stored. TBD: get rid of list itemData.insert(PI_RunId, runId); itemData.insert(PI_CreationDate, QDateTime::currentDateTime().toString()); @@ -366,17 +376,16 @@ void BaselineHandler::receiveDisconnect() } -void BaselineHandler::mapPlatformInfo() const +PlatformInfo BaselineHandler::mapPlatformInfo(const PlatformInfo& orig) const { - mapped = plat; + PlatformInfo mapped = orig; // Map hostname - QString host = plat.value(PI_HostName).section(QLC('.'), 0, 0); // Filter away domain, if any + QString host = orig.value(PI_HostName).section(QLC('.'), 0, 0); // Filter away domain, if any if (host.isEmpty() || host == QLS("localhost")) { - host = plat.value(PI_HostAddress); + host = orig.value(PI_HostAddress); } else { - if (!plat.value(PI_PulseGitBranch).isEmpty()) { - // i.e. pulse run, so remove index postfix typical of vm hostnames + if (!orig.isAdHocRun()) { // i.e. CI system run, so remove index postfix typical of vm hostnames host.remove(QRegExp(QLS("\\d+$"))); if (host.endsWith(QLC('-'))) host.chop(1); @@ -387,18 +396,28 @@ void BaselineHandler::mapPlatformInfo() const mapped.insert(PI_HostName, host); // Map qmakespec - QString mkspec = plat.value(PI_QMakeSpec); + QString mkspec = orig.value(PI_QMakeSpec); mapped.insert(PI_QMakeSpec, mkspec.replace(QLC('/'), QLC('_'))); // Map Qt version - QString ver = plat.value(PI_QtVersion); + QString ver = orig.value(PI_QtVersion); mapped.insert(PI_QtVersion, ver.prepend(QLS("Qt-"))); + + return mapped; } + QString BaselineHandler::pathForItem(const ImageItem &item, bool isBaseline, bool absolute) const { - if (mapped.isEmpty()) - mapPlatformInfo(); + if (mappedClientInfo.isEmpty()) { + mappedClientInfo = mapPlatformInfo(clientInfo); + PlatformInfo oraw = clientInfo; + for (int i = 0; i < clientInfo.overrides().size()-1; i+=2) + oraw.insert(clientInfo.overrides().at(i), clientInfo.overrides().at(i+1)); + overriddenMappedClientInfo = mapPlatformInfo(oraw); + } + + const PlatformInfo& mapped = isBaseline ? overriddenMappedClientInfo : mappedClientInfo; QString itemName = item.itemName.simplified(); itemName.replace(QLC(' '), QLC('_')); @@ -512,13 +531,14 @@ void BaselineHandler::testPathMapping() item.imageChecksums << 0x0123456789abcdefULL; item.itemChecksum = 0x0123; - plat.insert(PI_QtVersion, QLS("5.0.0")); - plat.insert(PI_BuildKey, QLS("(nobuildkey)")); - plat.insert(PI_QMakeSpec, QLS("linux-g++")); - plat.insert(PI_PulseGitBranch, QLS("somebranch")); + clientInfo.insert(PI_QtVersion, QLS("5.0.0")); + clientInfo.insert(PI_BuildKey, QLS("(nobuildkey)")); + clientInfo.insert(PI_QMakeSpec, QLS("linux-g++")); + clientInfo.insert(PI_PulseGitBranch, QLS("somebranch")); + foreach(const QString& host, hosts) { - mapped.clear(); - plat.insert(PI_HostName, host); + mappedClientInfo.clear(); + clientInfo.insert(PI_HostName, host); qDebug() << "Baseline from" << host << "->" << pathForItem(item, true); qDebug() << "Mismatch from" << host << "->" << pathForItem(item, false); } diff --git a/tests/baselineserver/src/baselineserver.h b/tests/baselineserver/src/baselineserver.h index d73bb974f9..333d9ed30b 100644 --- a/tests/baselineserver/src/baselineserver.h +++ b/tests/baselineserver/src/baselineserver.h @@ -125,13 +125,14 @@ private: void storeImage(const QByteArray &itemBlock, bool isBaseline); void storeItemMetadata(const PlatformInfo &metadata, const QString &path); PlatformInfo fetchItemMetadata(const QString &path); - void mapPlatformInfo() const; + PlatformInfo mapPlatformInfo(const PlatformInfo& orig) const; const char *logtime(); QString computeMismatchScore(const QImage& baseline, const QImage& rendered); BaselineProtocol proto; - PlatformInfo plat; - mutable PlatformInfo mapped; + PlatformInfo clientInfo; + mutable PlatformInfo mappedClientInfo; + mutable PlatformInfo overriddenMappedClientInfo; QString runId; bool connectionEstablished; Report report; diff --git a/tests/baselineserver/src/report.cpp b/tests/baselineserver/src/report.cpp index 7c2d6ac6df..16f061c7e7 100644 --- a/tests/baselineserver/src/report.cpp +++ b/tests/baselineserver/src/report.cpp @@ -66,12 +66,13 @@ void Report::init(const BaselineHandler *h, const QString &r, const PlatformInfo runId = r; plat = p; rootDir = BaselineServer::storagePath() + QLC('/'); - reportDir = plat.value(PI_TestCase) + QLC('/') + (plat.value(PI_PulseGitBranch).isEmpty() ? QLS("reports/adhoc/") : QLS("reports/pulse/")); + reportDir = plat.value(PI_TestCase) + QLC('/') + (plat.isAdHocRun() ? QLS("reports/adhoc/") : QLS("reports/pulse/")); QString dir = rootDir + reportDir; QDir cwd; if (!cwd.exists(dir)) cwd.mkpath(dir); path = reportDir + QLS("Report_") + runId + QLS(".html"); + hasOverride = !plat.overrides().isEmpty(); } void Report::addItems(const ImageItemList &items) @@ -141,11 +142,19 @@ void Report::writeHeader() << "

Note: This is a static page, generated at " << QDateTime::currentDateTime().toString() << " for the test run with id " << runId << "

\n" << "

Summary: " << numMismatches << " of " << numItems << " items reported mismatching

\n\n"; - out << "

Platform Info:

\n" + out << "

Testing Client Platform Info:

\n" << "\n"; foreach (QString key, plat.keys()) - out << "\n"; + out << "\n"; out << "
" << key << "" << plat.value(key) << "
" << key << ":" << plat.value(key) << "
\n\n"; + if (hasOverride) { + out << "

Note! Platform Override Info:

\n" + << "

The client's output has been compared to baselines created on a different platform. Differences:

\n" + << "\n"; + for (int i = 0; i < plat.overrides().size()-1; i+=2) + out << "\n"; + out << "
" << plat.overrides().at(i) << ":" << plat.overrides().at(i+1) << "
\n\n"; + } } @@ -158,10 +167,12 @@ void Report::writeFunctionResults(const ImageItemList &list) out << "\n

 

Test function: " << testFunction << "

\n"; - out << "

Clear all baselines for this testfunction (They will be recreated by the next run)

\n"; - out << "

Let these mismatching images be the new baselines for this testfunction

\n\n"; + if (!hasOverride) { + out << "

Clear all baselines for this testfunction (They will be recreated by the next run)

\n"; + out << "

Let these mismatching images be the new baselines for this testfunction

\n\n"; + } out << "\n" "\n" @@ -192,10 +203,12 @@ void Report::writeFunctionResults(const ImageItemList &list) out << "Baseline not found/regenerated"; break; case ImageItem::IgnoreItem: - out << "Blacklisted " - << "Whitelist this item"; + out << "Blacklisted "; + if (!hasOverride) { + out << "Whitelist this item"; + } break; case ImageItem::Ok: out << "No mismatch reported"; @@ -224,12 +237,14 @@ void Report::writeItem(const QString &baseline, const QString &rendered, const I out << "\n"; } diff --git a/tests/baselineserver/src/report.h b/tests/baselineserver/src/report.h index d21102d32f..610497c84b 100644 --- a/tests/baselineserver/src/report.h +++ b/tests/baselineserver/src/report.h @@ -86,6 +86,7 @@ private: int numItems; int numMismatches; QTextStream out; + bool hasOverride; }; #endif // REPORT_H -- cgit v1.2.3 From 7a0a9bd5c4bedba771841822b53181e783292227 Mon Sep 17 00:00:00 2001 From: Ritt Konstantin Date: Sat, 16 Jul 2011 04:45:28 +0400 Subject: omit unassigned (and too recent) codepoints from the text Normalization process http://www.unicode.org/reports/tr15/#Guaranteeing_Process_Stability: > handle any code points that were not defined in the earlier version > as if they were unassigned: such code points will not decompose or compose, > and their Canonical_Combining_Class value will be zero. since QChar::Unicode_Unassigned value is 0, it's less than any other QChar::UnicodeVersion value and must ba handled explicitly Change-Id: I6df025b4173d407660adae77ec5eeb98d15cb8ce Reviewed-on: http://codereview.qt.nokia.com/4084 Reviewed-by: Qt Sanity Bot Reviewed-by: Lars Knoll --- src/corelib/tools/qchar.cpp | 18 +++++++++++++----- src/corelib/tools/qstring.cpp | 2 +- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/src/corelib/tools/qchar.cpp b/src/corelib/tools/qchar.cpp index 736bc63b11..b68da9def4 100644 --- a/src/corelib/tools/qchar.cpp +++ b/src/corelib/tools/qchar.cpp @@ -1402,7 +1402,8 @@ static void decomposeHelper(QString *str, bool canonical, QChar::UnicodeVersion ucs4 = QChar::surrogateToUcs4(high, ucs4); } } - if (QChar::unicodeVersion(ucs4) > version) + const QChar::UnicodeVersion v = QChar::unicodeVersion(ucs4); + if (v > version || v == QChar::Unicode_Unassigned) continue; int length; int tag; @@ -1462,7 +1463,7 @@ static ushort ligatureHelper(ushort u1, ushort u2) return 0; } -static void composeHelper(QString *str, int from) +static void composeHelper(QString *str, QChar::UnicodeVersion version, int from) { QString &s = *str; @@ -1482,7 +1483,14 @@ static void composeHelper(QString *str, int from) ++pos; } } - int combining = QChar::combiningClass(uc); + const QUnicodeTables::Properties *p = qGetProp(uc); + if (p->unicodeVersion > version || p->unicodeVersion == QChar::Unicode_Unassigned) { + starter = -1; // to prevent starter == pos - 1 + lastCombining = 0; + ++pos; + continue; + } + int combining = p->combiningClass; if (starter == pos - 1 || combining > lastCombining) { // allowed to form ligature with S QChar ligature = ligatureHelper(s.at(starter).unicode(), uc); @@ -1529,7 +1537,7 @@ static void canonicalOrderHelper(QString *str, QChar::UnicodeVersion version, in ushort c2 = 0; { const QUnicodeTables::Properties *p = qGetProp(u2); - if ((QChar::UnicodeVersion)p->unicodeVersion <= version) + if (p->unicodeVersion <= version && p->unicodeVersion != QChar::Unicode_Unassigned) c2 = p->combiningClass; } if (c2 == 0) { @@ -1540,7 +1548,7 @@ static void canonicalOrderHelper(QString *str, QChar::UnicodeVersion version, in ushort c1 = 0; { const QUnicodeTables::Properties *p = qGetProp(u1); - if ((QChar::UnicodeVersion)p->unicodeVersion <= version) + if (p->unicodeVersion <= version && p->unicodeVersion != QChar::Unicode_Unassigned) c1 = p->combiningClass; } diff --git a/src/corelib/tools/qstring.cpp b/src/corelib/tools/qstring.cpp index 78b1b59210..c56c050f76 100644 --- a/src/corelib/tools/qstring.cpp +++ b/src/corelib/tools/qstring.cpp @@ -6230,7 +6230,7 @@ void qt_string_normalize(QString *data, QString::NormalizationForm mode, QChar:: if (mode == QString::NormalizationForm_D || mode == QString::NormalizationForm_KD) return; - composeHelper(data, from); + composeHelper(data, version, from); } -- cgit v1.2.3 From 2438a5ad48014ca0828ee417616358ea171826aa Mon Sep 17 00:00:00 2001 From: Kent Hansen Date: Thu, 1 Sep 2011 16:13:29 +0200 Subject: Try to ensure that QT_ARCH is always set when configuring v8 This is a workaround for QTBUG-21224. For v8 we want to use QT_ARCH as the primary variable for detecting the target platform. Unfortunately, QT_ARCH isn't set when v8.pro is parsed using fromfile() from within another .pro file (namely src/src.pro). qt_config seems to be the bare minimum that's needed to get qconfig.pri (which sets QT_ARCH and friends) loaded. Change-Id: Ideb713724b98dd100560eaf6d7be39df9a22a71e Reviewed-on: http://codereview.qt.nokia.com/4094 Reviewed-by: Qt Sanity Bot Reviewed-by: Oswald Buddenhagen Reviewed-by: Marius Storm-Olsen --- src/v8/v8.pri | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/v8/v8.pri b/src/v8/v8.pri index 4d55bbfd5a..dde953ca0d 100644 --- a/src/v8/v8.pri +++ b/src/v8/v8.pri @@ -1,3 +1,10 @@ +isEmpty(QT_ARCH) { + # We're most likely being parsed in a fromfile() call, in which case the + # QMake environment isn't complete. Load qt_config in an attempt to set + # the variables we need (QT_ARCH and CONFIG, in particular). + load(qt_config) +} + equals(QT_ARCH, x86_64)|contains(CONFIG, x86_64):CONFIG += arch_x86_64 else:equals(QT_ARCH, "i386"):CONFIG += arch_i386 else:equals(QT_ARCH, "arm"):CONFIG += arch_arm -- cgit v1.2.3 From 949be8cbdd2d346647accbbd9bdab879256470ec Mon Sep 17 00:00:00 2001 From: Rohan McGovern Date: Thu, 1 Sep 2011 08:43:18 +1000 Subject: test: fixed `assert' selftest for release-only mac builds This test intentionally crashes itself by using Q_ASSERT. Since Q_ASSERT is a no-op in release builds, the .pro file was attempting to always force debug mode for this project. However, on platforms where debug vs release affect linkage (e.g. mac and windows), this is invalid. On these platforms, debug mode can't be enabled unless debug versions of the Qt libraries are available, which they are not if Qt is configured with `-no-debug-and-release -release'. Use a different method to ensure that Q_ASSERT really asserts, for both debug and release builds. Change-Id: I13eea2c72c77a0a981850dbcaa77f65f147c8490 Reviewed-on: http://codereview.qt.nokia.com/4015 Reviewed-by: Qt Sanity Bot Reviewed-by: Jason McDonald --- tests/auto/selftests/assert/assert.pro | 2 -- tests/auto/selftests/assert/tst_assert.cpp | 4 ++++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/auto/selftests/assert/assert.pro b/tests/auto/selftests/assert/assert.pro index e8d60bda6d..a1ed578a31 100644 --- a/tests/auto/selftests/assert/assert.pro +++ b/tests/auto/selftests/assert/assert.pro @@ -8,7 +8,5 @@ QT = core mac:CONFIG -= app_bundle CONFIG -= debug_and_release_target -!win32:CONFIG += debug - TARGET = assert diff --git a/tests/auto/selftests/assert/tst_assert.cpp b/tests/auto/selftests/assert/tst_assert.cpp index 6e1fbdb509..bd44162971 100644 --- a/tests/auto/selftests/assert/tst_assert.cpp +++ b/tests/auto/selftests/assert/tst_assert.cpp @@ -39,6 +39,10 @@ ** ****************************************************************************/ +// Make sure we get a real Q_ASSERT even in release builds +#ifdef QT_NO_DEBUG +# undef QT_NO_DEBUG +#endif #include #include -- cgit v1.2.3 From fad997b4ee6b1cde911fe44921b4bf87e07fa167 Mon Sep 17 00:00:00 2001 From: Rohan McGovern Date: Thu, 1 Sep 2011 08:55:06 +1000 Subject: test: removed bogus CONFIG+=debug for badxml selftest This appears to serve no purpose. It was probably copy-pasted from assert.pro. Change-Id: Ie3d9605b969ee11f2d64c1ac3e480e9efb862a3c Reviewed-on: http://codereview.qt.nokia.com/4016 Reviewed-by: Qt Sanity Bot Reviewed-by: Jason McDonald --- tests/auto/selftests/badxml/badxml.pro | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/auto/selftests/badxml/badxml.pro b/tests/auto/selftests/badxml/badxml.pro index f55636de2b..126ac379d7 100644 --- a/tests/auto/selftests/badxml/badxml.pro +++ b/tests/auto/selftests/badxml/badxml.pro @@ -8,7 +8,6 @@ QT = core mac:CONFIG -= app_bundle CONFIG -= debug_and_release_target -!win32:CONFIG += debug TARGET = badxml -- cgit v1.2.3 From 592d53a17c2d19d5b33e3d4b4cd4386110e9196b Mon Sep 17 00:00:00 2001 From: Rohan McGovern Date: Thu, 1 Sep 2011 09:23:54 +1000 Subject: test: removed bogus CONFIG+=debug in qdiriterator benchmark This doesn't make sense, none of the other benchmarks do it, and it breaks compilation for a release-only mac build. Change-Id: I3bc73f670688d413afcae7fa88bab19f7b3dac33 Reviewed-on: http://codereview.qt.nokia.com/4017 Reviewed-by: Qt Sanity Bot Reviewed-by: Jason McDonald --- tests/benchmarks/corelib/io/qdiriterator/qdiriterator.pro | 2 -- 1 file changed, 2 deletions(-) diff --git a/tests/benchmarks/corelib/io/qdiriterator/qdiriterator.pro b/tests/benchmarks/corelib/io/qdiriterator/qdiriterator.pro index 38bcfd0c9e..e6bd962302 100755 --- a/tests/benchmarks/corelib/io/qdiriterator/qdiriterator.pro +++ b/tests/benchmarks/corelib/io/qdiriterator/qdiriterator.pro @@ -11,8 +11,6 @@ INCLUDEPATH += . QT -= gui CONFIG += release -CONFIG += debug - SOURCES += main.cpp -- cgit v1.2.3 From f1af291d4901e503f7c8098c55393ac756f032f1 Mon Sep 17 00:00:00 2001 From: Jason McDonald Date: Thu, 1 Sep 2011 18:24:55 +1000 Subject: Remove circular dependency in testlib logging Remove one of the circular dependencies between QPlainTestLogger and QTestLog by directly checking whether we're writing to stdout rather than inferring the same by examining whether the output file name is null. Change-Id: I798288482c9e2e071e17a8622e8a8f8d5016dc7e Reviewed-on: http://codereview.qt.nokia.com/4052 Reviewed-by: Qt Sanity Bot Reviewed-by: Rohan McGovern --- src/testlib/qabstracttestlogger_p.h | 2 +- src/testlib/qplaintestlogger.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/testlib/qabstracttestlogger_p.h b/src/testlib/qabstracttestlogger_p.h index 3ac6787754..47f772e7ed 100644 --- a/src/testlib/qabstracttestlogger_p.h +++ b/src/testlib/qabstracttestlogger_p.h @@ -98,7 +98,7 @@ public: void outputString(const char *msg); -private: +protected: FILE *stream; }; diff --git a/src/testlib/qplaintestlogger.cpp b/src/testlib/qplaintestlogger.cpp index bd1bc11582..6dc2135d1b 100644 --- a/src/testlib/qplaintestlogger.cpp +++ b/src/testlib/qplaintestlogger.cpp @@ -211,7 +211,7 @@ void QPlainTestLogger::outputMessage(const char *str) OutputDebugString((wchar_t*)tmp.utf16()); strUtf16.remove(0, maxOutputLength); } while (!strUtf16.isEmpty()); - if (QTestLog::outputFileName()) + if (stream != stdout) #elif defined(Q_OS_WIN) EnterCriticalSection(&QTest::outputCriticalSection); // OutputDebugString is not threadsafe -- cgit v1.2.3 From 254d7189d8ac3681ae52487513487f8a2cb7d0dc Mon Sep 17 00:00:00 2001 From: Corentin Chary Date: Wed, 31 Aug 2011 19:35:35 +0200 Subject: qssl: add auto test to QSsl::Opaque QSslKeys Also export two symbols for auto tests since opaque keys need EVP_PKEY * created by openssl. Change-Id: Ib7801ddfceb259de7291bfaa5940df87f68af97d Merge-request: 48 Reviewed-by: Peter Hartmann Reviewed-on: http://codereview.qt.nokia.com/4011 Reviewed-by: Qt Sanity Bot --- src/network/ssl/qsslsocket_openssl_symbols_p.h | 4 ++-- tests/auto/qsslsocket/qsslsocket.pro | 11 ++++++++++ tests/auto/qsslsocket/tst_qsslsocket.cpp | 30 ++++++++++++++++++++++++++ 3 files changed, 43 insertions(+), 2 deletions(-) diff --git a/src/network/ssl/qsslsocket_openssl_symbols_p.h b/src/network/ssl/qsslsocket_openssl_symbols_p.h index a1db6d9320..d1705b3680 100644 --- a/src/network/ssl/qsslsocket_openssl_symbols_p.h +++ b/src/network/ssl/qsslsocket_openssl_symbols_p.h @@ -228,13 +228,13 @@ char *q_ERR_error_string(unsigned long a, char *b); unsigned long q_ERR_get_error(); const EVP_CIPHER *q_EVP_des_ede3_cbc(); int q_EVP_PKEY_assign(EVP_PKEY *a, int b, char *c); -int q_EVP_PKEY_set1_RSA(EVP_PKEY *a, RSA *b); +Q_AUTOTEST_EXPORT int q_EVP_PKEY_set1_RSA(EVP_PKEY *a, RSA *b); int q_EVP_PKEY_set1_DSA(EVP_PKEY *a, DSA *b); void q_EVP_PKEY_free(EVP_PKEY *a); RSA *q_EVP_PKEY_get1_RSA(EVP_PKEY *a); DSA *q_EVP_PKEY_get1_DSA(EVP_PKEY *a); int q_EVP_PKEY_type(int a); -EVP_PKEY *q_EVP_PKEY_new(); +Q_AUTOTEST_EXPORT EVP_PKEY *q_EVP_PKEY_new(); int q_i2d_X509(X509 *a, unsigned char **b); const char *q_OBJ_nid2sn(int a); const char *q_OBJ_nid2ln(int a); diff --git a/tests/auto/qsslsocket/qsslsocket.pro b/tests/auto/qsslsocket/qsslsocket.pro index 76d73b7cb3..1f5c7f6aaf 100644 --- a/tests/auto/qsslsocket/qsslsocket.pro +++ b/tests/auto/qsslsocket/qsslsocket.pro @@ -15,6 +15,17 @@ win32 { } } +# OpenSSL support +contains(QT_CONFIG, openssl) | contains(QT_CONFIG, openssl-linked) { + symbian { + INCLUDEPATH *= $$OS_LAYER_SSL_SYSTEMINCLUDE + } else { + include($$QT_SOURCE_TREE/config.tests/unix/openssl/openssl.pri) + } + # Add optional SSL libs + LIBS += $$OPENSSL_LIBS +} + wince* { DEFINES += SRCDIR=\\\"./\\\" diff --git a/tests/auto/qsslsocket/tst_qsslsocket.cpp b/tests/auto/qsslsocket/tst_qsslsocket.cpp index 8b3ec3d31e..4ffcba6e65 100644 --- a/tests/auto/qsslsocket/tst_qsslsocket.cpp +++ b/tests/auto/qsslsocket/tst_qsslsocket.cpp @@ -56,6 +56,7 @@ #include "private/qhostinfo_p.h" #include "private/qsslsocket_openssl_p.h" +#include "private/qsslsocket_openssl_symbols_p.h" #include "../network-settings.h" @@ -146,6 +147,7 @@ private slots: void peerCertificate(); void peerCertificateChain(); void privateKey(); + void privateKeyOpaque(); void protocol(); void protocolServerSide_data(); void protocolServerSide(); @@ -764,6 +766,34 @@ void tst_QSslSocket::privateKey() { } +void tst_QSslSocket::privateKeyOpaque() +{ + if (!QSslSocket::supportsSsl()) + return; + + QFile file(SRCDIR "certs/fluke.key"); + QVERIFY(file.open(QIODevice::ReadOnly)); + QSslKey key(file.readAll(), QSsl::Rsa, QSsl::Pem, QSsl::PrivateKey); + QVERIFY(!key.isNull()); + + EVP_PKEY *pkey = q_EVP_PKEY_new(); + q_EVP_PKEY_set1_RSA(pkey, reinterpret_cast(key.handle())); + + // This test does not make 100% sense yet. We just set some local CA/cert/key and use it + // to authenticate ourselves against the server. The server does not actually check this + // values. This test should just run the codepath inside qsslsocket_openssl.cpp + + QSslSocketPtr socket = newSocket(); + QList localCert = QSslCertificate::fromPath(SRCDIR "certs/qt-test-server-cacert.pem"); + socket->setCaCertificates(localCert); + socket->setLocalCertificate(QLatin1String(SRCDIR "certs/fluke.cert")); + socket->setPrivateKey(QSslKey(reinterpret_cast(pkey))); + + socket->setPeerVerifyMode(QSslSocket::QueryPeer); + socket->connectToHostEncrypted(QtNetworkSettings::serverName(), 443); + QVERIFY(socket->waitForEncrypted(10000)); +} + void tst_QSslSocket::protocol() { if (!QSslSocket::supportsSsl()) -- cgit v1.2.3 From e8192883b2d00b7a1b68fb7c7154a1e75bab0b26 Mon Sep 17 00:00:00 2001 From: Shane Kearns Date: Thu, 1 Sep 2011 15:04:33 +0100 Subject: Fix comparison of absolute, unclean paths in QDir QDir::operator== was creating a clean absolute path for comparison purposes if the original path was relative. However original absolute paths were trusted, even though they could be unclean. Now they are checked for cleanliness first. Task-Number: QTBUG-19995 Task-Number: QTBUG-20495 Change-Id: I047a1a40ae5151e4604085e4ac87f30a4e4979c4 Reviewed-on: http://codereview.qt.nokia.com/4099 Reviewed-by: Qt Sanity Bot Reviewed-by: Prasanth Ullattil --- src/corelib/io/qdir.cpp | 2 +- src/corelib/io/qfilesystementry.cpp | 31 +++++++++++++++++++++ src/corelib/io/qfilesystementry_p.h | 1 + tests/auto/qdir/tst_qdir.cpp | 13 +++++++++ .../auto/qfilesystementry/tst_qfilesystementry.cpp | 32 ++++++++++++++++++++++ 5 files changed, 78 insertions(+), 1 deletion(-) diff --git a/src/corelib/io/qdir.cpp b/src/corelib/io/qdir.cpp index 49d8a7b4f7..d1c9be213b 100644 --- a/src/corelib/io/qdir.cpp +++ b/src/corelib/io/qdir.cpp @@ -190,7 +190,7 @@ inline void QDirPrivate::resolveAbsoluteEntry() const QString absoluteName; if (fileEngine.isNull()) { - if (!dirEntry.isRelative()) { + if (!dirEntry.isRelative() && dirEntry.isClean()) { absoluteDirEntry = dirEntry; return; } diff --git a/src/corelib/io/qfilesystementry.cpp b/src/corelib/io/qfilesystementry.cpp index bb7cb4e6ab..2f37542f66 100644 --- a/src/corelib/io/qfilesystementry.cpp +++ b/src/corelib/io/qfilesystementry.cpp @@ -380,4 +380,35 @@ void QFileSystemEntry::findFileNameSeparators() const } } +bool QFileSystemEntry::isClean() const +{ + resolveFilePath(); + int dots = 0; + bool dotok = true; // checking for ".." or "." starts to relative paths + bool slashok = true; + for (QString::const_iterator iter = m_filePath.constBegin(); iter != m_filePath.constEnd(); iter++) { + if (*iter == QLatin1Char('/')) { + if (dots == 1 || dots == 2) + return false; // path contains "./" or "../" + if (!slashok) + return false; // path contains "//" + dots = 0; + dotok = true; + slashok = false; + } else if (dotok) { + slashok = true; + if (*iter == QLatin1Char('.')) { + dots++; + if (dots > 2) + dotok = false; + } else { + //path element contains a character other than '.', it's clean + dots = 0; + dotok = false; + } + } + } + return (dots != 1 && dots != 2); // clean if path doesn't end in . or .. +} + QT_END_NAMESPACE diff --git a/src/corelib/io/qfilesystementry_p.h b/src/corelib/io/qfilesystementry_p.h index 34b083a03e..8d524c087e 100644 --- a/src/corelib/io/qfilesystementry_p.h +++ b/src/corelib/io/qfilesystementry_p.h @@ -91,6 +91,7 @@ public: QString completeSuffix() const; bool isAbsolute() const; bool isRelative() const; + bool isClean() const; #if defined(Q_OS_WIN) || defined(Q_OS_SYMBIAN) bool isDriveRoot() const; diff --git a/tests/auto/qdir/tst_qdir.cpp b/tests/auto/qdir/tst_qdir.cpp index 8436014c05..fd1ecd5793 100644 --- a/tests/auto/qdir/tst_qdir.cpp +++ b/tests/auto/qdir/tst_qdir.cpp @@ -1109,6 +1109,11 @@ void tst_QDir::absolutePath_data() QTest::newRow("4") << "c:/machine/share/dir1" << "c:/machine/share/dir1"; QTest::newRow("5") << "c:\\machine\\share\\dir1" << "c:/machine/share/dir1"; #endif + //test dirty paths are cleaned (QTBUG-19995) + QTest::newRow("/home/qt/.") << QDir::rootPath() + "home/qt/." << QDir::rootPath() + "home/qt"; + QTest::newRow("/system/data/../config") << QDir::rootPath() + "system/data/../config" << QDir::rootPath() + "system/config"; + QTest::newRow("//home//qt/") << QDir::rootPath() + "/home//qt/" << QDir::rootPath() + "home/qt"; + QTest::newRow("foo/../bar") << "foo/../bar" << QDir::currentPath() + "/bar"; QTest::newRow("resource") << ":/prefix/foo.bar" << ":/prefix/foo.bar"; } @@ -1872,6 +1877,14 @@ void tst_QDir::equalityOperator_data() << "./entrylist" << "*.cpp" << int(QDir::Name) << int(QDir::Files) << true; + QTest::newRow("QTBUG-20495") << QDir::currentPath() + "/entrylist/.." << "*.cpp" << int(QDir::Name) << int(QDir::Files) + << "." << "*.cpp" << int(QDir::Name) << int(QDir::Files) + << true; + + QTest::newRow("QTBUG-20495-root") << QDir::rootPath() + "tmp/.." << "*.cpp" << int(QDir::Name) << int(QDir::Files) + << QDir::rootPath() << "*.cpp" << int(QDir::Name) << int(QDir::Files) + << true; + QTest::newRow("diff-filters") << SRCDIR << "*.cpp" << int(QDir::Name) << int(QDir::Files) << SRCDIR << "*.cpp" << int(QDir::Name) << int(QDir::Dirs) << false; diff --git a/tests/auto/qfilesystementry/tst_qfilesystementry.cpp b/tests/auto/qfilesystementry/tst_qfilesystementry.cpp index 016bcbfe8a..2daabee48f 100644 --- a/tests/auto/qfilesystementry/tst_qfilesystementry.cpp +++ b/tests/auto/qfilesystementry/tst_qfilesystementry.cpp @@ -68,6 +68,8 @@ private slots: void absoluteOrRelative_data(); void absoluteOrRelative(); #endif + void isClean_data(); + void isClean(); }; #if defined(WIN_STUFF) @@ -383,5 +385,35 @@ void tst_QFileSystemEntry::absoluteOrRelative() } #endif +void tst_QFileSystemEntry::isClean_data() +{ + QTest::addColumn("path"); + QTest::addColumn("isClean"); + + QTest::newRow("simple") << "foo" << true; + QTest::newRow("complex") << "/foo/bar/bz" << true; + QTest::newRow(".file") << "/foo/.file" << true; + QTest::newRow("..file") << "/foo/..file" << true; + QTest::newRow("...") << "/foo/.../bar" << true; + QTest::newRow("./") << "./" << false; + QTest::newRow("../") << "../" << false; + QTest::newRow(".") << "." << false; + QTest::newRow("..") << ".." << false; + QTest::newRow("/.") << "/." << false; + QTest::newRow("/..") << "/.." << false; + QTest::newRow("/../") << "foo/../bar" << false; + QTest::newRow("/./") << "foo/./bar" << false; + QTest::newRow("//") << "foo//bar" << false; +} + +void tst_QFileSystemEntry::isClean() +{ + QFETCH(QString, path); + QFETCH(bool, isClean); + + QFileSystemEntry fi(path); + QCOMPARE(fi.isClean(), isClean); +} + QTEST_MAIN(tst_QFileSystemEntry) #include -- cgit v1.2.3 From 7493ee1c44a16dc3b155a5bf3ed7ca966a71072a Mon Sep 17 00:00:00 2001 From: "Bradley T. Hughes" Date: Wed, 31 Aug 2011 14:23:42 +0200 Subject: Remove the build-key from the plugin verification data The build-key is an old mechanism to work around binary incompatibilities in GCC 3.x versions. Modern GCC has not broken binary compatibility since 3.4, making this mechanism obsolete. The cache value stored now only includes Qt version, the debug/release boolean, and the last modified time for the plugin. Old 4-value keys will be replaced with new keys as the plugins are reloaded the first time. This also removes QLibraryInfo::buildKey(), which is a source-incompatible change. The UNIX and Windows configure tools have been updated to stop outputting the QT_BUILD_KEY preprocessor directive. See also: http://lists.qt.nokia.com/pipermail/qt5-feedback/2011-August/000892.html Change-Id: I7d06969a370d3d2c6de413c1230d9d6789cbf195 Reviewed-on: http://codereview.qt.nokia.com/3977 Reviewed-by: Qt Sanity Bot Reviewed-by: Bradley T. Hughes --- configure | 260 +---------------------- dist/changes-5.0.0 | 4 + src/corelib/global/qglobal.h | 7 - src/corelib/global/qlibraryinfo.cpp | 27 --- src/corelib/global/qlibraryinfo.h | 1 - src/corelib/plugin/qlibrary.cpp | 56 +---- src/corelib/plugin/qplugin.h | 3 +- tests/baselineserver/shared/baselineprotocol.cpp | 2 - tests/baselineserver/shared/baselineprotocol.h | 1 - tools/configure/configureapp.cpp | 59 +---- 10 files changed, 19 insertions(+), 401 deletions(-) diff --git a/configure b/configure index 83d5662912..0344057730 100755 --- a/configure +++ b/configure @@ -781,7 +781,6 @@ CFG_AVX=auto CFG_REDUCE_RELOCATIONS=no CFG_NAS=no CFG_QWS_DEPTHS=all -CFG_USER_BUILD_KEY= CFG_ACCESSIBILITY=auto CFG_QT3SUPPORT=no CFG_ENDIAN=auto @@ -1059,7 +1058,7 @@ while [ "$#" -gt 0 ]; do shift VAL=$1 ;; - -prefix|-docdir|-headerdir|-plugindir|-importdir|-datadir|-libdir|-bindir|-translationdir|-sysconfdir|-examplesdir|-depths|-make|-nomake|-platform|-xplatform|-buildkey|-sdk|-arch|-host-arch|-mysql_config) + -prefix|-docdir|-headerdir|-plugindir|-importdir|-datadir|-libdir|-bindir|-translationdir|-sysconfdir|-examplesdir|-depths|-make|-nomake|-platform|-xplatform|-sdk|-arch|-host-arch|-mysql_config) VAR=`echo $1 | sed "s,^-\(.*\),\1,"` shift VAL="$1" @@ -1322,9 +1321,6 @@ while [ "$#" -gt 0 ]; do bindir) QT_INSTALL_BINS="$VAL" ;; - buildkey) - CFG_USER_BUILD_KEY="$VAL" - ;; sxe) CFG_SXE="$VAL" ;; @@ -3722,7 +3718,7 @@ if [ "$OPT_HELP" = "yes" ]; then Usage: $relconf [-h] [-prefix ] [-prefix-install] [-bindir ] [-libdir ] [-docdir ] [-headerdir ] [-plugindir ] [-importdir ] [-datadir ] [-translationdir ] [-sysconfdir ] [-examplesdir ] - [-buildkey ] [-release] [-debug] [-debug-and-release] + [-release] [-debug] [-debug-and-release] [-developer-build] [-shared] [-static] [-no-fast] [-fast] [-no-largefile] [-largefile] [-no-exceptions] [-exceptions] [-no-accessibility] [-accessibility] [-no-stl] [-stl] [-no-sql-] [-sql-] @@ -3800,12 +3796,6 @@ cat < .... Examples will be installed to (default PREFIX/examples) - You may use these options to turn on strict plugin loading. - - -buildkey .... Build the Qt library and plugins using the specified - . When the library loads plugins, it will only - load those that have a matching key. - Configure options: The defaults (*) are usually acceptable. A plus (+) denotes a default value @@ -7736,226 +7726,6 @@ if [ "$PLATFORM_MAC" = "yes" ] && [ "$CFG_MAC_XARCH" != "no" ] ; then fi fi -#------------------------------------------------------------------------------- -# generate QT_BUILD_KEY -#------------------------------------------------------------------------------- - -# some compilers generate binary incompatible code between different versions, -# so we need to generate a build key that is different between these compilers -COMPAT_COMPILER= -case "$COMPILER" in -g++*) - # GNU C++ - COMPILER_VERSION=`${QMAKE_CONF_COMPILER} -dumpversion 2>/dev/null` - - case "$COMPILER_VERSION" in - *.*.*) - QT_GCC_MAJOR_VERSION=`echo $COMPILER_VERSION | sed 's,^\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\).*,\1,'` - QT_GCC_MINOR_VERSION=`echo $COMPILER_VERSION | sed 's,^\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\).*,\2,'` - QT_GCC_PATCH_VERSION=`echo $COMPILER_VERSION | sed 's,^\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\).*,\3,'` - ;; - *.*) - QT_GCC_MAJOR_VERSION=`echo $COMPILER_VERSION | sed 's,^\([0-9]*\)\.\([0-9]*\).*,\1,'` - QT_GCC_MINOR_VERSION=`echo $COMPILER_VERSION | sed 's,^\([0-9]*\)\.\([0-9]*\).*,\2,'` - QT_GCC_PATCH_VERSION=0 - ;; - esac - - case "$COMPILER_VERSION" in - 2.95.*) - COMPILER_VERSION="2.95.*" - ;; - 3.*) - COMPILER_VERSION="3.*" - ;; - 4.*) - COMPILER_VERSION="4" - ;; - *) - ;; - esac - [ '!' -z "$COMPILER_VERSION" ] && COMPILER="g++-${COMPILER_VERSION}" - ;; -icc*) - # The Intel CC compiler on Unix systems matches the ABI of the g++ - # that is found on PATH - COMPAT_COMPILER="icc" - COMPILER="g++-4" - case "`g++ -dumpversion` 2>/dev/null" in - 2.95.*) - COMPILER="g++-2.95.*" - ;; - 3.*) -a COMPILER="g++-3.*" - ;; - *) - ;; - esac - ;; -*) - # - ;; -esac - -# QT_CONFIG can contain the following: -# -# Things that affect the Qt API/ABI: -# -# Options: -# minimal-config small-config medium-config large-config full-config -# -# Different edition modules: -# gui network canvas table xml opengl sql -# -# Things that do not affect the Qt API/ABI: -# stl -# system-jpeg no-jpeg jpeg -# system-mng no-mng mng -# system-png no-png png -# system-zlib no-zlib zlib -# system-libtiff no-libtiff -# no-gif gif -# debug release -# dll staticlib -# -# nocrosscompiler -# GNUmake -# largefile -# nis -# nas -# tablet -# ipv6 -# -# X11 : x11sm xinerama xcursor xfixes xrandr xrender mitshm fontconfig xkb -# Embedded: embedded qpa freetype -# -ALL_OPTIONS= -BUILD_CONFIG= -BUILD_OPTIONS= - -# determine the build options -for config_option in $QMAKE_CONFIG $QT_CONFIG; do - SKIP="yes" - case "$config_option" in - *-config) - # take the last *-config setting. this is the highest config being used, - # and is the one that we will use for tagging plugins - BUILD_CONFIG="$config_option" - ;; - - *) # skip all other options since they don't affect the Qt API/ABI. - ;; - esac - - if [ "$SKIP" = "no" ]; then - BUILD_OPTIONS="$BUILD_OPTIONS $config_option" - fi -done - -# put the options that we are missing into .options -rm -f .options -for opt in `echo $ALL_OPTIONS`; do - SKIP="no" - if echo $BUILD_OPTIONS | grep $opt >/dev/null 2>&1; then - SKIP="yes" - fi - if [ "$SKIP" = "no" ]; then - echo "$opt" >> .options - fi -done - -# reconstruct BUILD_OPTIONS with a sorted negative feature list -# (ie. only things that are missing are will be put into the build key) -BUILD_OPTIONS= -if [ -f .options ]; then - for opt in `sort -f .options | uniq`; do - BUILD_OPTIONS="$BUILD_OPTIONS no-$opt" - done -fi -rm -f .options - -# QT_NO* defines affect the Qt API (and binary compatibility). they need -# to be included in the build key -for build_option in $D_FLAGS; do - build_option=`echo $build_option | cut -d \" -f 2 -` - case "$build_option" in - QT_NO*) - echo "$build_option" >> .options - ;; - *) - # skip all other compiler defines - ;; - esac -done - -# sort the compile time defines (helps ensure that changes in this configure -# script don't affect the QT_BUILD_KEY generation) -if [ -f .options ]; then - for opt in `sort -f .options | uniq`; do - BUILD_OPTIONS="$BUILD_OPTIONS $opt" - done -fi -rm -f .options - -BUILD_OPTIONS="$BUILD_CONFIG $BUILD_OPTIONS" -# extract the operating system from the XPLATFORM -TARGET_OPERATING_SYSTEM=`echo $XPLATFORM | cut -f 2- -d/ | cut -f -1 -d-` -if [ "$XPLATFORM_SYMBIAN" = "yes" ]; then - QT_BUILD_KEY_SYSTEM_PART="Symbian" -else - QT_BUILD_KEY_SYSTEM_PART="$CFG_ARCH $TARGET_OPERATING_SYSTEM $COMPILER" -fi - -# when cross-compiling, don't include build-host information (build key is target specific) -QT_BUILD_KEY="$CFG_USER_BUILD_KEY $QT_BUILD_KEY_SYSTEM_PART $BUILD_OPTIONS" -if [ -n "$QT_NAMESPACE" ]; then - QT_BUILD_KEY="$QT_BUILD_KEY $QT_NAMESPACE" -fi -MAC_NEED_TWO_BUILD_KEYS="no" -if [ "$PLATFORM_MAC" = "yes" -a "$CFG_MAC_COCOA" = "yes" ]; then - QT_BUILD_KEY_CARBON=$QT_BUILD_KEY - TARGET_OPERATING_SYSTEM="$TARGET_OPERATING_SYSTEM-cocoa" - QT_BUILD_KEY_COCOA="$CFG_USER_BUILD_KEY $CFG_ARCH $TARGET_OPERATING_SYSTEM $COMPILER $BUILD_OPTIONS" - if [ "$CFG_MAC_CARBON" = "no" ]; then - QT_BUILD_KEY=$QT_BUILD_KEY_COCOA - else - MAC_NEED_TWO_BUILD_KEYS="yes" - fi -fi -# don't break loading plugins build with an older version of Qt -QT_BUILD_KEY_COMPAT= -if [ "$QT_CROSS_COMPILE" = "no" ]; then - # previous versions of Qt used a build key built from the uname - QT_BUILD_KEY_COMPAT="$CFG_USER_BUILD_KEY $UNAME_MACHINE $UNAME_SYSTEM $COMPILER $BUILD_OPTIONS" - if [ -n "$QT_NAMESPACE" ]; then - QT_BUILD_KEY_COMPAT="$QT_BUILD_KEY_COMPAT $QT_NAMESPACE" - fi -fi - -# is this compiler compatible with some other "standard" build key -QT_BUILD_KEY_COMPAT_COMPILER= -if [ ! -z "$COMPAT_COMPILER" ]; then - QT_BUILD_KEY_COMPAT_COMPILER="$CFG_USER_BUILD_KEY $CFG_ARCH $TARGET_OPERATING_SYSTEM $COMPAT_COMPILER $BUILD_OPTIONS" - if [ -n "$QT_NAMESPACE" ]; then - QT_BUILD_KEY_COMPAT_COMPILER="$QT_BUILD_KEY_COMPAT_COMPILER $QT_NAMESPACE" - fi -fi - -# is this arch compatible with some other "standard" build key -QT_BUILD_KEY_COMPAT_ARCH= -if [ ! -z "$COMPAT_ARCH" ]; then - QT_BUILD_KEY_COMPAT_ARCH="$CFG_USER_BUILD_KEY $COMPAT_ARCH $TARGET_OPERATING_SYSTEM $COMPILER $BUILD_OPTIONS" - if [ -n "$QT_NAMESPACE" ]; then - QT_BUILD_KEY_COMPAT_COMPILER="$QT_BUILD_KEY_COMPAT_ARCH $QT_NAMESPACE" - fi -fi - -# strip out leading/trailing/extra whitespace -QT_BUILD_KEY=`echo $QT_BUILD_KEY | sed -e "s, *, ,g" -e "s,^ *,," -e "s, *$,,"` -QT_BUILD_KEY_COMPAT=`echo $QT_BUILD_KEY_COMPAT | sed -e "s, *, ,g" -e "s,^ *,," -e "s, *$,,"` -QT_BUILD_KEY_COMPAT_COMPILER=`echo $QT_BUILD_KEY_COMPAT_COMPILER | sed -e "s, *, ,g" -e "s,^ *,," -e "s, *$,,"` -QT_BUILD_KEY_COMPAT_ARCH=`echo $QT_BUILD_KEY_COMPAT_ARCH | sed -e "s, *, ,g" -e "s,^ *,," -e "s, *$,,"` - #------------------------------------------------------------------------------- # part of configuration information goes into qconfig.h #------------------------------------------------------------------------------- @@ -7988,32 +7758,6 @@ cat >>"$outpath/src/corelib/global/qconfig.h.new" <> "$outpath/src/corelib/global/qconfig.h.new" -else - cat >>"$outpath/src/corelib/global/qconfig.h.new" <> "$outpath/src/corelib/global/qconfig.h.new" -fi -if [ -n "$QT_BUILD_KEY_COMPAT_COMPILER" ]; then - echo "#define QT_BUILD_KEY_COMPAT2 \"$QT_BUILD_KEY_COMPAT_COMPILER\"" \ - >> "$outpath/src/corelib/global/qconfig.h.new" -fi -if [ -n "$QT_BUILD_KEY_COMPAT_ARCH" ]; then - echo "#define QT_BUILD_KEY_COMPAT3 \"$QT_BUILD_KEY_COMPAT_ARCH\"" \ - >> "$outpath/src/corelib/global/qconfig.h.new" -fi - -echo "" >>"$outpath/src/corelib/global/qconfig.h.new" - echo "#ifdef QT_BOOTSTRAPPED" >>"$outpath/src/corelib/global/qconfig.h.new" if [ "$CFG_HOST_ENDIAN" = "auto" ]; then cat >>"$outpath/src/corelib/global/qconfig.h.new" < 0); @@ -337,11 +333,11 @@ static long qt_find_pattern(const char *s, ulong s_len, we can get the verification data without have to actually load the library. This lets us detect mismatches more safely. - Returns false if version/key information is not present, or if the + Returns false if version information is not present, or if the information could not be read. - Returns true if version/key information is present and successfully read. + Returns true if version information is present and successfully read. */ -static bool qt_unix_query(const QString &library, uint *version, bool *debug, QByteArray *key, QLibraryPrivate *lib = 0) +static bool qt_unix_query(const QString &library, uint *version, bool *debug, QLibraryPrivate *lib = 0) { QFile file(library); if (!file.open(QIODevice::ReadOnly)) { @@ -396,7 +392,7 @@ static bool qt_unix_query(const QString &library, uint *version, bool *debug, QB #endif // defined(Q_OF_ELF) && defined(Q_CC_GNU) bool ret = false; if (pos >= 0) - ret = qt_parse_pattern(filedata + pos, version, debug, key); + ret = qt_parse_pattern(filedata + pos, version, debug); if (!ret && lib) lib->errorString = QLibrary::tr("Plugin verification data mismatch in '%1'").arg(library); @@ -636,7 +632,7 @@ typedef const char * __stdcall (*QtPluginQueryVerificationDataFunction)(); typedef const char * (*QtPluginQueryVerificationDataFunction)(); #endif -bool qt_get_verificationdata(QtPluginQueryVerificationDataFunction pfn, uint *qt_version, bool *debug, QByteArray *key, bool *exceptionThrown) +bool qt_get_verificationdata(QtPluginQueryVerificationDataFunction pfn, uint *qt_version, bool *debug, bool *exceptionThrown) { *exceptionThrown = false; const char *szData = 0; @@ -649,7 +645,7 @@ bool qt_get_verificationdata(QtPluginQueryVerificationDataFunction pfn, uint *qt #else szData = pfn(); #endif - return qt_parse_pattern(szData, qt_version, debug, key); + return qt_parse_pattern(szData, qt_version, debug); } bool QLibraryPrivate::isPlugin(QSettings *settings) @@ -660,7 +656,6 @@ bool QLibraryPrivate::isPlugin(QSettings *settings) #ifndef QT_NO_PLUGIN_CHECK bool debug = !QLIBRARY_AS_DEBUG; - QByteArray key; bool success = false; #if defined(Q_OS_UNIX) && !defined(Q_OS_MAC) @@ -710,16 +705,15 @@ bool QLibraryPrivate::isPlugin(QSettings *settings) } reg = settings->value(regkey).toStringList(); #endif - if (reg.count() == 4 && lastModified == reg.at(3)) { + if (reg.count() == 3 && lastModified == reg.at(2)) { qt_version = reg.at(0).toUInt(0, 16); debug = bool(reg.at(1).toInt()); - key = reg.at(2).toLatin1(); success = qt_version != 0; } else { #if defined(Q_OS_UNIX) && !defined(Q_OS_MAC) && !defined(Q_OS_SYMBIAN) if (!pHnd) { // use unix shortcut to avoid loading the library - success = qt_unix_query(fileName, &qt_version, &debug, &key, this); + success = qt_unix_query(fileName, &qt_version, &debug, this); } else #endif { @@ -767,11 +761,10 @@ bool QLibraryPrivate::isPlugin(QSettings *settings) #endif bool exceptionThrown = false; bool ret = qt_get_verificationdata(qtPluginQueryVerificationDataFunction, - &qt_version, &debug, &key, &exceptionThrown); + &qt_version, &debug, &exceptionThrown); if (!exceptionThrown) { if (!ret) { qt_version = 0; - key = "unknown"; if (temporary_load) unload_sys(); } else { @@ -801,14 +794,10 @@ bool QLibraryPrivate::isPlugin(QSettings *settings) // exception is thrown(will happen only when using a MS compiler) } - // Qt 4.5 compatibility: stl doesn't affect binary compatibility - key.replace(" no-stl", ""); - #ifndef QT_NO_SETTINGS QStringList queried; queried << QString::number(qt_version,16) << QString::number((int)debug) - << QLatin1String(key) << lastModified; settings->setValue(regkey, queried); #endif @@ -840,31 +829,6 @@ bool QLibraryPrivate::isPlugin(QSettings *settings) .arg((qt_version&0xff00) >> 8) .arg(qt_version&0xff) .arg(debug ? QLatin1String("debug") : QLatin1String("release")); - } else if (key != QT_BUILD_KEY - // we may have some compatibility keys, try them too: -#ifdef QT_BUILD_KEY_COMPAT - && key != QT_BUILD_KEY_COMPAT -#endif -#ifdef QT_BUILD_KEY_COMPAT2 - && key != QT_BUILD_KEY_COMPAT2 -#endif -#ifdef QT_BUILD_KEY_COMPAT3 - && key != QT_BUILD_KEY_COMPAT3 -#endif - ) { - if (qt_debug_component()) { - qWarning("In %s:\n" - " Plugin uses incompatible Qt library\n" - " expected build key \"%s\", got \"%s\"", - (const char*) QFile::encodeName(fileName), - QT_BUILD_KEY, - key.isEmpty() ? "" : (const char *) key); - } - errorString = QLibrary::tr("The plugin '%1' uses incompatible Qt library." - " Expected build key \"%2\", got \"%3\"") - .arg(fileName) - .arg(QLatin1String(QT_BUILD_KEY)) - .arg(key.isEmpty() ? QLatin1String("") : QLatin1String((const char *) key)); #ifndef QT_NO_DEBUG_PLUGIN_CHECK } else if(debug != QLIBRARY_AS_DEBUG) { //don't issue a qWarning since we will hopefully find a non-debug? --Sam diff --git a/src/corelib/plugin/qplugin.h b/src/corelib/plugin/qplugin.h index 40e6e66de3..52661671b5 100644 --- a/src/corelib/plugin/qplugin.h +++ b/src/corelib/plugin/qplugin.h @@ -117,8 +117,7 @@ void Q_CORE_EXPORT qRegisterStaticPluginInstanceFunction(QtPluginInstanceFunctio static const char qt_plugin_verification_data[] = \ "pattern=""QT_PLUGIN_VERIFICATION_DATA""\n" \ "version="QT_VERSION_STR"\n" \ - "debug="QPLUGIN_DEBUG_STR"\n" \ - "buildkey="QT_BUILD_KEY; + "debug="QPLUGIN_DEBUG_STR; # if defined (Q_OF_ELF) && defined (Q_CC_GNU) # define Q_PLUGIN_VERIFICATION_SECTION \ diff --git a/tests/baselineserver/shared/baselineprotocol.cpp b/tests/baselineserver/shared/baselineprotocol.cpp index 630ca88e5b..9cbf67856d 100644 --- a/tests/baselineserver/shared/baselineprotocol.cpp +++ b/tests/baselineserver/shared/baselineprotocol.cpp @@ -56,7 +56,6 @@ const QString PI_HostAddress(QLS("HostAddress")); const QString PI_OSName(QLS("OSName")); const QString PI_OSVersion(QLS("OSVersion")); const QString PI_QtVersion(QLS("QtVersion")); -const QString PI_BuildKey(QLS("BuildKey")); const QString PI_GitCommit(QLS("GitCommit")); const QString PI_QMakeSpec(QLS("QMakeSpec")); const QString PI_PulseGitBranch(QLS("PulseGitBranch")); @@ -93,7 +92,6 @@ PlatformInfo PlatformInfo::localHostInfo() pi.insert(PI_HostName, QHostInfo::localHostName()); pi.insert(PI_QtVersion, QLS(qVersion())); pi.insert(PI_QMakeSpec, QString(QLS(QMAKESPEC)).remove(QRegExp(QLS("^.*mkspecs/")))); - pi.insert(PI_BuildKey, QLibraryInfo::buildKey()); #if defined(Q_OS_LINUX) pi.insert(PI_OSName, QLS("Linux")); QProcess uname; diff --git a/tests/baselineserver/shared/baselineprotocol.h b/tests/baselineserver/shared/baselineprotocol.h index 0b08e444fd..cc501e1d53 100644 --- a/tests/baselineserver/shared/baselineprotocol.h +++ b/tests/baselineserver/shared/baselineprotocol.h @@ -61,7 +61,6 @@ extern const QString PI_HostAddress; extern const QString PI_OSName; extern const QString PI_OSVersion; extern const QString PI_QtVersion; -extern const QString PI_BuildKey; extern const QString PI_GitCommit; extern const QString PI_QMakeSpec; extern const QString PI_PulseGitBranch; diff --git a/tools/configure/configureapp.cpp b/tools/configure/configureapp.cpp index 3b7f190736..afaab16f93 100644 --- a/tools/configure/configureapp.cpp +++ b/tools/configure/configureapp.cpp @@ -495,13 +495,6 @@ void Configure::parseCmdLine() dictionary[ "QCONFIG" ] = configCmdLine.at(i); } - else if (configCmdLine.at(i) == "-buildkey") { - ++i; - if (i == argCount) - break; - dictionary[ "USER_BUILD_KEY" ] = configCmdLine.at(i); - } - else if (configCmdLine.at(i) == "-release") { dictionary[ "BUILD" ] = "release"; if (dictionary[ "BUILDALL" ] == "auto") @@ -1661,11 +1654,11 @@ QString Configure::locateFile(const QString &fileName) bool Configure::displayHelp() { if (dictionary[ "HELP" ] == "yes") { - desc("Usage: configure [-buildkey ]\n" + desc("Usage: configure\n" // desc("Usage: configure [-prefix dir] [-bindir ] [-libdir ]\n" // "[-docdir ] [-headerdir ] [-plugindir ]\n" // "[-importdir ] [-datadir ] [-translationdir ]\n" -// "[-examplesdir ] [-buildkey ]\n" +// "[-examplesdir ]\n" "[-release] [-debug] [-debug-and-release] [-shared] [-static]\n" "[-no-fast] [-fast] [-no-exceptions] [-exceptions]\n" "[-no-accessibility] [-accessibility] [-no-rtti] [-rtti]\n" @@ -1711,10 +1704,6 @@ bool Configure::displayHelp() desc( "-translationdir ","Translations of Qt programs will be installed to dir\n(default PREFIX/translations)\n"); desc( "-examplesdir ", "Examples will be installed to dir\n(default PREFIX/examples)"); */ - desc(" You may use these options to turn on strict plugin loading:\n\n", 0, 1); - - desc( "-buildkey ", "Build the Qt library and plugins using the specified . " - "When the library loads plugins, it will only load those that have a matching .\n"); desc("Configure options:\n\n"); @@ -2470,53 +2459,11 @@ void Configure::generateBuildKey() // Sorted defines that start with QT_NO_ QStringList build_defines = qmakeDefines.filter(QRegExp("^QT_NO_")); build_defines.sort(); - - // Build up the QT_BUILD_KEY ifdef - QString buildKey = "QT_BUILD_KEY \""; - if (!dictionary["USER_BUILD_KEY"].isEmpty()) - buildKey += dictionary["USER_BUILD_KEY"] + " "; - - QString build32Key = buildKey + "Windows " + compiler + " %1 " + build_options.join(" ") + " " + build_defines.join(" "); - QString build64Key = buildKey + "Windows x64 " + compiler + " %1 " + build_options.join(" ") + " " + build_defines.join(" "); - QString buildSymbianKey = buildKey + "Symbian " + build_options.join(" ") + " " + build_defines.join(" "); - build32Key = build32Key.simplified(); - build64Key = build64Key.simplified(); - buildSymbianKey = buildSymbianKey.simplified(); - build32Key.prepend("# define "); - build64Key.prepend("# define "); - buildSymbianKey.prepend("# define "); - - QString buildkey = "#if defined(__SYMBIAN32__)\n" - + buildSymbianKey + "\"\n" - "#else\n" - // Debug builds - "# if !defined(QT_NO_DEBUG)\n" - "# if (defined(WIN64) || defined(_WIN64) || defined(__WIN64__))\n" - + build64Key.arg("debug") + "\"\n" - "# else\n" - + build32Key.arg("debug") + "\"\n" - "# endif\n" - "# else\n" - // Release builds - "# if (defined(WIN64) || defined(_WIN64) || defined(__WIN64__))\n" - + build64Key.arg("release") + "\"\n" - "# else\n" - + build32Key.arg("release") + "\"\n" - "# endif\n" - "# endif\n" - "#endif\n"; - - dictionary["BUILD_KEY"] = buildkey; } void Configure::generateOutputVars() { // Generate variables for output - // Build key ---------------------------------------------------- - if (dictionary.contains("BUILD_KEY")) { - qmakeVars += dictionary.value("BUILD_KEY"); - } - QString build = dictionary[ "BUILD" ]; bool buildAll = (dictionary[ "BUILDALL" ] == "yes"); if (build == "debug") { @@ -3141,8 +3088,6 @@ void Configure::generateConfigfiles() tmpStream << "# define QT_EDITION " << dictionary["QT_EDITION"] << endl; tmpStream << "#endif" << endl; tmpStream << endl; - tmpStream << dictionary["BUILD_KEY"]; - tmpStream << endl; if (dictionary["BUILDDEV"] == "yes") { dictionary["QMAKE_INTERNAL"] = "yes"; tmpStream << "/* Used for example to export symbols for the certain autotests*/" << endl; -- cgit v1.2.3 From f5501c0f3b237a8181820e65f3bfa693475b22b4 Mon Sep 17 00:00:00 2001 From: Kent Hansen Date: Tue, 30 Aug 2011 13:36:52 +0200 Subject: Update our V8 Change-Id: I8925815c068d697999955c45de9f0736ad31ed56 Reviewed-on: http://codereview.qt.nokia.com/3880 Reviewed-by: Kent Hansen Reviewed-by: Qt Sanity Bot --- src/3rdparty/v8 | 2 +- ...shing-and-comparison-methods-to-v8-String.patch | 4 +- src/v8/0002-Add-a-bit-field-3-to-Map.patch | 4 +- ...back-mode-for-named-property-interceptors.patch | 4 +- ...0004-Generalize-external-object-resources.patch | 4 +- src/v8/0005-Introduce-a-QML-compilation-mode.patch | 4 +- ...6-Allow-access-to-the-calling-script-data.patch | 4 +- src/v8/0007-Fix-warnings.patch | 4 +- .../0008-Add-custom-object-compare-callback.patch | 4 +- ...unction-method-to-the-Object-class-in-the.patch | 7 +-- ...allAsConstructor-method-for-Object-in-the.patch | 7 +-- ...-Add-new-v8-api-to-check-if-a-value-is-an.patch | 5 ++- ...d-IsCallable-method-for-Object-in-the-API.patch | 7 +-- .../0013-Remove-execute-flag-from-v8-debug.h.patch | 4 +- ...d-error-suggest-parentheses-around-within.patch | 25 +++++++++++ ...compatibility-where-the-String-Equals-ove.patch | 25 +++++++++++ src/v8/0016-Fix-deprecated-Python-code.patch | 50 ++++++++++++++++++++++ 17 files changed, 134 insertions(+), 30 deletions(-) create mode 100644 src/v8/0014-Fix-build-error-suggest-parentheses-around-within.patch create mode 100644 src/v8/0015-Fix-source-compatibility-where-the-String-Equals-ove.patch create mode 100644 src/v8/0016-Fix-deprecated-Python-code.patch diff --git a/src/3rdparty/v8 b/src/3rdparty/v8 index dc2cad4f8f..97cb46d421 160000 --- a/src/3rdparty/v8 +++ b/src/3rdparty/v8 @@ -1 +1 @@ -Subproject commit dc2cad4f8fc88c52fcea09b8d0262d35cd32dc44 +Subproject commit 97cb46d421faebd2b139570bcf9aaf2d5eadc333 diff --git a/src/v8/0001-Add-hashing-and-comparison-methods-to-v8-String.patch b/src/v8/0001-Add-hashing-and-comparison-methods-to-v8-String.patch index 54a35fda9f..4ec44e3547 100644 --- a/src/v8/0001-Add-hashing-and-comparison-methods-to-v8-String.patch +++ b/src/v8/0001-Add-hashing-and-comparison-methods-to-v8-String.patch @@ -1,7 +1,7 @@ From e13ce09287a56c920d5ffdc5d4662d49f1838f16 Mon Sep 17 00:00:00 2001 From: Aaron Kennedy Date: Mon, 23 May 2011 15:47:20 +1000 -Subject: [PATCH 01/13] Add hashing and comparison methods to v8::String +Subject: [PATCH 01/16] Add hashing and comparison methods to v8::String This allows us to more rapidly search for a v8::String inside a hash of QStrings. @@ -339,5 +339,5 @@ index e966b3d..6e26f57 100644 // Maximal memory usage for a single sequential two-byte string. -- -1.7.2.3 +1.7.6 diff --git a/src/v8/0002-Add-a-bit-field-3-to-Map.patch b/src/v8/0002-Add-a-bit-field-3-to-Map.patch index dda9fa0dff..4b21317668 100644 --- a/src/v8/0002-Add-a-bit-field-3-to-Map.patch +++ b/src/v8/0002-Add-a-bit-field-3-to-Map.patch @@ -1,7 +1,7 @@ From 7c9cfff80b7864d5687432d424074e51712c4a07 Mon Sep 17 00:00:00 2001 From: Aaron Kennedy Date: Mon, 23 May 2011 15:55:26 +1000 -Subject: [PATCH 02/13] Add a bit field 3 to Map +Subject: [PATCH 02/16] Add a bit field 3 to Map Bit field 3 will be used to add QML specific map flags. --- @@ -114,5 +114,5 @@ index 6e26f57..07e1089 100644 static const int kCodeCacheEntrySize = 2; static const int kCodeCacheEntryNameOffset = 0; -- -1.7.2.3 +1.7.6 diff --git a/src/v8/0003-Add-a-fallback-mode-for-named-property-interceptors.patch b/src/v8/0003-Add-a-fallback-mode-for-named-property-interceptors.patch index 50f97c7de8..27529ff3da 100644 --- a/src/v8/0003-Add-a-fallback-mode-for-named-property-interceptors.patch +++ b/src/v8/0003-Add-a-fallback-mode-for-named-property-interceptors.patch @@ -1,7 +1,7 @@ From ae8688b53d67044f2c9b0cce25fc282b078610c1 Mon Sep 17 00:00:00 2001 From: Aaron Kennedy Date: Mon, 23 May 2011 16:21:02 +1000 -Subject: [PATCH 03/13] Add a "fallback" mode for named property interceptors +Subject: [PATCH 03/16] Add a "fallback" mode for named property interceptors By default interceptors are called before the normal property resolution on objects. When an interceptor is installed as a @@ -360,5 +360,5 @@ index 7335da8..660352c 100644 return isolate->heap()->undefined_value(); } -- -1.7.2.3 +1.7.6 diff --git a/src/v8/0004-Generalize-external-object-resources.patch b/src/v8/0004-Generalize-external-object-resources.patch index f44e7b2134..a05aad0889 100644 --- a/src/v8/0004-Generalize-external-object-resources.patch +++ b/src/v8/0004-Generalize-external-object-resources.patch @@ -1,7 +1,7 @@ From 4827116b12c50f6662794017c5a662b5dbb2da0b Mon Sep 17 00:00:00 2001 From: Aaron Kennedy Date: Mon, 23 May 2011 16:55:35 +1000 -Subject: [PATCH 04/13] Generalize external object resources +Subject: [PATCH 04/16] Generalize external object resources V8 was already able to manage and finalize an external string resource. This change generalizes that mechanism to handle a @@ -890,5 +890,5 @@ index a209cd0..1bdb5c7 100644 -- -1.7.2.3 +1.7.6 diff --git a/src/v8/0005-Introduce-a-QML-compilation-mode.patch b/src/v8/0005-Introduce-a-QML-compilation-mode.patch index b464e61266..3c1cab2497 100644 --- a/src/v8/0005-Introduce-a-QML-compilation-mode.patch +++ b/src/v8/0005-Introduce-a-QML-compilation-mode.patch @@ -1,7 +1,7 @@ From fd7d475e298e5b63cd6383c78cc900635c82aa38 Mon Sep 17 00:00:00 2001 From: Aaron Kennedy Date: Mon, 23 May 2011 18:26:19 +1000 -Subject: [PATCH 05/13] Introduce a QML compilation mode +Subject: [PATCH 05/16] Introduce a QML compilation mode In QML mode, there is a second global object - known as the QML global object. During property resolution, if a property is not @@ -1773,5 +1773,5 @@ index 4c17720..aa284ed 100644 static inline Operand StackSpaceOperand(int index) { #ifdef _WIN64 -- -1.7.2.3 +1.7.6 diff --git a/src/v8/0006-Allow-access-to-the-calling-script-data.patch b/src/v8/0006-Allow-access-to-the-calling-script-data.patch index d4acdf7a42..50529d67b1 100644 --- a/src/v8/0006-Allow-access-to-the-calling-script-data.patch +++ b/src/v8/0006-Allow-access-to-the-calling-script-data.patch @@ -1,7 +1,7 @@ From f890f0d1a1e5bd62711815489c87755a4f382436 Mon Sep 17 00:00:00 2001 From: Aaron Kennedy Date: Wed, 25 May 2011 10:36:13 +1000 -Subject: [PATCH 06/13] Allow access to the calling script data +Subject: [PATCH 06/16] Allow access to the calling script data --- include/v8.h | 1 + @@ -44,5 +44,5 @@ index 39767f4..ff74efb 100644 v8::Local Context::Global() { if (IsDeadCheck(i::Isolate::Current(), "v8::Context::Global()")) { -- -1.7.2.3 +1.7.6 diff --git a/src/v8/0007-Fix-warnings.patch b/src/v8/0007-Fix-warnings.patch index 26141c8ae8..fe6fa59517 100644 --- a/src/v8/0007-Fix-warnings.patch +++ b/src/v8/0007-Fix-warnings.patch @@ -1,7 +1,7 @@ From dac5d9db84cf20564621c679937ca7b9c6a8e880 Mon Sep 17 00:00:00 2001 From: Aaron Kennedy Date: Fri, 27 May 2011 13:04:15 +1000 -Subject: [PATCH 07/13] Fix warnings +Subject: [PATCH 07/16] Fix warnings --- include/v8.h | 16 ++++++++-------- @@ -42,5 +42,5 @@ index 9aba4a8..8891dab 100644 } // namespace internal -- -1.7.2.3 +1.7.6 diff --git a/src/v8/0008-Add-custom-object-compare-callback.patch b/src/v8/0008-Add-custom-object-compare-callback.patch index d7ef5c434d..a6973969fe 100644 --- a/src/v8/0008-Add-custom-object-compare-callback.patch +++ b/src/v8/0008-Add-custom-object-compare-callback.patch @@ -1,7 +1,7 @@ From bec11b8b7f89d135e7d9a823ac4fe98c70d017cf Mon Sep 17 00:00:00 2001 From: Aaron Kennedy Date: Mon, 27 Jun 2011 14:57:28 +1000 -Subject: [PATCH 08/13] Add custom object compare callback +Subject: [PATCH 08/16] Add custom object compare callback A global custom object comparison callback can be set with: V8::SetUserObjectComparisonCallbackFunction() @@ -485,5 +485,5 @@ index d923494..10b9b56 100644 ASSERT(GetCondition() == equal); __ subq(rax, rdx); -- -1.7.2.3 +1.7.6 diff --git a/src/v8/0009-Add-CallAsFunction-method-to-the-Object-class-in-the.patch b/src/v8/0009-Add-CallAsFunction-method-to-the-Object-class-in-the.patch index d197ac9e48..242161358f 100644 --- a/src/v8/0009-Add-CallAsFunction-method-to-the-Object-class-in-the.patch +++ b/src/v8/0009-Add-CallAsFunction-method-to-the-Object-class-in-the.patch @@ -1,7 +1,8 @@ From 4183b973ed3bd603784c798dfa63ba48f6b68003 Mon Sep 17 00:00:00 2001 -From: ager@chromium.org +From: "ager@chromium.org" Date: Wed, 4 May 2011 13:03:08 +0000 -Subject: [PATCH 09/13] Add CallAsFunction method to the Object class in the API +Subject: [PATCH 09/16] Add CallAsFunction method to the Object class in the + API Patch by Peter Varga. @@ -282,5 +283,5 @@ index d7621d1..693d51e 100644 -- -1.7.2.3 +1.7.6 diff --git a/src/v8/0010-Implement-CallAsConstructor-method-for-Object-in-the.patch b/src/v8/0010-Implement-CallAsConstructor-method-for-Object-in-the.patch index cb4dd186d6..ea3802b96d 100644 --- a/src/v8/0010-Implement-CallAsConstructor-method-for-Object-in-the.patch +++ b/src/v8/0010-Implement-CallAsConstructor-method-for-Object-in-the.patch @@ -1,7 +1,8 @@ From 3d6d4249878f7960eac4c9c94e0f2529f9a58c4a Mon Sep 17 00:00:00 2001 -From: ager@chromium.org +From: "ager@chromium.org" Date: Fri, 6 May 2011 11:07:52 +0000 -Subject: [PATCH 10/13] Implement CallAsConstructor method for Object in the API +Subject: [PATCH 10/16] Implement CallAsConstructor method for Object in the + API Patch by Peter Varga. @@ -393,5 +394,5 @@ index 693d51e..1334f63 100644 } } -- -1.7.2.3 +1.7.6 diff --git a/src/v8/0011-QtScript-V8-Add-new-v8-api-to-check-if-a-value-is-an.patch b/src/v8/0011-QtScript-V8-Add-new-v8-api-to-check-if-a-value-is-an.patch index 9c0e68352f..aefcae55cd 100644 --- a/src/v8/0011-QtScript-V8-Add-new-v8-api-to-check-if-a-value-is-an.patch +++ b/src/v8/0011-QtScript-V8-Add-new-v8-api-to-check-if-a-value-is-an.patch @@ -1,7 +1,8 @@ From f22d0312faeb93ced8747d9aae8c6d77e11b4aba Mon Sep 17 00:00:00 2001 From: Jedrzej Nowacki Date: Tue, 7 Dec 2010 11:56:42 +0100 -Subject: [PATCH 11/13] QtScript/V8: Add new v8 api to check if a value is an error. +Subject: [PATCH 11/16] QtScript/V8: Add new v8 api to check if a value is an + error. New function v8::Value::IsError was created. @@ -59,5 +60,5 @@ index 8cbf378..db90bb9 100644 V(to_string_symbol, "toString") \ V(char_at_symbol, "CharAt") \ -- -1.7.2.3 +1.7.6 diff --git a/src/v8/0012-Add-IsCallable-method-for-Object-in-the-API.patch b/src/v8/0012-Add-IsCallable-method-for-Object-in-the-API.patch index 77589c8af3..426458dafc 100644 --- a/src/v8/0012-Add-IsCallable-method-for-Object-in-the-API.patch +++ b/src/v8/0012-Add-IsCallable-method-for-Object-in-the-API.patch @@ -1,7 +1,8 @@ From 472c04c9e7a64e8734c76d2cf97a7cc5b773b788 Mon Sep 17 00:00:00 2001 -From: ager@chromium.org +From: "ager@chromium.org" + Date: Mon, 9 May 2011 15:24:48 +0000 -Subject: [PATCH 12/13] Add IsCallable method for Object in the API +Subject: [PATCH 12/16] Add IsCallable method for Object in the API Patch by Peter Varga. @@ -112,5 +113,5 @@ index 1334f63..45db5a1 100644 return v8::HandleScope::NumberOfHandles(); } -- -1.7.2.3 +1.7.6 diff --git a/src/v8/0013-Remove-execute-flag-from-v8-debug.h.patch b/src/v8/0013-Remove-execute-flag-from-v8-debug.h.patch index 6bad561273..f73785d123 100644 --- a/src/v8/0013-Remove-execute-flag-from-v8-debug.h.patch +++ b/src/v8/0013-Remove-execute-flag-from-v8-debug.h.patch @@ -1,7 +1,7 @@ From dc2cad4f8fc88c52fcea09b8d0262d35cd32dc44 Mon Sep 17 00:00:00 2001 From: Aaron Kennedy Date: Thu, 25 Aug 2011 11:09:58 +1000 -Subject: [PATCH 13/13] Remove execute flag from v8-debug.h +Subject: [PATCH 13/16] Remove execute flag from v8-debug.h --- 0 files changed, 0 insertions(+), 0 deletions(-) @@ -11,5 +11,5 @@ diff --git a/include/v8-debug.h b/include/v8-debug.h old mode 100755 new mode 100644 -- -1.7.2.3 +1.7.6 diff --git a/src/v8/0014-Fix-build-error-suggest-parentheses-around-within.patch b/src/v8/0014-Fix-build-error-suggest-parentheses-around-within.patch new file mode 100644 index 0000000000..bb26b1493f --- /dev/null +++ b/src/v8/0014-Fix-build-error-suggest-parentheses-around-within.patch @@ -0,0 +1,25 @@ +From d7e876decc00c611d327185bf890a7efecb2cf7e Mon Sep 17 00:00:00 2001 +From: Kent Hansen +Date: Mon, 29 Aug 2011 13:26:13 +0200 +Subject: [PATCH 14/16] Fix build error: "suggest parentheses around '&&' + within '||'" + +--- + src/mark-compact.cc | 2 +- + 1 files changed, 1 insertions(+), 1 deletions(-) + +diff --git a/src/mark-compact.cc b/src/mark-compact.cc +index 1b1e361..775f787 100644 +--- a/src/mark-compact.cc ++++ b/src/mark-compact.cc +@@ -1020,7 +1020,7 @@ class SymbolTableCleaner : public ObjectVisitor { + // Since no objects have yet been moved we can safely access the map of + // the object. + if ((*p)->IsExternalString() || +- (*p)->IsHeapObject() && HeapObject::cast(*p)->map()->has_external_resource()) { ++ ((*p)->IsHeapObject() && HeapObject::cast(*p)->map()->has_external_resource())) { + heap_->FinalizeExternalString(HeapObject::cast(*p)); + } + // Set the entry to null_value (as deleted). +-- +1.7.6 diff --git a/src/v8/0015-Fix-source-compatibility-where-the-String-Equals-ove.patch b/src/v8/0015-Fix-source-compatibility-where-the-String-Equals-ove.patch new file mode 100644 index 0000000000..003c430f56 --- /dev/null +++ b/src/v8/0015-Fix-source-compatibility-where-the-String-Equals-ove.patch @@ -0,0 +1,25 @@ +From 0af1e15a3d6b28923c262a02a5ace35812c8f5d6 Mon Sep 17 00:00:00 2001 +From: Simon Hausmann +Date: Thu, 4 Aug 2011 21:28:38 +0200 +Subject: [PATCH 15/16] Fix source compatibility where the String::Equals + overloads would shadow the Value::Equals function, + breaking the build. + +--- + include/v8.h | 1 + + 1 files changed, 1 insertions(+), 0 deletions(-) + +diff --git a/include/v8.h b/include/v8.h +index 4194d4a..5e1ce50 100644 +--- a/include/v8.h ++++ b/include/v8.h +@@ -1048,6 +1048,7 @@ class String : public Primitive { + */ + V8EXPORT bool Equals(uint16_t *string, int length); + V8EXPORT bool Equals(char *string, int length); ++ inline bool Equals(Handle that) const { return v8::Value::Equals(that); } + + /** + * Write the contents of the string to an external buffer. +-- +1.7.6 diff --git a/src/v8/0016-Fix-deprecated-Python-code.patch b/src/v8/0016-Fix-deprecated-Python-code.patch new file mode 100644 index 0000000000..4ecf8d7e6f --- /dev/null +++ b/src/v8/0016-Fix-deprecated-Python-code.patch @@ -0,0 +1,50 @@ +From 97cb46d421faebd2b139570bcf9aaf2d5eadc333 Mon Sep 17 00:00:00 2001 +From: Kent Hansen +Date: Fri, 2 Sep 2011 12:03:09 +0200 +Subject: [PATCH 16/16] Fix deprecated Python code + +Needed to make the scripts run on Python 3, which is the +default python interpreter on some newer distros. + +Patch from http://code.google.com/p/v8/issues/detail?id=1391 +--- + tools/js2c.py | 4 ++-- + tools/jsmin.py | 2 +- + 2 files changed, 3 insertions(+), 3 deletions(-) + +diff --git a/tools/js2c.py b/tools/js2c.py +index 2da132f..d13d53d 100755 +--- a/tools/js2c.py ++++ b/tools/js2c.py +@@ -187,14 +187,14 @@ def ReadMacros(lines): + macro_match = MACRO_PATTERN.match(line) + if macro_match: + name = macro_match.group(1) +- args = map(string.strip, macro_match.group(2).split(',')) ++ args = args = [match.strip() for match in macro_match.group(2).split(',')] + body = macro_match.group(3).strip() + macros.append((re.compile("\\b%s\\(" % name), TextMacro(args, body))) + else: + python_match = PYTHON_MACRO_PATTERN.match(line) + if python_match: + name = python_match.group(1) +- args = map(string.strip, python_match.group(2).split(',')) ++ args = [match.strip() for match in python_match.group(2).split(',')] + body = python_match.group(3).strip() + fun = eval("lambda " + ",".join(args) + ': ' + body) + macros.append((re.compile("\\b%s\\(" % name), PythonMacro(args, fun))) +diff --git a/tools/jsmin.py b/tools/jsmin.py +index 646bf14..395441b 100644 +--- a/tools/jsmin.py ++++ b/tools/jsmin.py +@@ -154,7 +154,7 @@ class JavaScriptMinifier(object): + return var_name + while True: + identifier_first_char = self.identifier_counter % 52 +- identifier_second_char = self.identifier_counter / 52 ++ identifier_second_char = self.identifier_counter // 52 + new_identifier = self.CharFromNumber(identifier_first_char) + if identifier_second_char != 0: + new_identifier = ( +-- +1.7.6 -- cgit v1.2.3 From c0dc40ce06582222c3501b69526df0cc1383f51b Mon Sep 17 00:00:00 2001 From: Corentin Chary Date: Wed, 31 Aug 2011 19:35:36 +0200 Subject: qssl: use reinterpret_cast instead of C-style casts Merge-request: 48 Reviewed-by: Peter Hartmann Change-Id: Ia5ac3239e6f378f930cb299a5711aa98dbb2f418 Reviewed-on: http://codereview.qt.nokia.com/4012 Reviewed-by: Qt Sanity Bot Reviewed-by: Peter Hartmann --- src/network/ssl/qsslsocket_openssl.cpp | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/network/ssl/qsslsocket_openssl.cpp b/src/network/ssl/qsslsocket_openssl.cpp index 2fae2ccdce..0ff17910f3 100644 --- a/src/network/ssl/qsslsocket_openssl.cpp +++ b/src/network/ssl/qsslsocket_openssl.cpp @@ -322,7 +322,7 @@ init_context: if (! caCertificate.isValid()) { expiredCerts.append(caCertificate); } else { - q_X509_STORE_add_cert(ctx->cert_store, (X509 *)caCertificate.handle()); + q_X509_STORE_add_cert(ctx->cert_store, reinterpret_cast(caCertificate.handle())); } } @@ -335,7 +335,7 @@ init_context: // now add the expired certs if (addExpiredCerts) { foreach (const QSslCertificate &caCertificate, expiredCerts) { - q_X509_STORE_add_cert(ctx->cert_store, (X509 *)caCertificate.handle()); + q_X509_STORE_add_cert(ctx->cert_store, reinterpret_cast(caCertificate.handle())); } } @@ -358,7 +358,7 @@ init_context: } // Load certificate - if (!q_SSL_CTX_use_certificate(ctx, (X509 *)configuration.localCertificate.handle())) { + if (!q_SSL_CTX_use_certificate(ctx, reinterpret_cast(configuration.localCertificate.handle()))) { q->setErrorString(QSslSocket::tr("Error loading local certificate, %1").arg(getErrorsFromOpenSsl())); emit q->error(QAbstractSocket::UnknownSocketError); return false; @@ -373,9 +373,9 @@ init_context: // this lead to a memory leak. Now we use the *_set1_* functions which do not // take ownership of the RSA/DSA key instance because the QSslKey already has ownership. if (configuration.privateKey.algorithm() == QSsl::Rsa) - q_EVP_PKEY_set1_RSA(pkey, (RSA *)configuration.privateKey.handle()); + q_EVP_PKEY_set1_RSA(pkey, reinterpret_cast(configuration.privateKey.handle())); else - q_EVP_PKEY_set1_DSA(pkey, (DSA *)configuration.privateKey.handle()); + q_EVP_PKEY_set1_DSA(pkey, reinterpret_cast(configuration.privateKey.handle())); } if (!q_SSL_CTX_use_PrivateKey(ctx, pkey)) { @@ -1514,7 +1514,7 @@ QList QSslSocketBackendPrivate::verify(QList certifi if (!caCertificate.isValid()) { expiredCerts.append(caCertificate); } else { - q_X509_STORE_add_cert(certStore, (X509 *)caCertificate.handle()); + q_X509_STORE_add_cert(certStore, reinterpret_cast(caCertificate.handle())); } } @@ -1527,7 +1527,7 @@ QList QSslSocketBackendPrivate::verify(QList certifi // now add the expired certs if (addExpiredCerts) { foreach (const QSslCertificate &caCertificate, expiredCerts) { - q_X509_STORE_add_cert(certStore, (X509 *)caCertificate.handle()); + q_X509_STORE_add_cert(certStore, reinterpret_cast(caCertificate.handle())); } } @@ -1554,9 +1554,9 @@ QList QSslSocketBackendPrivate::verify(QList certifi continue; } #if OPENSSL_VERSION_NUMBER >= 0x10000000L - q_sk_push( (_STACK *)intermediates, (X509 *)cert.handle()); + q_sk_push( (_STACK *)intermediates, reinterpret_cast(cert.handle())); #else - q_sk_push( (STACK *)intermediates, (X509 *)cert.handle()); + q_sk_push( (STACK *)intermediates, reinterpret_cast(cert.handle())); #endif } } @@ -1568,7 +1568,7 @@ QList QSslSocketBackendPrivate::verify(QList certifi return errors; } - if (!q_X509_STORE_CTX_init(storeContext, certStore, (X509 *)certificateChain[0].handle(), intermediates)) { + if (!q_X509_STORE_CTX_init(storeContext, certStore, reinterpret_cast(certificateChain[0].handle()), intermediates)) { q_X509_STORE_CTX_free(storeContext); q_X509_STORE_free(certStore); errors << QSslError(QSslError::UnspecifiedError); -- cgit v1.2.3 From 3840ce839fb339c685371ba834736a87fe097a9b Mon Sep 17 00:00:00 2001 From: Peter Hartmann Date: Tue, 30 Aug 2011 13:10:06 +0200 Subject: QSslCertificate: also check common name for blacklisted certificates ... to reduce the possibility of blacklisting valid certificates that happen to have the same serial number as a blacklisted one, which is unlikely, but possible. Reviewed-by: Richard J. Moore (cherry picked from commit 6b1a8129623e3716f2fc075608b260ce7c381fe2 and adapted to the source incompatible change) Change-Id: If714c34f6ce028032eee6d68f34d088b6ad5a0cc Reviewed-on: http://codereview.qt.nokia.com/3895 Reviewed-by: Qt Sanity Bot Reviewed-by: Peter Hartmann --- src/network/ssl/qsslcertificate.cpp | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/src/network/ssl/qsslcertificate.cpp b/src/network/ssl/qsslcertificate.cpp index bbc60f674c..fa97ccb78c 100644 --- a/src/network/ssl/qsslcertificate.cpp +++ b/src/network/ssl/qsslcertificate.cpp @@ -892,23 +892,24 @@ QList QSslCertificatePrivate::certificatesFromDer(const QByteAr // These certificates are known to be fraudulent and were created during the comodo // compromise. See http://www.comodo.com/Comodo-Fraud-Incident-2011-03-23.html static const char *certificate_blacklist[] = { - "04:7e:cb:e9:fc:a5:5f:7b:d0:9e:ae:36:e1:0c:ae:1e", - "f5:c8:6a:f3:61:62:f1:3a:64:f5:4f:6d:c9:58:7c:06", - "d7:55:8f:da:f5:f1:10:5b:b2:13:28:2b:70:77:29:a3", - "39:2a:43:4f:0e:07:df:1f:8a:a3:05:de:34:e0:c2:29", - "3e:75:ce:d4:6b:69:30:21:21:88:30:ae:86:a8:2a:71", - "e9:02:8b:95:78:e4:15:dc:1a:71:0a:2b:88:15:44:47", - "92:39:d5:34:8f:40:d1:69:5a:74:54:70:e1:f2:3f:43", - "b0:b7:13:3e:d0:96:f9:b5:6f:ae:91:c8:74:bd:3a:c0", - "d8:f3:5f:4e:b7:87:2b:2d:ab:06:92:e3:15:38:2f:b0", - "05:e2:e6:a4:cd:09:ea:54:d6:65:b0:75:fe:22:a2:56", + "04:7e:cb:e9:fc:a5:5f:7b:d0:9e:ae:36:e1:0c:ae:1e", "mail.google.com", // Comodo + "f5:c8:6a:f3:61:62:f1:3a:64:f5:4f:6d:c9:58:7c:06", "www.google.com", // Comodo + "d7:55:8f:da:f5:f1:10:5b:b2:13:28:2b:70:77:29:a3", "login.yahoo.com", // Comodo + "39:2a:43:4f:0e:07:df:1f:8a:a3:05:de:34:e0:c2:29", "login.yahoo.com", // Comodo + "3e:75:ce:d4:6b:69:30:21:21:88:30:ae:86:a8:2a:71", "login.yahoo.com", // Comodo + "e9:02:8b:95:78:e4:15:dc:1a:71:0a:2b:88:15:44:47", "login.skype.com", // Comodo + "92:39:d5:34:8f:40:d1:69:5a:74:54:70:e1:f2:3f:43", "addons.mozilla.org", // Comodo + "b0:b7:13:3e:d0:96:f9:b5:6f:ae:91:c8:74:bd:3a:c0", "login.live.com", // Comodo + "d8:f3:5f:4e:b7:87:2b:2d:ab:06:92:e3:15:38:2f:b0", "global trustee", // Comodo + "05:e2:e6:a4:cd:09:ea:54:d6:65:b0:75:fe:22:a2:56", "*.google.com", // DigiNotar 0 }; bool QSslCertificatePrivate::isBlacklisted(const QSslCertificate &certificate) { for (int a = 0; certificate_blacklist[a] != 0; a++) { - if (certificate.serialNumber() == certificate_blacklist[a]) + if (certificate.serialNumber() == certificate_blacklist[a++] && + certificate.subjectInfo(QSslCertificate::CommonName).contains(QString::fromUtf8(certificate_blacklist[a]))) return true; } return false; -- cgit v1.2.3 From a4227c8400e652142da669babfff0bf453661ab4 Mon Sep 17 00:00:00 2001 From: Shane Kearns Date: Fri, 2 Sep 2011 18:39:16 +0100 Subject: Fix compile error on MSVC2008 Change-Id: I4f6192b9db601076688b52bfd794ea80a7346729 Reviewed-on: http://codereview.qt.nokia.com/4153 Reviewed-by: Qt Sanity Bot Reviewed-by: Prasanth Ullattil --- tests/auto/qfileinfo/tst_qfileinfo.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/auto/qfileinfo/tst_qfileinfo.cpp b/tests/auto/qfileinfo/tst_qfileinfo.cpp index 696ab42188..92046d3e12 100644 --- a/tests/auto/qfileinfo/tst_qfileinfo.cpp +++ b/tests/auto/qfileinfo/tst_qfileinfo.cpp @@ -1388,7 +1388,7 @@ void tst_QFileInfo::ntfsJunctionPointsAndSymlinks_data() wchar_t errstr[0x100]; DWORD count = FormatMessageW(FORMAT_MESSAGE_FROM_SYSTEM, 0, err, 0, errstr, 0x100, 0); - QString error(QString::fromUtf16(errstr, count)); + QString error(QString::fromWCharArray (errstr, count)); qWarning() << error; //we need at least one data set for the test not to assert fail when skipping _data function QDir target("target"); -- cgit v1.2.3 From c8baa5602a478fb4e2907b8a319397c15a72ad1c Mon Sep 17 00:00:00 2001 From: Shane Kearns Date: Fri, 2 Sep 2011 18:40:45 +0100 Subject: Restore Qt4.7 behaviour of QFileInfo::absolute(File)Path Many applications relied on the undefined behaviour that the filesystem engines returned clean paths (despite the documentation stating that they may not), and consequently suffered regressions with Qt 4.8. Unix paths are once again cleaned if necessary. Windows/Symbian paths were already cleaned, but now use the utility function to check if a path is dirty, to avoid duplicated code. Task-number: QTBUG-19995 Change-Id: If8c18469f149291c9d079ae3da23bc2087bbd49a Reviewed-on: http://codereview.qt.nokia.com/4154 Reviewed-by: Qt Sanity Bot Reviewed-by: Prasanth Ullattil --- src/corelib/io/qfilesystemengine_symbian.cpp | 4 +--- src/corelib/io/qfilesystemengine_unix.cpp | 2 +- src/corelib/io/qfilesystemengine_win.cpp | 6 +----- tests/auto/qfileinfo/tst_qfileinfo.cpp | 10 +++++++++- 4 files changed, 12 insertions(+), 10 deletions(-) diff --git a/src/corelib/io/qfilesystemengine_symbian.cpp b/src/corelib/io/qfilesystemengine_symbian.cpp index 18c52cbb17..c8c1dfdc84 100644 --- a/src/corelib/io/qfilesystemengine_symbian.cpp +++ b/src/corelib/io/qfilesystemengine_symbian.cpp @@ -114,9 +114,7 @@ QFileSystemEntry QFileSystemEngine::absoluteName(const QFileSystemEntry &entry) { QString orig = entry.filePath(); const bool isAbsolute = entry.isAbsolute(); - const bool isDirty = (orig.contains(QLatin1String("/../")) || orig.contains(QLatin1String("/./")) || - orig.contains(QLatin1String("//")) || - orig.endsWith(QLatin1String("/..")) || orig.endsWith(QLatin1String("/."))); + const bool isDirty = !entry.isClean(); if (isAbsolute && !isDirty) return entry; diff --git a/src/corelib/io/qfilesystemengine_unix.cpp b/src/corelib/io/qfilesystemengine_unix.cpp index f1e0758bbe..966daba021 100644 --- a/src/corelib/io/qfilesystemengine_unix.cpp +++ b/src/corelib/io/qfilesystemengine_unix.cpp @@ -218,7 +218,7 @@ QFileSystemEntry QFileSystemEngine::canonicalName(const QFileSystemEntry &entry, //static QFileSystemEntry QFileSystemEngine::absoluteName(const QFileSystemEntry &entry) { - if (entry.isAbsolute()) + if (entry.isAbsolute() && entry.isClean()) return entry; QByteArray orig = entry.nativeFilePath(); diff --git a/src/corelib/io/qfilesystemengine_win.cpp b/src/corelib/io/qfilesystemengine_win.cpp index f704fc3e90..df34184091 100644 --- a/src/corelib/io/qfilesystemengine_win.cpp +++ b/src/corelib/io/qfilesystemengine_win.cpp @@ -508,11 +508,7 @@ QFileSystemEntry QFileSystemEngine::absoluteName(const QFileSystemEntry &entry) if (!entry.isRelative()) { #if !defined(Q_OS_WINCE) - if (entry.isAbsolute() - && !entry.filePath().contains(QLatin1String("/../")) - && !entry.filePath().contains(QLatin1String("/./")) - && !entry.filePath().endsWith(QLatin1String("/..")) - && !entry.filePath().endsWith(QLatin1String("/."))) { + if (entry.isAbsolute() && entry.isClean()) { ret = entry.filePath(); } else { ret = QDir::fromNativeSeparators(nativeAbsoluteFilePath(entry.filePath())); diff --git a/tests/auto/qfileinfo/tst_qfileinfo.cpp b/tests/auto/qfileinfo/tst_qfileinfo.cpp index 92046d3e12..878493b8e3 100644 --- a/tests/auto/qfileinfo/tst_qfileinfo.cpp +++ b/tests/auto/qfileinfo/tst_qfileinfo.cpp @@ -481,6 +481,11 @@ void tst_QFileInfo::absolutePath_data() QTest::newRow("c:\\autoexec.bat") << "c:\\autoexec.bat" << "C:/" << "autoexec.bat"; #endif + QTest::newRow("QTBUG-19995.1") << drivePrefix + "/System/Library/StartupItems/../Frameworks" + << drivePrefix + "/System/Library" + << "Frameworks"; + QTest::newRow("QTBUG-19995.2") << drivePrefix + "/System/Library/StartupItems/../Frameworks/" + << drivePrefix + "/System/Library/Frameworks" << ""; } void tst_QFileInfo::absolutePath() @@ -502,6 +507,7 @@ void tst_QFileInfo::absFilePath_data() QTest::newRow("relativeFile") << "tmp.txt" << QDir::currentPath() + "/tmp.txt"; QTest::newRow("relativeFileInSubDir") << "temp/tmp.txt" << QDir::currentPath() + "/" + "temp/tmp.txt"; + QString drivePrefix; #if (defined(Q_OS_WIN) && !defined(Q_OS_WINCE)) || defined(Q_OS_SYMBIAN) QString curr = QDir::currentPath(); @@ -510,7 +516,7 @@ void tst_QFileInfo::absFilePath_data() QTest::newRow("absFilePath") << "c:\\home\\andy\\tmp.txt" << "C:/home/andy/tmp.txt"; // Make sure drive-relative paths return correct absolute paths (task 255326) - QString drivePrefix = QDir::currentPath().left(2); + drivePrefix = QDir::currentPath().left(2); QString nonCurrentDrivePrefix = drivePrefix.left(1).compare("X", Qt::CaseInsensitive) == 0 ? QString("Y:") : QString("X:"); @@ -520,6 +526,8 @@ void tst_QFileInfo::absFilePath_data() #else QTest::newRow("absFilePath") << "/home/andy/tmp.txt" << "/home/andy/tmp.txt"; #endif + QTest::newRow("QTBUG-19995") << drivePrefix + "/System/Library/StartupItems/../Frameworks" + << drivePrefix + "/System/Library/Frameworks"; } void tst_QFileInfo::absFilePath() -- cgit v1.2.3 From 8febd569408db19c8a83e16cc7a8574f9b00084b Mon Sep 17 00:00:00 2001 From: Andrew den Exter Date: Thu, 4 Aug 2011 10:58:26 +1000 Subject: Move cursorDelegate with the mouse selection of read only text input. Task-number: QTBUG-19109 Reviewed-by: Martin Jones Change-Id: I709427fe73b2d6ed9e3526af140b9dc375740789 Reviewed-on: http://codereview.qt.nokia.com/4164 Reviewed-by: Andrew den Exter --- src/gui/text/qtextcontrol.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/gui/text/qtextcontrol.cpp b/src/gui/text/qtextcontrol.cpp index c29379ed28..a03dabf52a 100644 --- a/src/gui/text/qtextcontrol.cpp +++ b/src/gui/text/qtextcontrol.cpp @@ -1674,8 +1674,10 @@ void QTextControlPrivate::mouseMoveEvent(QEvent *e, Qt::MouseButton button, cons #endif //QT_NO_IM } else { //emit q->visibilityRequest(QRectF(mousePos, QSizeF(1, 1))); - if (cursor.position() != oldCursorPos) + if (cursor.position() != oldCursorPos) { emit q->cursorPositionChanged(); + emit q->microFocusChanged(); + } } selectionChanged(true); repaintOldAndNewSelection(oldSelection); @@ -1719,8 +1721,10 @@ void QTextControlPrivate::mouseReleaseEvent(QEvent *e, Qt::MouseButton button, c repaintOldAndNewSelection(oldSelection); - if (cursor.position() != oldCursorPos) + if (cursor.position() != oldCursorPos) { emit q->cursorPositionChanged(); + emit q->microFocusChanged(); + } if (interactionFlags & Qt::LinksAccessibleByMouse) { if (!(button & Qt::LeftButton)) -- cgit v1.2.3 From 06e2ce51d1170557e43d41767947a1d6eb74c637 Mon Sep 17 00:00:00 2001 From: Andrew den Exter Date: Wed, 17 Aug 2011 12:52:09 +1000 Subject: Fix delayed password masking mid-string. Unmask the last character typed, not the last character in the string. Change-Id: I9c70d2347bf878c18ab0a7f4ea76f755ca19a85c Task-number: QTBUG-17003 Reviewed-by: Alan Alpert (cherry picked from commit b98e9e69dd8ba33d5f01b9518d95b63b86c4b443) Reviewed-on: http://codereview.qt.nokia.com/4165 Reviewed-by: Andrew den Exter --- src/gui/widgets/qlinecontrol.cpp | 6 +++--- tests/auto/qlineedit/tst_qlineedit.cpp | 7 +++++++ 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/gui/widgets/qlinecontrol.cpp b/src/gui/widgets/qlinecontrol.cpp index 9b7d9b83ad..18b4490729 100644 --- a/src/gui/widgets/qlinecontrol.cpp +++ b/src/gui/widgets/qlinecontrol.cpp @@ -60,7 +60,7 @@ QT_BEGIN_NAMESPACE #ifdef QT_GUI_PASSWORD_ECHO_DELAY -static int qt_passwordEchoDelay = QT_GUI_PASSWORD_ECHO_DELAY; +static const int qt_passwordEchoDelay = QT_GUI_PASSWORD_ECHO_DELAY; #endif /*! @@ -115,8 +115,8 @@ void QLineControl::updateDisplayText(bool forceUpdate) if (m_echoMode == QLineEdit::Password) { str.fill(m_passwordCharacter); #ifdef QT_GUI_PASSWORD_ECHO_DELAY - if (m_passwordEchoTimer != 0 && !str.isEmpty()) { - int cursor = m_text.length() - 1; + if (m_passwordEchoTimer != 0 && m_cursor > 0 && m_cursor <= m_text.length()) { + int cursor = m_cursor - 1; QChar uc = m_text.at(cursor); str[cursor] = uc; if (cursor > 0 && uc.unicode() >= 0xdc00 && uc.unicode() < 0xe000) { diff --git a/tests/auto/qlineedit/tst_qlineedit.cpp b/tests/auto/qlineedit/tst_qlineedit.cpp index 68e88a87ed..fde77bca51 100644 --- a/tests/auto/qlineedit/tst_qlineedit.cpp +++ b/tests/auto/qlineedit/tst_qlineedit.cpp @@ -1728,6 +1728,13 @@ void tst_QLineEdit::passwordEchoDelay() QApplication::sendEvent(testWidget, &ev); QCOMPARE(testWidget->displayText(), QString(7, fillChar) + QLatin1Char('7')); + testWidget->setCursorPosition(3); + QCOMPARE(testWidget->displayText(), QString(7, fillChar) + QLatin1Char('7')); + QTest::keyPress(testWidget, 'a'); + QCOMPARE(testWidget->displayText(), QString(3, fillChar) + QLatin1Char('a') + QString(5, fillChar)); + QTest::keyPress(testWidget, Qt::Key_Backspace); + QCOMPARE(testWidget->displayText(), QString(8, fillChar)); + // restore clean state testWidget->setEchoMode(QLineEdit::Normal); } -- cgit v1.2.3 From bb2f045c10965542ae14275e8ce5a97e42931d8d Mon Sep 17 00:00:00 2001 From: Andrew den Exter Date: Wed, 24 Aug 2011 11:26:29 +1000 Subject: Make it easier to select words at the start of a line. QTextControl's word selection will only include a word if the cursor position is past the mid point of the word. This can make it difficult to select words near the edges of the screen on touch devices. For the TextEdit word selection mode select a word ignore the relative position within a word. Task-number: QT-5206 Change-Id: I4e5675596cd89934b3c2bc5d825088887c222fe8 Reviewed-by: Martin Jones Reviewed-on: http://codereview.qt.nokia.com/4166 Reviewed-by: Andrew den Exter --- src/gui/text/qtextcontrol.cpp | 34 ++++++++++++++++++++++------------ 1 file changed, 22 insertions(+), 12 deletions(-) diff --git a/src/gui/text/qtextcontrol.cpp b/src/gui/text/qtextcontrol.cpp index a03dabf52a..a04bcc561a 100644 --- a/src/gui/text/qtextcontrol.cpp +++ b/src/gui/text/qtextcontrol.cpp @@ -689,20 +689,30 @@ void QTextControlPrivate::extendWordwiseSelection(int suggestedNewPosition, qrea if (!wordSelectionEnabled && (mouseXPosition < wordStartX || mouseXPosition > wordEndX)) return; - // keep the already selected word even when moving to the left - // (#39164) - if (suggestedNewPosition < selectedWordOnDoubleClick.position()) - cursor.setPosition(selectedWordOnDoubleClick.selectionEnd()); - else - cursor.setPosition(selectedWordOnDoubleClick.selectionStart()); + if (wordSelectionEnabled) { + if (suggestedNewPosition < selectedWordOnDoubleClick.position()) { + cursor.setPosition(selectedWordOnDoubleClick.selectionEnd()); + setCursorPosition(wordStartPos, QTextCursor::KeepAnchor); + } else { + cursor.setPosition(selectedWordOnDoubleClick.selectionStart()); + setCursorPosition(wordEndPos, QTextCursor::KeepAnchor); + } + } else { + // keep the already selected word even when moving to the left + // (#39164) + if (suggestedNewPosition < selectedWordOnDoubleClick.position()) + cursor.setPosition(selectedWordOnDoubleClick.selectionEnd()); + else + cursor.setPosition(selectedWordOnDoubleClick.selectionStart()); - const qreal differenceToStart = mouseXPosition - wordStartX; - const qreal differenceToEnd = wordEndX - mouseXPosition; + const qreal differenceToStart = mouseXPosition - wordStartX; + const qreal differenceToEnd = wordEndX - mouseXPosition; - if (differenceToStart < differenceToEnd) - setCursorPosition(wordStartPos, QTextCursor::KeepAnchor); - else - setCursorPosition(wordEndPos, QTextCursor::KeepAnchor); + if (differenceToStart < differenceToEnd) + setCursorPosition(wordStartPos, QTextCursor::KeepAnchor); + else + setCursorPosition(wordEndPos, QTextCursor::KeepAnchor); + } if (interactionFlags & Qt::TextSelectableByMouse) { #ifndef QT_NO_CLIPBOARD -- cgit v1.2.3 From 91fe1fd9e8f5b040511721cb64b11772e034b265 Mon Sep 17 00:00:00 2001 From: Jason McDonald Date: Thu, 1 Sep 2011 19:24:48 +1000 Subject: Beautify testlib's usage message Change-Id: Ibeed554075215a5c4a154339dfa751dfe14a4d33 Reviewed-on: http://codereview.qt.nokia.com/4059 Reviewed-by: Qt Sanity Bot Reviewed-by: Rohan McGovern --- src/testlib/qtestcase.cpp | 63 +++++++++++++++++++++++++---------------------- 1 file changed, 33 insertions(+), 30 deletions(-) diff --git a/src/testlib/qtestcase.cpp b/src/testlib/qtestcase.cpp index 666f0a7318..5019f40680 100644 --- a/src/testlib/qtestcase.cpp +++ b/src/testlib/qtestcase.cpp @@ -1001,38 +1001,40 @@ static int qToInt(char *str) Q_TESTLIB_EXPORT void qtest_qParseArgs(int argc, char *argv[], bool qml) { const char *testOptions = - " options:\n" - " -functions : Returns a list of current testfunctions\n" - " -xunitxml : Outputs results as XML XUnit document\n" - " -xml : Outputs results as XML document\n" - " -lightxml : Outputs results as stream of XML tags\n" - " -o filename: Writes all output into a file\n" - " -silent : Only outputs warnings and failures\n" - " -v1 : Print enter messages for each testfunction\n" - " -v2 : Also print out each QVERIFY/QCOMPARE/QTEST\n" - " -vs : Print every signal emitted\n" - " -eventdelay ms : Set default delay for mouse and keyboard simulation to ms milliseconds\n" - " -keydelay ms : Set default delay for keyboard simulation to ms milliseconds\n" - " -mousedelay ms : Set default delay for mouse simulation to ms milliseconds\n" - " -keyevent-verbose : Turn on verbose messages for keyboard simulation\n" - " -maxwarnings n : Sets the maximum amount of messages to output.\n" - " 0 means unlimited, default: 2000\n" + " Output options:\n" + " -xunitxml : Outputs results as XML XUnit document\n" + " -xml : Outputs results as XML document\n" + " -lightxml : Outputs results as stream of XML tags\n" + " -o filename : Writes all output into a file\n" + " -silent : Only outputs warnings and failures\n" + " -v1 : Print enter messages for each testfunction\n" + " -v2 : Also print out each QVERIFY/QCOMPARE/QTEST\n" + " -vs : Print every signal emitted\n" + "\n" + " Testing options:\n" + " -functions : Returns a list of current testfunctions\n" + " -eventdelay ms : Set default delay for mouse and keyboard simulation to ms milliseconds\n" + " -keydelay ms : Set default delay for keyboard simulation to ms milliseconds\n" + " -mousedelay ms : Set default delay for mouse simulation to ms milliseconds\n" + " -keyevent-verbose : Turn on verbose messages for keyboard simulation\n" + " -maxwarnings n : Sets the maximum amount of messages to output.\n" + " 0 means unlimited, default: 2000\n" #if defined(Q_OS_UNIX) && !defined(Q_OS_SYMBIAN) - " -nocrashhandler : Disables the crash handler\n" + " -nocrashhandler : Disables the crash handler\n" #endif "\n" - " Benchmark related options:\n" + " Benchmarking options:\n" #ifdef QTESTLIB_USE_VALGRIND - " -callgrind : Use callgrind to time benchmarks\n" + " -callgrind : Use callgrind to time benchmarks\n" #endif #ifdef HAVE_TICK_COUNTER - " -tickcounter : Use CPU tick counters to time benchmarks\n" + " -tickcounter : Use CPU tick counters to time benchmarks\n" #endif - " -eventcounter : Counts events received during benchmarks\n" - " -minimumvalue n : Sets the minimum acceptable measurement value\n" - " -iterations n : Sets the number of accumulation iterations.\n" - " -median n : Sets the number of median iterations.\n" - " -vb : Print out verbose benchmarking information.\n"; + " -eventcounter : Counts events received during benchmarks\n" + " -minimumvalue n : Sets the minimum acceptable measurement value\n" + " -iterations n : Sets the number of accumulation iterations.\n" + " -median n : Sets the number of median iterations.\n" + " -vb : Print out verbose benchmarking information.\n"; for (int i = 1; i < argc; ++i) { if (strcmp(argv[i], "-help") == 0 || strcmp(argv[i], "--help") == 0 @@ -1042,15 +1044,16 @@ Q_TESTLIB_EXPORT void qtest_qParseArgs(int argc, char *argv[], bool qml) "%s", argv[0], testOptions); if (qml) { - printf ("\nqmltest related options:\n" - " -import : Specify an import directory.\n" - " -input : Specify the root directory for test cases.\n" - " -qtquick1 : Run with QtQuick 1 rather than QtQuick 2.\n" + printf ("\n" + " QmlTest options:\n" + " -import : Specify an import directory.\n" + " -input : Specify the root directory for test cases.\n" + " -qtquick1 : Run with QtQuick 1 rather than QtQuick 2.\n" ); } printf("\n" - " -help : This help\n"); + " -help : This help\n"); exit(0); } else if (strcmp(argv[i], "-functions") == 0) { if (qml) { -- cgit v1.2.3 From cab90f8c8b19892b2e026d12411702dbc8c10fb9 Mon Sep 17 00:00:00 2001 From: Jason McDonald Date: Fri, 2 Sep 2011 17:08:20 +1000 Subject: Pass log file name when constructing loggers. Pass the filename when creating the logger rather than when commencing output. This will simplify forthcoming changes for running multiple loggers. Change-Id: I563aa97661caf279a5dcccb1321ff3ce4725b332 Reviewed-on: http://codereview.qt.nokia.com/4116 Reviewed-by: Qt Sanity Bot Reviewed-by: Rohan McGovern --- src/testlib/qabstracttestlogger.cpp | 30 +++++++++++------- src/testlib/qabstracttestlogger_p.h | 6 ++-- src/testlib/qplaintestlogger.cpp | 7 +++-- src/testlib/qplaintestlogger_p.h | 4 +-- src/testlib/qtestcase.cpp | 14 ++++++--- src/testlib/qtestlog.cpp | 62 ++++++++++++++----------------------- src/testlib/qtestlog_p.h | 6 ++-- src/testlib/qxmltestlogger.cpp | 8 ++--- src/testlib/qxmltestlogger_p.h | 4 +-- src/testlib/qxunittestlogger.cpp | 9 +++--- src/testlib/qxunittestlogger_p.h | 4 +-- 11 files changed, 75 insertions(+), 79 deletions(-) diff --git a/src/testlib/qabstracttestlogger.cpp b/src/testlib/qabstracttestlogger.cpp index d71addb655..e2f253c22e 100644 --- a/src/testlib/qabstracttestlogger.cpp +++ b/src/testlib/qabstracttestlogger.cpp @@ -54,18 +54,8 @@ QT_BEGIN_NAMESPACE -void QAbstractTestLogger::outputString(const char *msg) +QAbstractTestLogger::QAbstractTestLogger(const char *filename) { - QTEST_ASSERT(stream); - - ::fputs(msg, stream); - ::fflush(stream); -} - -void QAbstractTestLogger::startLogging(const char *filename) -{ - QTEST_ASSERT(!stream); - if (!filename) { stream = stdout; return; @@ -81,7 +71,7 @@ void QAbstractTestLogger::startLogging(const char *filename) } } -void QAbstractTestLogger::stopLogging() +QAbstractTestLogger::~QAbstractTestLogger() { QTEST_ASSERT(stream); if (stream != stdout) { @@ -97,6 +87,22 @@ void QAbstractTestLogger::stopLogging() stream = 0; } +void QAbstractTestLogger::outputString(const char *msg) +{ + QTEST_ASSERT(stream); + + ::fputs(msg, stream); + ::fflush(stream); +} + +void QAbstractTestLogger::startLogging() +{ +} + +void QAbstractTestLogger::stopLogging() +{ +} + namespace QTest { diff --git a/src/testlib/qabstracttestlogger_p.h b/src/testlib/qabstracttestlogger_p.h index 47f772e7ed..3e11863012 100644 --- a/src/testlib/qabstracttestlogger_p.h +++ b/src/testlib/qabstracttestlogger_p.h @@ -80,10 +80,10 @@ public: Info }; - QAbstractTestLogger() : stream(0) {} - virtual ~QAbstractTestLogger() {} + QAbstractTestLogger(const char *filename); + virtual ~QAbstractTestLogger(); - virtual void startLogging(const char *filename); + virtual void startLogging(); virtual void stopLogging(); virtual void enterTestFunction(const char *function) = 0; diff --git a/src/testlib/qplaintestlogger.cpp b/src/testlib/qplaintestlogger.cpp index 6dc2135d1b..14fa752c40 100644 --- a/src/testlib/qplaintestlogger.cpp +++ b/src/testlib/qplaintestlogger.cpp @@ -344,7 +344,8 @@ void QPlainTestLogger::printBenchmarkResult(const QBenchmarkResult &result) outputMessage(buf); } -QPlainTestLogger::QPlainTestLogger() +QPlainTestLogger::QPlainTestLogger(const char *filename) + : QAbstractTestLogger(filename) { #if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) InitializeCriticalSection(&QTest::outputCriticalSection); @@ -358,9 +359,9 @@ QPlainTestLogger::~QPlainTestLogger() #endif } -void QPlainTestLogger::startLogging(const char *filename) +void QPlainTestLogger::startLogging() { - QAbstractTestLogger::startLogging(filename); + QAbstractTestLogger::startLogging(); char buf[1024]; if (QTestLog::verboseLevel() < 0) { diff --git a/src/testlib/qplaintestlogger_p.h b/src/testlib/qplaintestlogger_p.h index baa1e24828..432e900320 100644 --- a/src/testlib/qplaintestlogger_p.h +++ b/src/testlib/qplaintestlogger_p.h @@ -60,10 +60,10 @@ QT_BEGIN_NAMESPACE class QPlainTestLogger : public QAbstractTestLogger { public: - QPlainTestLogger(); + QPlainTestLogger(const char *filename); ~QPlainTestLogger(); - void startLogging(const char *filename); + void startLogging(); void stopLogging(); void enterTestFunction(const char *function); diff --git a/src/testlib/qtestcase.cpp b/src/testlib/qtestcase.cpp index 5019f40680..9bb591989d 100644 --- a/src/testlib/qtestcase.cpp +++ b/src/testlib/qtestcase.cpp @@ -1000,6 +1000,9 @@ static int qToInt(char *str) Q_TESTLIB_EXPORT void qtest_qParseArgs(int argc, char *argv[], bool qml) { + QTestLog::LogMode logFormat = QTestLog::Plain; + const char *logFilename = 0; + const char *testOptions = " Output options:\n" " -xunitxml : Outputs results as XML XUnit document\n" @@ -1063,11 +1066,11 @@ Q_TESTLIB_EXPORT void qtest_qParseArgs(int argc, char *argv[], bool qml) exit(0); } } else if (strcmp(argv[i], "-xunitxml") == 0) { - QTestLog::setLogMode(QTestLog::XunitXML); + logFormat = QTestLog::XunitXML; } else if (strcmp(argv[i], "-xml") == 0) { - QTestLog::setLogMode(QTestLog::XML); + logFormat = QTestLog::XML; } else if (strcmp(argv[i], "-lightxml") == 0) { - QTestLog::setLogMode(QTestLog::LightXML); + logFormat = QTestLog::LightXML; } else if (strcmp(argv[i], "-silent") == 0) { QTestLog::setVerboseLevel(-1); } else if (strcmp(argv[i], "-v1") == 0) { @@ -1081,7 +1084,7 @@ Q_TESTLIB_EXPORT void qtest_qParseArgs(int argc, char *argv[], bool qml) fprintf(stderr, "-o needs an extra parameter specifying the filename\n"); exit(1); } else { - QTestLog::redirectOutput(argv[++i]); + logFilename = argv[++i]; } } else if (strcmp(argv[i], "-eventdelay") == 0) { if (i + 1 >= argc) { @@ -1244,6 +1247,9 @@ Q_TESTLIB_EXPORT void qtest_qParseArgs(int argc, char *argv[], bool qml) QTEST_ASSERT(QTest::testFuncCount < 512); } } + + // Create the logger + QTestLog::initLogger(logFormat, logFilename); } QBenchmarkResult qMedian(const QList &container) diff --git a/src/testlib/qtestlog.cpp b/src/testlib/qtestlog.cpp index 410972db0f..d53b00ca7f 100644 --- a/src/testlib/qtestlog.cpp +++ b/src/testlib/qtestlog.cpp @@ -87,7 +87,6 @@ namespace QTest { static int maxWarnings = 2002; static QAbstractTestLogger *testLogger = 0; - static const char *outFile = 0; static QtMsgHandler oldMessageHandler; @@ -164,24 +163,6 @@ namespace QTest { break; } } - - void initLogger() - { - switch (QTest::logMode) { - case QTestLog::Plain: - QTest::testLogger = new QPlainTestLogger; - break; - case QTestLog::XML: - QTest::testLogger = new QXmlTestLogger(QXmlTestLogger::Complete); - break; - case QTestLog::LightXML: - QTest::testLogger = new QXmlTestLogger(QXmlTestLogger::Light); - break; - case QTestLog::XunitXML: - QTest::testLogger = new QXunitTestLogger(); - break; - } - } } void QTestLog::enterTestFunction(const char* function) @@ -276,9 +257,8 @@ void QTestLog::addBenchmarkResult(const QBenchmarkResult &result) void QTestLog::startLogging() { - QTEST_ASSERT(!QTest::testLogger); - QTest::initLogger(); - QTest::testLogger->startLogging(QTest::outFile); + QTEST_ASSERT(QTest::testLogger); + QTest::testLogger->startLogging(); QTest::oldMessageHandler = qInstallMsgHandler(QTest::messageHandler); } @@ -292,6 +272,27 @@ void QTestLog::stopLogging() QTest::testLogger = 0; } +void QTestLog::initLogger(LogMode mode, const char *filename) +{ + QTest::logMode = mode; + + switch (mode) { + case QTestLog::Plain: + QTest::testLogger = new QPlainTestLogger(filename); + break; + case QTestLog::XML: + QTest::testLogger = new QXmlTestLogger(QXmlTestLogger::Complete, filename); + break; + case QTestLog::LightXML: + QTest::testLogger = new QXmlTestLogger(QXmlTestLogger::Light, filename); + break; + case QTestLog::XunitXML: + QTest::testLogger = new QXunitTestLogger(filename); + break; + } + QTEST_ASSERT(QTest::testLogger); +} + void QTestLog::warn(const char *msg) { QTEST_ASSERT(QTest::testLogger); @@ -308,11 +309,6 @@ void QTestLog::info(const char *msg, const char *file, int line) QTest::testLogger->addMessage(QAbstractTestLogger::Info, msg, file, line); } -void QTestLog::setLogMode(LogMode mode) -{ - QTest::logMode = mode; -} - QTestLog::LogMode QTestLog::logMode() { return QTest::logMode; @@ -344,18 +340,6 @@ void QTestLog::addIgnoreMessage(QtMsgType type, const char *msg) list->next = item; } -void QTestLog::redirectOutput(const char *fileName) -{ - QTEST_ASSERT(fileName); - - QTest::outFile = fileName; -} - -const char *QTestLog::outputFileName() -{ - return QTest::outFile; -} - void QTestLog::setMaxWarnings(int m) { QTest::maxWarnings = m <= 0 ? INT_MAX : m + 2; diff --git a/src/testlib/qtestlog_p.h b/src/testlib/qtestlog_p.h index c667289b66..f06382978f 100644 --- a/src/testlib/qtestlog_p.h +++ b/src/testlib/qtestlog_p.h @@ -83,15 +83,13 @@ public: static void startLogging(); static void stopLogging(); - static void setLogMode(LogMode mode); + static void initLogger(LogMode mode, const char *filename); + static LogMode logMode(); static void setVerboseLevel(int level); static int verboseLevel(); - static void redirectOutput(const char *fileName); - static const char *outputFileName(); - static void setMaxWarnings(int max); private: diff --git a/src/testlib/qxmltestlogger.cpp b/src/testlib/qxmltestlogger.cpp index ec153c8e17..304cd0a0ef 100644 --- a/src/testlib/qxmltestlogger.cpp +++ b/src/testlib/qxmltestlogger.cpp @@ -92,8 +92,8 @@ namespace QTest { } -QXmlTestLogger::QXmlTestLogger(XmlMode mode ) - : xmlmode(mode) +QXmlTestLogger::QXmlTestLogger(XmlMode mode, const char *filename) + : QAbstractTestLogger(filename), xmlmode(mode) { } @@ -101,9 +101,9 @@ QXmlTestLogger::~QXmlTestLogger() { } -void QXmlTestLogger::startLogging(const char *filename) +void QXmlTestLogger::startLogging() { - QAbstractTestLogger::startLogging(filename); + QAbstractTestLogger::startLogging(); QTestCharBuffer buf; if (xmlmode == QXmlTestLogger::Complete) { diff --git a/src/testlib/qxmltestlogger_p.h b/src/testlib/qxmltestlogger_p.h index 5a3fb27d78..c273493c48 100644 --- a/src/testlib/qxmltestlogger_p.h +++ b/src/testlib/qxmltestlogger_p.h @@ -63,10 +63,10 @@ class QXmlTestLogger : public QAbstractTestLogger public: enum XmlMode { Complete = 0, Light }; - QXmlTestLogger(XmlMode mode); + QXmlTestLogger(XmlMode mode, const char *filename); ~QXmlTestLogger(); - void startLogging(const char *filename); + void startLogging(); void stopLogging(); void enterTestFunction(const char *function); diff --git a/src/testlib/qxunittestlogger.cpp b/src/testlib/qxunittestlogger.cpp index 69705b837b..f923b2334b 100644 --- a/src/testlib/qxunittestlogger.cpp +++ b/src/testlib/qxunittestlogger.cpp @@ -51,8 +51,9 @@ QT_BEGIN_NAMESPACE -QXunitTestLogger::QXunitTestLogger() - : listOfTestcases(0) +QXunitTestLogger::QXunitTestLogger(const char *filename) + : QAbstractTestLogger(filename) + , listOfTestcases(0) , currentLogElement(0) , errorLogElement(0) , logFormatter(0) @@ -68,9 +69,9 @@ QXunitTestLogger::~QXunitTestLogger() delete logFormatter; } -void QXunitTestLogger::startLogging(const char *filename) +void QXunitTestLogger::startLogging() { - QAbstractTestLogger::startLogging(filename); + QAbstractTestLogger::startLogging(); logFormatter = new QTestXunitStreamer(this); delete errorLogElement; diff --git a/src/testlib/qxunittestlogger_p.h b/src/testlib/qxunittestlogger_p.h index 0607504310..a51d70533d 100644 --- a/src/testlib/qxunittestlogger_p.h +++ b/src/testlib/qxunittestlogger_p.h @@ -63,10 +63,10 @@ class QTestElement; class QXunitTestLogger : public QAbstractTestLogger { public: - QXunitTestLogger(); + QXunitTestLogger(const char *filename); ~QXunitTestLogger(); - void startLogging(const char *filename); + void startLogging(); void stopLogging(); void enterTestFunction(const char *function); -- cgit v1.2.3 From 74cf3bfc2c62ac30d16be68db1237a3dc55843a4 Mon Sep 17 00:00:00 2001 From: Kent Hansen Date: Fri, 2 Sep 2011 07:41:42 +0200 Subject: New configure.exe binary Change-Id: I129b9f17cfc195656701acf7bf1472846d237935 Reviewed-on: http://codereview.qt.nokia.com/4113 Reviewed-by: Qt Sanity Bot Reviewed-by: Oswald Buddenhagen --- configure.exe | Bin 1470464 -> 1491968 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/configure.exe b/configure.exe index 5b8013064f..cb4373b8dc 100644 Binary files a/configure.exe and b/configure.exe differ -- cgit v1.2.3 From 6fd75df2889c5635f3de265f40f9d23a35a94d00 Mon Sep 17 00:00:00 2001 From: Lasse Holmstedt Date: Wed, 31 Aug 2011 09:55:11 +0200 Subject: Generic property support for platform windows MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit QPlatformNativeInterface can now contain generic window properties in a QVariantMap, to facilitate communication with the compositor and clients for certain platforms. When window properties change, a signal is emitted from the respective QPlatformNativeInterface instance. The properties are intended to be read/writable from both client and server. Change-Id: I7b42f7910d03c0d309add6c7dbb1c9b66ad22a3f Reviewed-on: http://codereview.qt.nokia.com/3956 Reviewed-by: Samuel Rødal --- src/gui/kernel/qplatformnativeinterface_qpa.cpp | 41 +++++ src/gui/kernel/qplatformnativeinterface_qpa.h | 15 +- .../platforms/wayland/qwaylandnativeinterface.cpp | 34 +++- .../platforms/wayland/qwaylandnativeinterface.h | 10 +- src/plugins/platforms/wayland/qwaylandwindow.cpp | 3 + .../qwaylandwindowmanager-client-protocol.h | 106 ------------- .../qwaylandwindowmanagerintegration.cpp | 174 +++++++++++++++++++-- .../qwaylandwindowmanagerintegration.h | 33 +++- .../wayland-windowmanager-client-protocol.h | 96 ++++++++++++ .../wayland-windowmanager-protocol.c | 45 +++--- .../windowmanager_integration.pri | 2 +- 11 files changed, 400 insertions(+), 159 deletions(-) delete mode 100644 src/plugins/platforms/wayland/windowmanager_integration/qwaylandwindowmanager-client-protocol.h create mode 100644 src/plugins/platforms/wayland/windowmanager_integration/wayland-windowmanager-client-protocol.h diff --git a/src/gui/kernel/qplatformnativeinterface_qpa.cpp b/src/gui/kernel/qplatformnativeinterface_qpa.cpp index 32849d9b5a..e3f6689acc 100644 --- a/src/gui/kernel/qplatformnativeinterface_qpa.cpp +++ b/src/gui/kernel/qplatformnativeinterface_qpa.cpp @@ -50,4 +50,45 @@ void *QPlatformNativeInterface::nativeResourceForWidget(const QByteArray &resour return 0; } +/*! + Contains generic window properties that the platform may utilize. +*/ +QVariantMap QPlatformNativeInterface::windowProperties(QPlatformWindow *window) const +{ + return QVariantMap(); +} + +/*! + Returns a window property with \a name. + + If the property does not exist, returns a default-constructed value. +*/ +QVariant QPlatformNativeInterface::windowProperty(QPlatformWindow *window, const QString &name) const +{ + Q_UNUSED(window); + Q_UNUSED(name); + return QVariant(); +} + +/*! + Returns a window property with \a name. If the value does not exist, defaultValue is returned. +*/ +QVariant QPlatformNativeInterface::windowProperty(QPlatformWindow *window, const QString &name, const QVariant &defaultValue) const +{ + Q_UNUSED(window); + Q_UNUSED(name); + Q_UNUSED(defaultValue); + return QVariant(); +} + +/*! + Sets a window property with \a name to \a value. +*/ +void QPlatformNativeInterface::setWindowProperty(QPlatformWindow *window, const QString &name, const QVariant &value) +{ + Q_UNUSED(window); + Q_UNUSED(name); + Q_UNUSED(value); +} + QT_END_NAMESPACE diff --git a/src/gui/kernel/qplatformnativeinterface_qpa.h b/src/gui/kernel/qplatformnativeinterface_qpa.h index 9f22337f6c..dd57f94a88 100644 --- a/src/gui/kernel/qplatformnativeinterface_qpa.h +++ b/src/gui/kernel/qplatformnativeinterface_qpa.h @@ -43,6 +43,8 @@ #define QPLATFORMNATIVEINTERFACE_QPA_H #include +#include +#include QT_BEGIN_HEADER @@ -51,11 +53,22 @@ QT_BEGIN_NAMESPACE QT_MODULE(Gui) class QWidget; +class QPlatformWindow; -class Q_GUI_EXPORT QPlatformNativeInterface +class Q_GUI_EXPORT QPlatformNativeInterface : public QObject { + Q_OBJECT public: virtual void *nativeResourceForWidget(const QByteArray &resource, QWidget *widget); + + virtual QVariantMap windowProperties(QPlatformWindow *window) const; + virtual QVariant windowProperty(QPlatformWindow *window, const QString &name) const; + virtual QVariant windowProperty(QPlatformWindow *window, const QString &name, const QVariant &defaultValue) const; + virtual void setWindowProperty(QPlatformWindow *window, const QString &name, const QVariant &value); + +Q_SIGNALS: + void windowPropertyChanged(QPlatformWindow *window, const QString &propertyName); + }; QT_END_NAMESPACE diff --git a/src/plugins/platforms/wayland/qwaylandnativeinterface.cpp b/src/plugins/platforms/wayland/qwaylandnativeinterface.cpp index 43be74a6ea..17736968c6 100644 --- a/src/plugins/platforms/wayland/qwaylandnativeinterface.cpp +++ b/src/plugins/platforms/wayland/qwaylandnativeinterface.cpp @@ -40,10 +40,13 @@ ****************************************************************************/ #include "qwaylandnativeinterface.h" - #include "qwaylanddisplay.h" #include "qwaylandwindow.h" + +#include "windowmanager_integration/qwaylandwindowmanagerintegration.h" + #include +#include void *QWaylandNativeInterface::nativeResourceForWidget(const QByteArray &resourceString, QWidget *widget) { @@ -70,3 +73,32 @@ QWaylandScreen * QWaylandNativeInterface::qPlatformScreenForWidget(QWidget *widg } return screen; } + +QVariantMap QWaylandNativeInterface::windowProperties(QPlatformWindow *window) const +{ + return m_windowProperties.value(window); +} + +QVariant QWaylandNativeInterface::windowProperty(QPlatformWindow *window, const QString &name) const +{ + const QVariantMap properties = m_windowProperties.value(window); + return properties.value(name); +} + +QVariant QWaylandNativeInterface::windowProperty(QPlatformWindow *window, const QString &name, const QVariant &defaultValue) const +{ + const QVariantMap properties = m_windowProperties.value(window); + return properties.value(name, defaultValue); +} + +void QWaylandNativeInterface::setWindowProperty(QPlatformWindow *window, const QString &name, const QVariant &value) +{ + QVariantMap props = m_windowProperties.value(window); + props.insert(name, value); + m_windowProperties.insert(window, props); + + QWaylandWindow *wlWindow = static_cast(window); + QWaylandWindowManagerIntegration::instance()->setWindowProperty(wlWindow, name, value); + + emit windowPropertyChanged(window, name); +} diff --git a/src/plugins/platforms/wayland/qwaylandnativeinterface.h b/src/plugins/platforms/wayland/qwaylandnativeinterface.h index d33a41b00b..c92b44eb03 100644 --- a/src/plugins/platforms/wayland/qwaylandnativeinterface.h +++ b/src/plugins/platforms/wayland/qwaylandnativeinterface.h @@ -43,7 +43,7 @@ #define QWAYLANDNATIVEINTERFACE_H #include "qwaylandscreen.h" - +#include #include class QWaylandNativeInterface : public QPlatformNativeInterface @@ -52,8 +52,16 @@ public: void *nativeResourceForWidget(const QByteArray &resourceString, QWidget *widget); + QVariantMap windowProperties(QPlatformWindow *window) const; + QVariant windowProperty(QPlatformWindow *window, const QString &name) const; + QVariant windowProperty(QPlatformWindow *window, const QString &name, const QVariant &defaultValue) const; + void setWindowProperty(QPlatformWindow *window, const QString &name, const QVariant &value); + private: static QWaylandScreen *qPlatformScreenForWidget(QWidget *widget); + +private: + QHash m_windowProperties; }; diff --git a/src/plugins/platforms/wayland/qwaylandwindow.cpp b/src/plugins/platforms/wayland/qwaylandwindow.cpp index ef2047e0f3..099ebabb06 100644 --- a/src/plugins/platforms/wayland/qwaylandwindow.cpp +++ b/src/plugins/platforms/wayland/qwaylandwindow.cpp @@ -147,6 +147,9 @@ void QWaylandWindow::newSurfaceCreated() // do not damage the surface here, as this leads to graphical corruptions in the compositor until // the first frame has been rendered } +#ifdef QT_WAYLAND_WINDOWMANAGER_SUPPORT + QWaylandWindowManagerIntegration::instance()->flushPropertyChanges(this); +#endif } void QWaylandWindow::frameCallback(struct wl_surface *surface, void *data, uint32_t time) diff --git a/src/plugins/platforms/wayland/windowmanager_integration/qwaylandwindowmanager-client-protocol.h b/src/plugins/platforms/wayland/windowmanager_integration/qwaylandwindowmanager-client-protocol.h deleted file mode 100644 index e781b16c41..0000000000 --- a/src/plugins/platforms/wayland/windowmanager_integration/qwaylandwindowmanager-client-protocol.h +++ /dev/null @@ -1,106 +0,0 @@ -/* - * Copyright © 2010 Kristian Høgsberg - * - * Permission to use, copy, modify, distribute, and sell this software and its - * documentation for any purpose is hereby granted without fee, provided that - * the above copyright notice appear in all copies and that both that copyright - * notice and this permission notice appear in supporting documentation, and - * that the name of the copyright holders not be used in advertising or - * publicity pertaining to distribution of the software without specific, - * written prior permission. The copyright holders make no representations - * about the suitability of this software for any purpose. It is provided "as - * is" without express or implied warranty. - * - * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, - * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO - * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR - * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, - * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER - * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE - * OF THIS SOFTWARE. - */ - - -#ifndef WAYLAND_WINDOWMANAGER_CLIENT_PROTOCOL_H -#define WAYLAND_WINDOWMANAGER_CLIENT_PROTOCOL_H - -#ifdef __cplusplus -extern "C" { -#endif - -#include -#include -#include "wayland-util.h" - -struct wl_client; - -struct wl_windowmanager; - -extern const struct wl_interface wl_windowmanager_interface; - -struct wl_windowmanager_listener { - void (*client_onscreen_visibility)(void *data, - struct wl_windowmanager *wl_windowmanager, - int visible); - void (*set_screen_rotation)(void *data, - struct wl_windowmanager *wl_windowmanager, - int rotation); -}; - -static inline int -wl_windowmanager_add_listener(struct wl_windowmanager *wl_windowmanager, - const struct wl_windowmanager_listener *listener, void *data) -{ - return wl_proxy_add_listener((struct wl_proxy *) wl_windowmanager, - (void (**)(void)) listener, data); -} - -#define WL_WINDOWMANAGER_MAP_CLIENT_TO_PROCESS 0 -#define WL_WINDOWMANAGER_AUTHENTICATE_WITH_TOKEN 1 - -static inline struct wl_windowmanager * -wl_windowmanager_create(struct wl_display *display, uint32_t id, uint32_t version) -{ - wl_display_bind(display, id, "wl_windowmanager", version); - - return (struct wl_windowmanager *) - wl_proxy_create_for_id(display, &wl_windowmanager_interface, id); -} - -static inline void -wl_windowmanager_set_user_data(struct wl_windowmanager *wl_windowmanager, void *user_data) -{ - wl_proxy_set_user_data((struct wl_proxy *) wl_windowmanager, user_data); -} - -static inline void * -wl_windowmanager_get_user_data(struct wl_windowmanager *wl_windowmanager) -{ - return wl_proxy_get_user_data((struct wl_proxy *) wl_windowmanager); -} - -static inline void -wl_windowmanager_destroy(struct wl_windowmanager *wl_windowmanager) -{ - wl_proxy_destroy((struct wl_proxy *) wl_windowmanager); -} - -static inline void -wl_windowmanager_map_client_to_process(struct wl_windowmanager *wl_windowmanager, uint32_t processid) -{ - wl_proxy_marshal((struct wl_proxy *) wl_windowmanager, - WL_WINDOWMANAGER_MAP_CLIENT_TO_PROCESS, processid); -} - -static inline void -wl_windowmanager_authenticate_with_token(struct wl_windowmanager *wl_windowmanager, const char *processid) -{ - wl_proxy_marshal((struct wl_proxy *) wl_windowmanager, - WL_WINDOWMANAGER_AUTHENTICATE_WITH_TOKEN, processid); -} - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/src/plugins/platforms/wayland/windowmanager_integration/qwaylandwindowmanagerintegration.cpp b/src/plugins/platforms/wayland/windowmanager_integration/qwaylandwindowmanagerintegration.cpp index 60b0a5605e..798900bbce 100644 --- a/src/plugins/platforms/wayland/windowmanager_integration/qwaylandwindowmanagerintegration.cpp +++ b/src/plugins/platforms/wayland/windowmanager_integration/qwaylandwindowmanagerintegration.cpp @@ -40,17 +40,44 @@ ****************************************************************************/ #include "qwaylandwindowmanagerintegration.h" -#include "qwaylandwindowmanager-client-protocol.h" +#include "wayland-windowmanager-client-protocol.h" +#include "qwaylandwindow.h" #include -#include -#include +#include +#include +#include +#include #include -#include +#include +#include + +#include + +class QWaylandWindowManagerIntegrationPrivate { +public: + QWaylandWindowManagerIntegrationPrivate(QWaylandDisplay *waylandDisplay); + bool m_blockPropertyUpdates; + QWaylandDisplay *m_waylandDisplay; + struct wl_windowmanager *m_waylandWindowManager; + QHash m_queuedProperties; -const struct wl_windowmanager_listener QWaylandWindowManagerIntegration::mWindowManagerListener = { +}; + +QWaylandWindowManagerIntegrationPrivate::QWaylandWindowManagerIntegrationPrivate(QWaylandDisplay *waylandDisplay) + : m_blockPropertyUpdates(false) + , m_waylandDisplay(waylandDisplay) + , m_waylandWindowManager(0) +{ + +} + +QWaylandWindowManagerIntegration *QWaylandWindowManagerIntegration::m_instance = 0; + +const struct wl_windowmanager_listener QWaylandWindowManagerIntegration::m_windowManagerListener = { QWaylandWindowManagerIntegration::wlHandleOnScreenVisibilityChange, QWaylandWindowManagerIntegration::wlHandleScreenOrientationChange, + QWaylandWindowManagerIntegration::wlHandleWindowPropertyChange }; QWaylandWindowManagerIntegration *QWaylandWindowManagerIntegration::createIntegration(QWaylandDisplay *waylandDisplay) @@ -59,10 +86,11 @@ QWaylandWindowManagerIntegration *QWaylandWindowManagerIntegration::createIntegr } QWaylandWindowManagerIntegration::QWaylandWindowManagerIntegration(QWaylandDisplay *waylandDisplay) - : mWaylandDisplay(waylandDisplay) - , mWaylandWindowManager(0) + : d_ptr(new QWaylandWindowManagerIntegrationPrivate(waylandDisplay)) { - wl_display_add_global_listener(mWaylandDisplay->wl_display(), + m_instance = this; + + wl_display_add_global_listener(d_ptr->m_waylandDisplay->wl_display(), QWaylandWindowManagerIntegration::wlHandleListenerGlobal, this); } @@ -72,9 +100,15 @@ QWaylandWindowManagerIntegration::~QWaylandWindowManagerIntegration() } +QWaylandWindowManagerIntegration *QWaylandWindowManagerIntegration::instance() +{ + return m_instance; +} + struct wl_windowmanager *QWaylandWindowManagerIntegration::windowManager() const { - return mWaylandWindowManager; + Q_D(const QWaylandWindowManagerIntegration); + return d->m_waylandWindowManager; } void QWaylandWindowManagerIntegration::wlHandleListenerGlobal(wl_display *display, uint32_t id, const char *interface, uint32_t version, void *data) @@ -82,29 +116,95 @@ void QWaylandWindowManagerIntegration::wlHandleListenerGlobal(wl_display *displa Q_UNUSED(version); if (strcmp(interface, "wl_windowmanager") == 0) { QWaylandWindowManagerIntegration *integration = static_cast(data); - integration->mWaylandWindowManager = wl_windowmanager_create(display, id, 1); - - wl_windowmanager_add_listener(integration->mWaylandWindowManager, &mWindowManagerListener, integration); + integration->d_ptr->m_waylandWindowManager = wl_windowmanager_create(display, id, 1); + wl_windowmanager *windowManager = integration->d_ptr->m_waylandWindowManager; + wl_windowmanager_add_listener(windowManager, &m_windowManagerListener, integration); } } void QWaylandWindowManagerIntegration::mapClientToProcess(long long processId) { - if (mWaylandWindowManager) - wl_windowmanager_map_client_to_process(mWaylandWindowManager, (uint32_t) processId); + Q_D(QWaylandWindowManagerIntegration); + if (d->m_waylandWindowManager) + wl_windowmanager_map_client_to_process(d->m_waylandWindowManager, (uint32_t) processId); } void QWaylandWindowManagerIntegration::authenticateWithToken(const QByteArray &token) { + Q_D(QWaylandWindowManagerIntegration); QByteArray authToken = token; if (authToken.isEmpty()) authToken = qgetenv("WL_AUTHENTICATION_TOKEN"); - if (mWaylandWindowManager && !authToken.isEmpty()) { - wl_windowmanager_authenticate_with_token(mWaylandWindowManager, authToken.constData()); + if (d->m_waylandWindowManager && !authToken.isEmpty()) { + wl_windowmanager_authenticate_with_token(d->m_waylandWindowManager, authToken.constData()); + } +} + +static wl_array writePropertyValue(const QVariant &value) +{ + QByteArray byteValue; + QDataStream ds(&byteValue, QIODevice::WriteOnly); + ds << value; + + wl_array data; + data.size = byteValue.size(); + data.data = (void*)byteValue.constData(); + data.alloc = 0; + + return data; +} + +void QWaylandWindowManagerIntegration::setWindowProperty(QWaylandWindow *window, const QString &propertyName, const QVariant &propertyValue) +{ + Q_D(QWaylandWindowManagerIntegration); + if (d->m_blockPropertyUpdates) + return; + + if (window->wl_surface()) { + wl_array data = writePropertyValue(propertyValue); + wl_windowmanager_update_generic_property(d->m_waylandWindowManager, window->wl_surface(), + propertyName.toLatin1().constData(), + &data); + } else { + QVariantMap props = d->m_queuedProperties.value(window); + props.insert(propertyName, propertyValue); + d->m_queuedProperties.insert(window, props); + // ### TODO we'll need to add listening to destroyed() of QWindow that owns QWaylandWindow + // once refactor changes are in, and connect to removeQueuedPropertiesForWindow(). } } +void QWaylandWindowManagerIntegration::flushPropertyChanges(QWaylandWindow *windowToFlush) +{ + // write all changes we got while we did not have a surface. + // this can happen during startup, for example, or while the window is hidden. + Q_D(QWaylandWindowManagerIntegration); + + if (!windowToFlush) + return; + + QVariantMap properties = d->m_queuedProperties.value(windowToFlush); + wl_surface *surface = windowToFlush->wl_surface(); + + QMapIterator pIt(properties); + while (pIt.hasNext()) { + pIt.next(); + wl_array data = writePropertyValue(pIt.value()); + wl_windowmanager_update_generic_property(d->m_waylandWindowManager, surface, pIt.key().toLatin1().constData(), &data); + } + + d->m_queuedProperties.clear(); +} + +void QWaylandWindowManagerIntegration::removeQueuedPropertiesForWindow() +{ + // TODO enable this later once refactor changes are in. +// Q_D(QWaylandWindowManagerIntegration); +// QWaylandWindow *window = 0; +// d->m_queuedProperties.remove(window); +} + void QWaylandWindowManagerIntegration::wlHandleOnScreenVisibilityChange(void *data, struct wl_windowmanager *wl_windowmanager, int visible) { Q_UNUSED(data); @@ -120,3 +220,45 @@ void QWaylandWindowManagerIntegration::wlHandleScreenOrientationChange(void *dat QScreenOrientationChangeEvent event(screenOrientation); QCoreApplication::sendEvent(QCoreApplication::instance(), &event); } + +void QWaylandWindowManagerIntegration::wlHandleWindowPropertyChange(void *data, struct wl_windowmanager *wl_windowmanager, + struct wl_surface *surface, + const char *propertyName, struct wl_array *propertyValue) +{ + // window manager changes a window property + Q_UNUSED(data); + Q_UNUSED(wl_windowmanager); + + QVariant variantValue; + QByteArray baValue = QByteArray((const char*)propertyValue->data, propertyValue->size); + QDataStream ds(&baValue, QIODevice::ReadOnly); + ds >> variantValue; + + QPlatformNativeInterface *nativeInterface = qApp->platformNativeInterface(); + QWaylandWindowManagerIntegration *inst = QWaylandWindowManagerIntegration::instance(); + + QWidgetList widgets = qApp->topLevelWidgets(); + foreach (QWidget *widget, widgets) { + QPlatformWindow *platformWindowForWidget = widget->platformWindow(); + if (!platformWindowForWidget) + continue; + QWaylandWindow *window = static_cast(platformWindowForWidget); + wl_surface *windowSurface = (wl_surface*)nativeInterface->nativeResourceForWidget(QByteArray("surface"), widget); + if (windowSurface == surface) { + inst->handleWindowPropertyChange(window, QString(propertyName), variantValue); + break; + } + } +} + +void QWaylandWindowManagerIntegration::handleWindowPropertyChange(QWaylandWindow *window, + const QString &propertyName, const QVariant &propertyValue) +{ + Q_D(QWaylandWindowManagerIntegration); + d->m_blockPropertyUpdates = true; + + QPlatformNativeInterface *nativeInterface = qApp->platformNativeInterface(); + nativeInterface->setWindowProperty(window, propertyName, propertyValue); + + d->m_blockPropertyUpdates = false; +} diff --git a/src/plugins/platforms/wayland/windowmanager_integration/qwaylandwindowmanagerintegration.h b/src/plugins/platforms/wayland/windowmanager_integration/qwaylandwindowmanagerintegration.h index 6b4658c7e1..1372fb81b8 100644 --- a/src/plugins/platforms/wayland/windowmanager_integration/qwaylandwindowmanagerintegration.h +++ b/src/plugins/platforms/wayland/windowmanager_integration/qwaylandwindowmanagerintegration.h @@ -42,21 +42,37 @@ #ifndef QWAYLANDWINDOWMANAGERINTEGRATION_H #define QWAYLANDWINDOWMANAGERINTEGRATION_H -#include +#include +#include + #include "wayland-client.h" #include "qwaylanddisplay.h" -class QWaylandWindowManagerIntegration +class QWaylandWindow; + +class QWaylandWindowManagerIntegrationPrivate; + +class QWaylandWindowManagerIntegration : public QObject { + Q_OBJECT + Q_DECLARE_PRIVATE(QWaylandWindowManagerIntegration) public: explicit QWaylandWindowManagerIntegration(QWaylandDisplay *waylandDisplay); virtual ~QWaylandWindowManagerIntegration(); static QWaylandWindowManagerIntegration *createIntegration(QWaylandDisplay *waylandDisplay); struct wl_windowmanager *windowManager() const; + static QWaylandWindowManagerIntegration *instance(); + void mapSurfaceToProcess(struct wl_surface *surface, long long processId); void mapClientToProcess(long long processId); void authenticateWithToken(const QByteArray &token = QByteArray()); + void setWindowProperty(QWaylandWindow *window, const QString &propertyName, const QVariant &propertyValue); + + void flushPropertyChanges(QWaylandWindow *windowToFlush); + +private slots: + void removeQueuedPropertiesForWindow(); private: static void wlHandleListenerGlobal(wl_display *display, uint32_t id, @@ -64,12 +80,17 @@ private: static void wlHandleOnScreenVisibilityChange(void *data, struct wl_windowmanager *wl_windowmanager, int visible); static void wlHandleScreenOrientationChange(void *data, struct wl_windowmanager *wl_windowmanager, int screenOrientation); -private: + static void wlHandleWindowPropertyChange(void *data, struct wl_windowmanager *wl_windowmanager, + struct wl_surface *surface, + const char *propertyName, struct wl_array *propertyValue); - QWaylandDisplay *mWaylandDisplay; - struct wl_windowmanager *mWaylandWindowManager; + void handleWindowPropertyChange(QWaylandWindow *window, const QString &propertyName, const QVariant &propertyValue); + +private: + QScopedPointer d_ptr; + static QWaylandWindowManagerIntegration *m_instance; - static const struct wl_windowmanager_listener mWindowManagerListener; + static const struct wl_windowmanager_listener m_windowManagerListener; }; #endif // QWAYLANDWINDOWMANAGERINTEGRATION_H diff --git a/src/plugins/platforms/wayland/windowmanager_integration/wayland-windowmanager-client-protocol.h b/src/plugins/platforms/wayland/windowmanager_integration/wayland-windowmanager-client-protocol.h new file mode 100644 index 0000000000..034c08f28a --- /dev/null +++ b/src/plugins/platforms/wayland/windowmanager_integration/wayland-windowmanager-client-protocol.h @@ -0,0 +1,96 @@ +#ifndef WAYLAND_WINDOWMANAGER_CLIENT_PROTOCOL_H +#define WAYLAND_WINDOWMANAGER_CLIENT_PROTOCOL_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include +#include "wayland-util.h" + +struct wl_client; + +struct wl_windowmanager; + +extern const struct wl_interface wl_windowmanager_interface; + +struct wl_windowmanager_listener { + void (*client_onscreen_visibility)(void *data, + struct wl_windowmanager *wl_windowmanager, + int32_t visible); + void (*set_screen_rotation)(void *data, + struct wl_windowmanager *wl_windowmanager, + int32_t rotation); + void (*set_generic_property)(void *data, + struct wl_windowmanager *wl_windowmanager, + struct wl_surface *surface, + const char *name, + struct wl_array *value); +}; + +static inline int +wl_windowmanager_add_listener(struct wl_windowmanager *wl_windowmanager, + const struct wl_windowmanager_listener *listener, void *data) +{ + return wl_proxy_add_listener((struct wl_proxy *) wl_windowmanager, + (void (**)(void)) listener, data); +} + +#define WL_WINDOWMANAGER_MAP_CLIENT_TO_PROCESS 0 +#define WL_WINDOWMANAGER_AUTHENTICATE_WITH_TOKEN 1 +#define WL_WINDOWMANAGER_UPDATE_GENERIC_PROPERTY 2 + +static inline struct wl_windowmanager * +wl_windowmanager_create(struct wl_display *display, uint32_t id, uint32_t version) +{ + wl_display_bind(display, id, "wl_windowmanager", version); + + return (struct wl_windowmanager *) + wl_proxy_create_for_id(display, &wl_windowmanager_interface, id); +} + +static inline void +wl_windowmanager_set_user_data(struct wl_windowmanager *wl_windowmanager, void *user_data) +{ + wl_proxy_set_user_data((struct wl_proxy *) wl_windowmanager, user_data); +} + +static inline void * +wl_windowmanager_get_user_data(struct wl_windowmanager *wl_windowmanager) +{ + return wl_proxy_get_user_data((struct wl_proxy *) wl_windowmanager); +} + +static inline void +wl_windowmanager_destroy(struct wl_windowmanager *wl_windowmanager) +{ + wl_proxy_destroy((struct wl_proxy *) wl_windowmanager); +} + +static inline void +wl_windowmanager_map_client_to_process(struct wl_windowmanager *wl_windowmanager, uint32_t processid) +{ + wl_proxy_marshal((struct wl_proxy *) wl_windowmanager, + WL_WINDOWMANAGER_MAP_CLIENT_TO_PROCESS, processid); +} + +static inline void +wl_windowmanager_authenticate_with_token(struct wl_windowmanager *wl_windowmanager, const char *processid) +{ + wl_proxy_marshal((struct wl_proxy *) wl_windowmanager, + WL_WINDOWMANAGER_AUTHENTICATE_WITH_TOKEN, processid); +} + +static inline void +wl_windowmanager_update_generic_property(struct wl_windowmanager *wl_windowmanager, struct wl_surface *surface, const char *name, struct wl_array *value) +{ + wl_proxy_marshal((struct wl_proxy *) wl_windowmanager, + WL_WINDOWMANAGER_UPDATE_GENERIC_PROPERTY, surface, name, value); +} + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/src/plugins/platforms/wayland/windowmanager_integration/wayland-windowmanager-protocol.c b/src/plugins/platforms/wayland/windowmanager_integration/wayland-windowmanager-protocol.c index 8125dec4d3..1d231f5d22 100644 --- a/src/plugins/platforms/wayland/windowmanager_integration/wayland-windowmanager-protocol.c +++ b/src/plugins/platforms/wayland/windowmanager_integration/wayland-windowmanager-protocol.c @@ -1,38 +1,29 @@ -/* - * Copyright © 2010 Kristian Høgsberg - * - * Permission to use, copy, modify, distribute, and sell this software and its - * documentation for any purpose is hereby granted without fee, provided that - * the above copyright notice appear in all copies and that both that copyright - * notice and this permission notice appear in supporting documentation, and - * that the name of the copyright holders not be used in advertising or - * publicity pertaining to distribution of the software without specific, - * written prior permission. The copyright holders make no representations - * about the suitability of this software for any purpose. It is provided "as - * is" without express or implied warranty. - * - * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, - * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO - * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR - * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, - * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER - * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE - * OF THIS SOFTWARE. - */ - - #include #include #include "wayland-util.h" +extern const struct wl_interface wl_surface_interface; + +static const struct wl_interface *types[] = { + NULL, + &wl_surface_interface, + NULL, + NULL, + &wl_surface_interface, + NULL, + NULL, +}; + static const struct wl_message wl_windowmanager_requests[] = { - { "map_client_to_process", "u", NULL }, - { "authenticate_with_token", "s", NULL }, + { "map_client_to_process", "u", types + 0 }, + { "authenticate_with_token", "s", types + 0 }, + { "update_generic_property", "osa", types + 1 }, }; static const struct wl_message wl_windowmanager_events[] = { - { "client_onscreen_visibility", "i", NULL }, - { "set_screen_rotation", "i", NULL }, + { "client_onscreen_visibility", "i", types + 0 }, + { "set_screen_rotation", "i", types + 0 }, + { "set_generic_property", "osa", types + 4 }, }; WL_EXPORT const struct wl_interface wl_windowmanager_interface = { diff --git a/src/plugins/platforms/wayland/windowmanager_integration/windowmanager_integration.pri b/src/plugins/platforms/wayland/windowmanager_integration/windowmanager_integration.pri index a28218272d..45118b5d50 100644 --- a/src/plugins/platforms/wayland/windowmanager_integration/windowmanager_integration.pri +++ b/src/plugins/platforms/wayland/windowmanager_integration/windowmanager_integration.pri @@ -3,7 +3,7 @@ DEFINES += QT_WAYLAND_WINDOWMANAGER_SUPPORT contains(DEFINES, QT_WAYLAND_WINDOWMANAGER_SUPPORT) { HEADERS += \ - $$PWD/qwaylandwindowmanager-client-protocol.h \ + $$PWD/wayland-windowmanager-client-protocol.h \ $$PWD/qwaylandwindowmanagerintegration.h SOURCES += \ -- cgit v1.2.3 From 8ed47d961dc7e6f161030654d11cd330a542eadf Mon Sep 17 00:00:00 2001 From: "Bradley T. Hughes" Date: Wed, 31 Aug 2011 15:17:30 +0200 Subject: Don't use QSettings to "cache" plugin information The main rationale of the cache was to examine the plugin's build-key before loading it. Now that the build-key has been removed, the cache has lost its usefulness. This is part of a larger push to not use QSettings for Qt specific settings or caches. See also: http://lists.qt.nokia.com/pipermail/qt5-feedback/2011-August/000892.html http://lists.qt.nokia.com/pipermail/qt5-feedback/2011-August/000960.html http://lists.qt.nokia.com/pipermail/qt5-feedback/2011-August/000907.html http://lists.qt.nokia.com/pipermail/qt5-feedback/2011-August/000904.html Change-Id: I96e84aa25983c8e06e027ff70cef109444c362a2 Reviewed-on: http://codereview.qt.nokia.com/3978 Reviewed-by: Qt Sanity Bot Reviewed-by: Lars Knoll --- src/corelib/kernel/qcoreapplication.cpp | 12 --- src/corelib/kernel/qcoreapplication_p.h | 1 - src/corelib/plugin/qfactoryloader.cpp | 57 ++++------- src/corelib/plugin/qlibrary.cpp | 165 +++++++++++--------------------- src/corelib/plugin/qlibrary_p.h | 3 +- src/corelib/plugin/qpluginloader.cpp | 16 ---- 6 files changed, 77 insertions(+), 177 deletions(-) diff --git a/src/corelib/kernel/qcoreapplication.cpp b/src/corelib/kernel/qcoreapplication.cpp index 2458f9649e..6d8bf20b7c 100644 --- a/src/corelib/kernel/qcoreapplication.cpp +++ b/src/corelib/kernel/qcoreapplication.cpp @@ -266,18 +266,6 @@ bool QCoreApplicationPrivate::is_app_closing = false; // initialized in qcoreapplication and in qtextstream autotest when setlocale is called. Q_CORE_EXPORT bool qt_locale_initialized = false; - -/* - Create an instance of Trolltech.conf. This ensures that the settings will not - be thrown out of QSetting's cache for unused settings. - */ -Q_GLOBAL_STATIC_WITH_ARGS(QSettings, staticTrolltechConf, (QSettings::UserScope, QLatin1String("Trolltech"))) - -QSettings *QCoreApplicationPrivate::trolltechConf() -{ - return staticTrolltechConf(); -} - Q_CORE_EXPORT uint qGlobalPostedEventsCount() { QThreadData *currentThreadData = QThreadData::current(); diff --git a/src/corelib/kernel/qcoreapplication_p.h b/src/corelib/kernel/qcoreapplication_p.h index 553e15f7db..8dff4ed80c 100644 --- a/src/corelib/kernel/qcoreapplication_p.h +++ b/src/corelib/kernel/qcoreapplication_p.h @@ -139,7 +139,6 @@ public: static uint attribs; static inline bool testAttribute(uint flag) { return attribs & (1 << flag); } static int app_compile_version; - static QSettings *trolltechConf(); }; QT_END_NAMESPACE diff --git a/src/corelib/plugin/qfactoryloader.cpp b/src/corelib/plugin/qfactoryloader.cpp index c8831e5ae5..c175dcfe1b 100644 --- a/src/corelib/plugin/qfactoryloader.cpp +++ b/src/corelib/plugin/qfactoryloader.cpp @@ -45,7 +45,6 @@ #include "qfactoryinterface.h" #include "qmap.h" #include -#include #include #include "qmutex.h" #include "qplugin.h" @@ -107,7 +106,6 @@ void QFactoryLoader::update() #ifdef QT_SHARED Q_D(QFactoryLoader); QStringList paths = QCoreApplication::libraryPaths(); - QSettings settings(QSettings::UserScope, QLatin1String("Trolltech")); for (int i = 0; i < paths.count(); ++i) { const QString &pluginDir = paths.at(i); // Already loaded, skip it... @@ -127,7 +125,7 @@ void QFactoryLoader::update() qDebug() << "QFactoryLoader::QFactoryLoader() looking at" << fileName; } library = QLibraryPrivate::findOrCreate(QFileInfo(fileName).canonicalFilePath()); - if (!library->isPlugin(&settings)) { + if (!library->isPlugin()) { if (qt_debug_component()) { qDebug() << library->errorString; qDebug() << " not a plugin"; @@ -135,45 +133,26 @@ void QFactoryLoader::update() library->release(); continue; } - QString regkey = QString::fromLatin1("Qt Factory Cache %1.%2/%3:/%4") - .arg((QT_VERSION & 0xff0000) >> 16) - .arg((QT_VERSION & 0xff00) >> 8) - .arg(QLatin1String(d->iid)) - .arg(fileName); - QStringList reg, keys; - reg = settings.value(regkey).toStringList(); - if (reg.count() && library->lastModified == reg[0]) { - keys = reg; - keys.removeFirst(); - } else { - if (!library->loadPlugin()) { - if (qt_debug_component()) { - qDebug() << library->errorString; - qDebug() << " could not load"; - } - library->release(); - continue; - } - QObject *instance = library->instance(); - if (!instance) { - library->release(); - // ignore plugins that have a valid signature but cannot be loaded. - continue; + QStringList keys; + if (!library->loadPlugin()) { + if (qt_debug_component()) { + qDebug() << library->errorString; + qDebug() << " could not load"; } - QFactoryInterface *factory = qobject_cast(instance); - if (instance && factory && instance->qt_metacast(d->iid)) - keys = factory->keys(); - if (keys.isEmpty()) - library->unload(); - reg.clear(); - reg << library->lastModified; - reg += keys; - settings.setValue(regkey, reg); + library->release(); + continue; } - if (qt_debug_component()) { - qDebug() << "keys" << keys; + QObject *instance = library->instance(); + if (!instance) { + library->release(); + // ignore plugins that have a valid signature but cannot be loaded. + continue; } - + QFactoryInterface *factory = qobject_cast(instance); + if (instance && factory && instance->qt_metacast(d->iid)) + keys = factory->keys(); + if (keys.isEmpty()) + library->unload(); if (keys.isEmpty()) { library->release(); continue; diff --git a/src/corelib/plugin/qlibrary.cpp b/src/corelib/plugin/qlibrary.cpp index 0a4ab77189..580dc37bd2 100644 --- a/src/corelib/plugin/qlibrary.cpp +++ b/src/corelib/plugin/qlibrary.cpp @@ -50,8 +50,6 @@ #include #include #include -#include -#include #include #ifdef Q_OS_MAC # include @@ -648,7 +646,7 @@ bool qt_get_verificationdata(QtPluginQueryVerificationDataFunction pfn, uint *qt return qt_parse_pattern(szData, qt_version, debug); } -bool QLibraryPrivate::isPlugin(QSettings *settings) +bool QLibraryPrivate::isPlugin() { errorString.clear(); if (pluginState != MightBeAPlugin) @@ -672,135 +670,88 @@ bool QLibraryPrivate::isPlugin(QSettings *settings) } #endif - QFileInfo fileinfo(fileName); - -#ifndef QT_NO_DATESTRING - lastModified = fileinfo.lastModified().toString(Qt::ISODate); -#endif - QString regkey = QString::fromLatin1("Qt Plugin Cache %1.%2.%3/%4") - .arg((QT_VERSION & 0xff0000) >> 16) - .arg((QT_VERSION & 0xff00) >> 8) - .arg(QLIBRARY_AS_DEBUG ? QLatin1String("debug") : QLatin1String("false")) - .arg(fileName); -#ifdef Q_WS_MAC - // On Mac, add the application arch to the reg key in order to - // cache plugin information separately for each arch. This prevents - // Qt from wrongly caching plugin load failures when the archs - // don't match. -#if defined(__x86_64__) - regkey += QLatin1String("-x86_64"); -#elif defined(__i386__) - regkey += QLatin1String("-i386"); -#elif defined(__ppc64__) - regkey += QLatin1String("-ppc64"); -#elif defined(__ppc__) - regkey += QLatin1String("-ppc"); -#endif -#endif // Q_WS_MAC - - QStringList reg; -#ifndef QT_NO_SETTINGS - if (!settings) { - settings = QCoreApplicationPrivate::trolltechConf(); - } - reg = settings->value(regkey).toStringList(); -#endif - if (reg.count() == 3 && lastModified == reg.at(2)) { - qt_version = reg.at(0).toUInt(0, 16); - debug = bool(reg.at(1).toInt()); - success = qt_version != 0; - } else { #if defined(Q_OS_UNIX) && !defined(Q_OS_MAC) && !defined(Q_OS_SYMBIAN) - if (!pHnd) { - // use unix shortcut to avoid loading the library - success = qt_unix_query(fileName, &qt_version, &debug, this); - } else + if (!pHnd) { + // use unix shortcut to avoid loading the library + success = qt_unix_query(fileName, &qt_version, &debug, this); + } else #endif - { - bool retryLoadLibrary = false; // Only used on Windows with MS compiler.(false in other cases) - do { - bool temporary_load = false; + { + bool retryLoadLibrary = false; // Only used on Windows with MS compiler.(false in other cases) + do { + bool temporary_load = false; #ifdef Q_OS_WIN - HMODULE hTempModule = 0; + HMODULE hTempModule = 0; #endif - if (!pHnd) { + if (!pHnd) { #ifdef Q_OS_WIN - DWORD dwFlags = (retryLoadLibrary) ? 0: DONT_RESOLVE_DLL_REFERENCES; - //avoid 'Bad Image' message box - UINT oldmode = SetErrorMode(SEM_FAILCRITICALERRORS|SEM_NOOPENFILEERRORBOX); - hTempModule = ::LoadLibraryEx((wchar_t*)QDir::toNativeSeparators(fileName).utf16(), 0, dwFlags); - SetErrorMode(oldmode); + DWORD dwFlags = (retryLoadLibrary) ? 0: DONT_RESOLVE_DLL_REFERENCES; + //avoid 'Bad Image' message box + UINT oldmode = SetErrorMode(SEM_FAILCRITICALERRORS|SEM_NOOPENFILEERRORBOX); + hTempModule = ::LoadLibraryEx((wchar_t*)QDir::toNativeSeparators(fileName).utf16(), 0, dwFlags); + SetErrorMode(oldmode); #else # if defined(Q_OS_SYMBIAN) - //Guard against accidentally trying to load non-plugin libraries by making sure the stub exists - if (fileinfo.exists()) + //Guard against accidentally trying to load non-plugin libraries by making sure the stub exists + if (fileinfo.exists()) # endif - temporary_load = load_sys(); + temporary_load = load_sys(); #endif - } + } #ifdef Q_OS_WIN - QtPluginQueryVerificationDataFunction qtPluginQueryVerificationDataFunction = hTempModule ? (QtPluginQueryVerificationDataFunction) + QtPluginQueryVerificationDataFunction qtPluginQueryVerificationDataFunction = hTempModule ? (QtPluginQueryVerificationDataFunction) #ifdef Q_OS_WINCE - ::GetProcAddress(hTempModule, L"qt_plugin_query_verification_data") + ::GetProcAddress(hTempModule, L"qt_plugin_query_verification_data") #else - ::GetProcAddress(hTempModule, "qt_plugin_query_verification_data") + ::GetProcAddress(hTempModule, "qt_plugin_query_verification_data") #endif - : (QtPluginQueryVerificationDataFunction) resolve("qt_plugin_query_verification_data"); + : (QtPluginQueryVerificationDataFunction) resolve("qt_plugin_query_verification_data"); #else - QtPluginQueryVerificationDataFunction qtPluginQueryVerificationDataFunction = NULL; + QtPluginQueryVerificationDataFunction qtPluginQueryVerificationDataFunction = NULL; # if defined(Q_OS_SYMBIAN) - if (temporary_load) { - qtPluginQueryVerificationDataFunction = (QtPluginQueryVerificationDataFunction) resolve("qt_plugin_query_verification_data"); - // If resolving with function name failed (i.e. not STDDLL), try resolving using known ordinal - if (!qtPluginQueryVerificationDataFunction) - qtPluginQueryVerificationDataFunction = (QtPluginQueryVerificationDataFunction) resolve("1"); - } -# else + if (temporary_load) { qtPluginQueryVerificationDataFunction = (QtPluginQueryVerificationDataFunction) resolve("qt_plugin_query_verification_data"); + // If resolving with function name failed (i.e. not STDDLL), try resolving using known ordinal + if (!qtPluginQueryVerificationDataFunction) + qtPluginQueryVerificationDataFunction = (QtPluginQueryVerificationDataFunction) resolve("1"); + } +# else + qtPluginQueryVerificationDataFunction = (QtPluginQueryVerificationDataFunction) resolve("qt_plugin_query_verification_data"); # endif #endif - bool exceptionThrown = false; - bool ret = qt_get_verificationdata(qtPluginQueryVerificationDataFunction, - &qt_version, &debug, &exceptionThrown); - if (!exceptionThrown) { - if (!ret) { - qt_version = 0; - if (temporary_load) - unload_sys(); - } else { - success = true; - } - retryLoadLibrary = false; + bool exceptionThrown = false; + bool ret = qt_get_verificationdata(qtPluginQueryVerificationDataFunction, + &qt_version, &debug, &exceptionThrown); + if (!exceptionThrown) { + if (!ret) { + qt_version = 0; + if (temporary_load) + unload_sys(); + } else { + success = true; } + retryLoadLibrary = false; + } #ifdef QT_USE_MS_STD_EXCEPTION - else { - // An exception was thrown when calling qt_plugin_query_verification_data(). - // This usually happens when plugin is compiled with the /clr compiler flag, - // & will only work if the dependencies are loaded & DLLMain() is called. - // LoadLibrary() will do this, try once with this & if it fails dont load. - retryLoadLibrary = !retryLoadLibrary; - } + else { + // An exception was thrown when calling qt_plugin_query_verification_data(). + // This usually happens when plugin is compiled with the /clr compiler flag, + // & will only work if the dependencies are loaded & DLLMain() is called. + // LoadLibrary() will do this, try once with this & if it fails dont load. + retryLoadLibrary = !retryLoadLibrary; + } #endif #ifdef Q_OS_WIN - if (hTempModule) { - BOOL ok = ::FreeLibrary(hTempModule); - if (ok) { - hTempModule = 0; - } - + if (hTempModule) { + BOOL ok = ::FreeLibrary(hTempModule); + if (ok) { + hTempModule = 0; } -#endif - } while(retryLoadLibrary); // Will be 'false' in all cases other than when an - // exception is thrown(will happen only when using a MS compiler) - } -#ifndef QT_NO_SETTINGS - QStringList queried; - queried << QString::number(qt_version,16) - << QString::number((int)debug) - << lastModified; - settings->setValue(regkey, queried); + } #endif + } while (retryLoadLibrary); // Will be 'false' in all cases other than when an + // exception is thrown(will happen only when using a MS compiler) } if (!success) { diff --git a/src/corelib/plugin/qlibrary_p.h b/src/corelib/plugin/qlibrary_p.h index 12d625050f..5559489767 100644 --- a/src/corelib/plugin/qlibrary_p.h +++ b/src/corelib/plugin/qlibrary_p.h @@ -68,7 +68,6 @@ QT_BEGIN_NAMESPACE bool qt_debug_component(); -class QSettings; class QLibraryPrivate { public: @@ -99,7 +98,7 @@ public: QString errorString; QLibrary::LoadHints loadHints; - bool isPlugin(QSettings *settings = 0); + bool isPlugin(); private: diff --git a/src/corelib/plugin/qpluginloader.cpp b/src/corelib/plugin/qpluginloader.cpp index bbb64e42e7..591e36e20a 100644 --- a/src/corelib/plugin/qpluginloader.cpp +++ b/src/corelib/plugin/qpluginloader.cpp @@ -98,22 +98,6 @@ QT_BEGIN_NAMESPACE every instance has called unload(). Right before the unloading happen, the root component will also be deleted. - In order to speed up loading and validation of plugins, some of - the information that is collected during loading is cached in - persistent memory (through QSettings). For instance, the result - of a load operation (e.g. succeeded or failed) is stored in the - cache, so that subsequent load operations don't try to load an - invalid plugin. However, if the "last modified" timestamp of - a plugin has changed, the plugin's cache entry is invalidated - and the plugin is reloaded regardless of the values in the cache - entry. The cache entry is then updated with the new result of the - load operation. - - This also means that the timestamp must be updated each time the - plugin or any dependent resources (such as a shared library) is - updated, since the dependent resources might influence the result - of loading a plugin. - See \l{How to Create Qt Plugins} for more information about how to make your application extensible through plugins. -- cgit v1.2.3
\n" << "

Mismatch reported

\n" - << "

Baseline Info\n" - << "

Let this be the new baseline

\n" - << "

Blacklist this item

\n" - << "

Baseline Info\n"; + if (!hasOverride) { + out << "

Let this be the new baseline

\n" + << "

Blacklist this item

\n"; + } + out << "

Inspect

\n" << "