From 628d367a9d618568167d43195c1118b7d7979da0 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Tue, 15 Nov 2016 10:44:37 +0100 Subject: Stabilize tst_QFileDialog2::task143519_deleteAndRenameActionBehavior() The test relied on the file created being automatically selected, which sometimes does not happen when executing the entire test. Explicitly select the file and check the selection. Use the temporary directory for testing. Change-Id: Ia58641c1ac32ba21effa8a5ace9623eb5d48a1c2 Reviewed-by: Maurice Kalinowski --- tests/auto/widgets/dialogs/qfiledialog2/tst_qfiledialog2.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/tests/auto/widgets/dialogs/qfiledialog2/tst_qfiledialog2.cpp b/tests/auto/widgets/dialogs/qfiledialog2/tst_qfiledialog2.cpp index b457558879..656d4d46de 100644 --- a/tests/auto/widgets/dialogs/qfiledialog2/tst_qfiledialog2.cpp +++ b/tests/auto/widgets/dialogs/qfiledialog2/tst_qfiledialog2.cpp @@ -372,8 +372,7 @@ void tst_QFileDialog2::task143519_deleteAndRenameActionBehavior() // test based on task233037_selectingDirectory struct TestContext { - TestContext() - : current(QDir::current()) {} + explicit TestContext(const QString &path) : current(path) {} ~TestContext() { file.remove(); current.rmdir(test.dirName()); @@ -381,7 +380,9 @@ void tst_QFileDialog2::task143519_deleteAndRenameActionBehavior() QDir current; QDir test; QFile file; - } ctx; + }; + + TestContext ctx(tempDir.path()); // setup testbed QVERIFY(ctx.current.mkdir("task143519_deleteAndRenameActionBehavior_test")); // ensure at least one item @@ -395,6 +396,7 @@ void tst_QFileDialog2::task143519_deleteAndRenameActionBehavior() QNonNativeFileDialog fd; fd.setViewMode(QFileDialog::List); fd.setDirectory(ctx.test.absolutePath()); + fd.selectFile(ctx.file.fileName()); fd.show(); QTest::qWaitForWindowActive(&fd); @@ -409,7 +411,7 @@ void tst_QFileDialog2::task143519_deleteAndRenameActionBehavior() // defaults QVERIFY(openContextMenu(fd)); - QCOMPARE(fd.selectedFiles().size(), 1); + QCOMPARE(fd.selectedFiles(), QStringList(ctx.file.fileName())); QCOMPARE(rm->isEnabled(), !fd.isReadOnly()); QCOMPARE(mv->isEnabled(), !fd.isReadOnly()); -- cgit v1.2.3 From f2205c48c21a6b135f2f59d0cf46e72f90f9f0f4 Mon Sep 17 00:00:00 2001 From: Robin Burchell Date: Fri, 11 Nov 2016 15:29:28 +0100 Subject: QFontEngine: Cache whether or not a font can be smoothly scaled This will be used by QtQuick to correct a performance regression introduced by 592614ea3ecd90ede2ae1b8e6579d1b898f474ec -- QFontDatabase::isSmoothlyScalable is quite computationally expensive; and now it is unconditionally expensive regardless of the platform. Change-Id: I82bfa65a963c6c3c276d574f2b379da4a9ba5b69 Reviewed-by: Konstantin Ritt Reviewed-by: Eskil Abrahamsen Blomfeldt --- src/gui/text/qfontdatabase.cpp | 3 ++- src/gui/text/qfontengine.cpp | 1 + src/gui/text/qfontengine_p.h | 1 + 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/gui/text/qfontdatabase.cpp b/src/gui/text/qfontdatabase.cpp index f1b2e84a1e..f1478515f4 100644 --- a/src/gui/text/qfontdatabase.cpp +++ b/src/gui/text/qfontdatabase.cpp @@ -948,8 +948,8 @@ QFontEngine *loadSingleEngine(int script, return 0; } + engine->isSmoothlyScalable = style->smoothScalable; fontCache->insertEngine(key, engine); - return engine; } } @@ -972,6 +972,7 @@ QFontEngine *loadSingleEngine(int script, return 0; } + engine->isSmoothlyScalable = style->smoothScalable; fontCache->insertEngine(key, engine); if (Q_LIKELY(cacheForCommonScript && !engine->symbol)) { diff --git a/src/gui/text/qfontengine.cpp b/src/gui/text/qfontengine.cpp index fa49b25073..790dd0b64b 100644 --- a/src/gui/text/qfontengine.cpp +++ b/src/gui/text/qfontengine.cpp @@ -251,6 +251,7 @@ QFontEngine::QFontEngine(Type type) cache_cost = 0; fsType = 0; symbol = false; + isSmoothlyScalable = false; glyphFormat = Format_None; m_subPixelPositionCount = 0; diff --git a/src/gui/text/qfontengine_p.h b/src/gui/text/qfontengine_p.h index 39cf826ee2..893dfb5092 100644 --- a/src/gui/text/qfontengine_p.h +++ b/src/gui/text/qfontengine_p.h @@ -283,6 +283,7 @@ public: uint cache_cost; // amount of mem used in bytes by the font uint fsType : 16; bool symbol; + bool isSmoothlyScalable; struct KernPair { uint left_right; QFixed adjust; -- cgit v1.2.3 From 083d8caee10892d2f3d9597609315231b6f8493a Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Thu, 20 Oct 2016 23:43:26 +0200 Subject: QXbmHandler: fix missing NUL-termination The buffer is fed into strstr() on the next loop iteration, but strstr() expects a NUL-terminated string. In the equivalent code some lines up, the buffer is explicitly terminated, and we never write the last character of the buffer again, so we'll not fall off the end of the buffer, but if we read less bytes than in the last line, we'll parse garbage from the previous line. Change-Id: I354e1ce1dea71188942305190500b4778a69b4ff Reviewed-by: Edward Welbourne --- src/gui/image/qxbmhandler.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/gui/image/qxbmhandler.cpp b/src/gui/image/qxbmhandler.cpp index 44d07f1624..b21bc75bc4 100644 --- a/src/gui/image/qxbmhandler.cpp +++ b/src/gui/image/qxbmhandler.cpp @@ -157,6 +157,7 @@ static bool read_xbm_body(QIODevice *device, int w, int h, QImage *outImage) } else { // read another line if ((readBytes = device->readLine(buf,buflen)) <= 0) // EOF ==> truncated image break; + buf[readBytes] = '\0'; p = buf + QByteArray::fromRawData(buf, readBytes).indexOf("0x"); } } -- cgit v1.2.3 From 1753d696070895f309c46ba5aee662b0f3a18bde Mon Sep 17 00:00:00 2001 From: "Martin T. H. Sandsmark" Date: Sat, 15 Oct 2016 14:14:00 +0200 Subject: QCss: Fix parsing of charset MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When including a CSS file in a HTML file sent to QTextDocument, and the CSS file starts with «@charset "UTF-8";», which is the correct way of declaring that, the parsing fails. If you omit the space, like «@charset"UTF-8";» the parsing succeeds, which is wrong. Fix this by expecting and swallowing whitespace after the @charset tokens. Task-number: QTBUG-54829 Change-Id: I32044e8d24bda70c1eb06bf74af50d4cabe2211d Reviewed-by: Allan Sandfeld Jensen --- src/gui/text/qcssparser.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/gui/text/qcssparser.cpp b/src/gui/text/qcssparser.cpp index e96aecdf68..3d6acccdb8 100644 --- a/src/gui/text/qcssparser.cpp +++ b/src/gui/text/qcssparser.cpp @@ -2175,6 +2175,7 @@ void Parser::init(const QString &css, bool isFile) bool Parser::parse(StyleSheet *styleSheet, Qt::CaseSensitivity nameCaseSensitivity) { if (testTokenAndEndsWith(ATKEYWORD_SYM, QLatin1String("charset"))) { + while (test(S) || test(CDO) || test(CDC)) {} if (!next(STRING)) return false; if (!next(SEMICOLON)) return false; } -- cgit v1.2.3 From e655426e7ac8396713272e123fe0218380e13de1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9rgio=20Martins?= Date: Tue, 15 Nov 2016 13:45:22 +0000 Subject: docs: Reference QLineEdit::hasAcceptableInput() in setValidator() Easy to miss otherwise and hasAcceptableInput() already references setValidator(). Change-Id: Id2d63050db670ab8f7150d7f76492664751cd2da Reviewed-by: Friedemann Kleint --- src/widgets/widgets/qlineedit.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/widgets/widgets/qlineedit.cpp b/src/widgets/widgets/qlineedit.cpp index 2cad5d325c..2069c91664 100644 --- a/src/widgets/widgets/qlineedit.cpp +++ b/src/widgets/widgets/qlineedit.cpp @@ -605,7 +605,7 @@ const QValidator * QLineEdit::validator() const The initial setting is to have no input validator (i.e. any input is accepted up to maxLength()). - \sa validator(), QIntValidator, QDoubleValidator, QRegExpValidator + \sa validator(), hasAcceptableInput(), QIntValidator, QDoubleValidator, QRegExpValidator */ void QLineEdit::setValidator(const QValidator *v) -- cgit v1.2.3 From 8d8991c697d001e3e205ad03533dc0e5ca5dde0b Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Thu, 20 Oct 2016 23:33:02 +0200 Subject: QXbmHandler: don't construct a QByteArray just to find '0x' in text Even QByteArray::fromRawData() allocates memory. Instead of QByteArray::contains() and indexOf(), use good ol' strstr(), like already done elsewhere in the same function. Apart from the memory allocations saved, this fixes a Coverity error complaining that indexOf() can return -1. It's a false positive on the first occurrence, because we didn't call that function unless we know there is a "0x" in the string, but the second _was_ wrong, because we applied it on a new buffer, with unknown content. Coverity-Id: 11262 Change-Id: I18f352c5576e24f89a5c3ef7f2f1b2176f2a235d Reviewed-by: Edward Welbourne --- src/gui/image/qxbmhandler.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/gui/image/qxbmhandler.cpp b/src/gui/image/qxbmhandler.cpp index b21bc75bc4..ada2485363 100644 --- a/src/gui/image/qxbmhandler.cpp +++ b/src/gui/image/qxbmhandler.cpp @@ -118,17 +118,18 @@ static bool read_xbm_body(QIODevice *device, int w, int h, QImage *outImage) qint64 readBytes = 0; + char *p; + // scan for database - for (;;) { + do { if ((readBytes = device->readLine(buf, buflen)) <= 0) { // end of file return false; } buf[readBytes] = '\0'; - if (QByteArray::fromRawData(buf, readBytes).contains("0x")) - break; - } + p = strstr(buf, "0x"); + } while (!p); if (outImage->size() != QSize(w, h) || outImage->format() != QImage::Format_MonoLSB) { *outImage = QImage(w, h, QImage::Format_MonoLSB); @@ -142,7 +143,6 @@ static bool read_xbm_body(QIODevice *device, int w, int h, QImage *outImage) int x = 0, y = 0; uchar *b = outImage->scanLine(0); - char *p = buf + QByteArray::fromRawData(buf, readBytes).indexOf("0x"); w = (w+7)/8; // byte width while (y < h) { // for all encoded bytes... @@ -158,7 +158,7 @@ static bool read_xbm_body(QIODevice *device, int w, int h, QImage *outImage) if ((readBytes = device->readLine(buf,buflen)) <= 0) // EOF ==> truncated image break; buf[readBytes] = '\0'; - p = buf + QByteArray::fromRawData(buf, readBytes).indexOf("0x"); + p = strstr(buf, "0x"); } } -- cgit v1.2.3 From bebbaa43fd21baf0b2235199e84898f18d6cc861 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Fri, 30 Sep 2016 15:51:30 +0200 Subject: Fix warnings in tst_q{table,list}widget MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit GCC warned: tst_qtablewidget.cpp:30: tst_qtablewidget.cpp: In member function ‘void tst_QTableWidget::mimeData()’: qtestcase.h:66:52: warning: suggest parentheses around assignment used as truth value [-Wparentheses] if (!QTest::qVerify(static_cast(statement), #statement, "", __FILE__, __LINE__))\ ^ tst_qtablewidget.cpp:1523:5: note: in expansion of macro ‘QVERIFY’ QVERIFY(data = table.mimeData(tableWidgetItemList)); ^~~~~~~ Fix by adding the extra parentheses, as usual. Change-Id: I2826d7a865b4113b468d5a958ede06e03aa0e278 Reviewed-by: Edward Welbourne Reviewed-by: Marc Mutz --- tests/auto/widgets/itemviews/qlistwidget/tst_qlistwidget.cpp | 8 ++++---- tests/auto/widgets/itemviews/qtablewidget/tst_qtablewidget.cpp | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/tests/auto/widgets/itemviews/qlistwidget/tst_qlistwidget.cpp b/tests/auto/widgets/itemviews/qlistwidget/tst_qlistwidget.cpp index ecf72613da..f526c041f5 100644 --- a/tests/auto/widgets/itemviews/qlistwidget/tst_qlistwidget.cpp +++ b/tests/auto/widgets/itemviews/qlistwidget/tst_qlistwidget.cpp @@ -1688,16 +1688,16 @@ void tst_QListWidget::mimeData() QMimeData *data; - QVERIFY(data = list.mimeData(tableWidgetItemList)); + QVERIFY((data = list.mimeData(tableWidgetItemList))); delete data; - QVERIFY(data = list.model()->mimeData(modelIndexList)); + QVERIFY((data = list.model()->mimeData(modelIndexList))); delete data; - QVERIFY(data = list.model()->mimeData(modelIndexList)); + QVERIFY((data = list.model()->mimeData(modelIndexList))); delete data; - QVERIFY(data = list.mimeData(tableWidgetItemList)); + QVERIFY((data = list.mimeData(tableWidgetItemList))); delete data; // check the saved data is actually the same diff --git a/tests/auto/widgets/itemviews/qtablewidget/tst_qtablewidget.cpp b/tests/auto/widgets/itemviews/qtablewidget/tst_qtablewidget.cpp index ea31fd19dd..ff3cb72832 100644 --- a/tests/auto/widgets/itemviews/qtablewidget/tst_qtablewidget.cpp +++ b/tests/auto/widgets/itemviews/qtablewidget/tst_qtablewidget.cpp @@ -1537,16 +1537,16 @@ void tst_QTableWidget::mimeData() QMimeData *data; - QVERIFY(data = table.mimeData(tableWidgetItemList)); + QVERIFY((data = table.mimeData(tableWidgetItemList))); delete data; - QVERIFY(data = table.model()->mimeData(modelIndexList)); + QVERIFY((data = table.model()->mimeData(modelIndexList))); delete data; - QVERIFY(data = table.model()->mimeData(modelIndexList)); + QVERIFY((data = table.model()->mimeData(modelIndexList))); delete data; - QVERIFY(data = table.mimeData(tableWidgetItemList)); + QVERIFY((data = table.mimeData(tableWidgetItemList))); delete data; // check the saved data is actually the same -- cgit v1.2.3 From bd591064be388216f91d48522b3bdbc1be93bb92 Mon Sep 17 00:00:00 2001 From: Andy Shaw Date: Fri, 21 Oct 2016 17:14:31 +0200 Subject: Use QPersistentModelIndex for storing a model index MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit QModelIndex is not safe to be used to store an index as it is designed to be discarded right after use as the index information can change. Therefore a QPersistentModelIndex should be used instead to store the index. Subsequently the m_index does not need to be updated whenever the model changes anymore as this is already done for us. Task-number: QTBUG-49907 Change-Id: Icc93e410de2821c503ea15a7a1dd9ae32634914e Reviewed-by: Jan Arve Sæther --- src/widgets/accessible/itemviews.cpp | 42 ++++------------------ src/widgets/accessible/itemviews_p.h | 2 +- .../other/qaccessibility/tst_qaccessibility.cpp | 5 ++- 3 files changed, 12 insertions(+), 37 deletions(-) diff --git a/src/widgets/accessible/itemviews.cpp b/src/widgets/accessible/itemviews.cpp index 1b724c9a17..d58db8de32 100644 --- a/src/widgets/accessible/itemviews.cpp +++ b/src/widgets/accessible/itemviews.cpp @@ -550,20 +550,8 @@ void QAccessibleTable::modelChange(QAccessibleTableModelChangeEvent *event) QAccessible::Id id = iter.value(); QAccessibleInterface *iface = QAccessible::accessibleInterface(id); Q_ASSERT(iface); - if (iface->role() == QAccessible::Cell || iface->role() == QAccessible::ListItem) { - Q_ASSERT(iface->tableCellInterface()); - QAccessibleTableCell *cell = static_cast(iface->tableCellInterface()); - if (event->modelChangeType() == QAccessibleTableModelChangeEvent::RowsInserted - && cell->m_index.row() >= event->firstRow()) { - int newRow = cell->m_index.row() + newRows; - cell->m_index = cell->m_index.sibling(newRow, cell->m_index.column()); - } else if (event->modelChangeType() == QAccessibleTableModelChangeEvent::ColumnsInserted - && cell->m_index.column() >= event->firstColumn()) { - int newColumn = cell->m_index.column() + newColumns; - cell->m_index = cell->m_index.sibling(cell->m_index.row(), newColumn); - } - } else if (event->modelChangeType() == QAccessibleTableModelChangeEvent::RowsInserted - && iface->role() == QAccessible::RowHeader) { + if (event->modelChangeType() == QAccessibleTableModelChangeEvent::RowsInserted + && iface->role() == QAccessible::RowHeader) { QAccessibleTableHeaderCell *cell = static_cast(iface); if (cell->index >= event->firstRow()) { cell->index += newRows; @@ -602,27 +590,11 @@ void QAccessibleTable::modelChange(QAccessibleTableModelChangeEvent *event) if (iface->role() == QAccessible::Cell || iface->role() == QAccessible::ListItem) { Q_ASSERT(iface->tableCellInterface()); QAccessibleTableCell *cell = static_cast(iface->tableCellInterface()); - if (event->modelChangeType() == QAccessibleTableModelChangeEvent::RowsRemoved) { - if (cell->m_index.row() < event->firstRow()) { - newCache.insert(indexOfChild(cell), id); - } else if (cell->m_index.row() > event->lastRow()) { - int newRow = cell->m_index.row() - deletedRows; - cell->m_index = cell->m_index.sibling(newRow, cell->m_index.column()); - newCache.insert(indexOfChild(cell), id); - } else { - QAccessible::deleteAccessibleInterface(id); - } - } else if (event->modelChangeType() == QAccessibleTableModelChangeEvent::ColumnsRemoved) { - if (cell->m_index.column() < event->firstColumn()) { - newCache.insert(indexOfChild(cell), id); - } else if (cell->m_index.column() > event->lastColumn()) { - int newColumn = cell->m_index.column() - deletedColumns; - cell->m_index = cell->m_index.sibling(cell->m_index.row(), newColumn); - newCache.insert(indexOfChild(cell), id); - } else { - QAccessible::deleteAccessibleInterface(id); - } - } + // Since it is a QPersistentModelIndex, we only need to check if it is valid + if (cell->m_index.isValid()) + newCache.insert(indexOfChild(cell), id); + else + QAccessible::deleteAccessibleInterface(id); } else if (event->modelChangeType() == QAccessibleTableModelChangeEvent::RowsRemoved && iface->role() == QAccessible::RowHeader) { QAccessibleTableHeaderCell *cell = static_cast(iface); diff --git a/src/widgets/accessible/itemviews_p.h b/src/widgets/accessible/itemviews_p.h index 6a18a1231b..b3cd456585 100644 --- a/src/widgets/accessible/itemviews_p.h +++ b/src/widgets/accessible/itemviews_p.h @@ -207,7 +207,7 @@ private: QHeaderView *verticalHeader() const; QHeaderView *horizontalHeader() const; QPointer view; - QModelIndex m_index; + QPersistentModelIndex m_index; QAccessible::Role m_role; void selectCell(); diff --git a/tests/auto/other/qaccessibility/tst_qaccessibility.cpp b/tests/auto/other/qaccessibility/tst_qaccessibility.cpp index 62c2c0a916..3d78749024 100644 --- a/tests/auto/other/qaccessibility/tst_qaccessibility.cpp +++ b/tests/auto/other/qaccessibility/tst_qaccessibility.cpp @@ -2903,7 +2903,10 @@ void tst_QAccessibility::listTest() QAccessibleInterface *cellMunich3 = table2->cellAt(2,0); QCOMPARE(cell4, cellMunich3); QCOMPARE(axidMunich, QAccessible::uniqueId(cellMunich3)); - + delete listView->takeItem(2); + // list: Oslo, Helsinki + // verify that it doesn't return an invalid item from the cache + QVERIFY(table2->cellAt(2,0) == 0); delete listView; } -- cgit v1.2.3 From 658c8370e4dd74ee82046799b56947bb3c738b92 Mon Sep 17 00:00:00 2001 From: Edward Welbourne Date: Fri, 22 Jan 2016 17:03:48 +0100 Subject: QDateTimeParser: localize variable to avoid shadowing The outer scope it was in had a later clause with its own pos variable. Change-Id: I8d083d3d5935416ef82a78890ed145f02d6d6ded Reviewed-by: Timur Pocheptsov --- src/corelib/tools/qdatetimeparser.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/corelib/tools/qdatetimeparser.cpp b/src/corelib/tools/qdatetimeparser.cpp index 5b7bf0d3d4..bda786aa24 100644 --- a/src/corelib/tools/qdatetimeparser.cpp +++ b/src/corelib/tools/qdatetimeparser.cpp @@ -879,12 +879,12 @@ QDateTimeParser::StateNode QDateTimeParser::parse(QString &input, int &cursorPos State state = Acceptable; QDateTime newCurrentValue; - int pos = 0; bool conflicts = false; const int sectionNodesCount = sectionNodes.size(); QDTPDEBUG << "parse" << input; { + int pos = 0; int year, month, day; currentValue.date().getDate(&year, &month, &day); int year2digits = year % 100; -- cgit v1.2.3 From ac384524c8fa6b19153811e2eaf6dac6b911f930 Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Fri, 14 Oct 2016 14:51:16 +0200 Subject: Speculative fix for tst_QThread::wait2() flakiness This test fails on Windows occasionally with values just short of 800, the lowest observed being 791. It is probably rounding somehow to 10ms segments, so allow it to be up to 10 ms too fast. Change-Id: Ie28e9f61588b68a9060a006f78eedc3a26d05155 Reviewed-by: Friedemann Kleint Reviewed-by: Thiago Macieira Reviewed-by: Simon Hausmann --- tests/auto/corelib/thread/qthread/tst_qthread.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/auto/corelib/thread/qthread/tst_qthread.cpp b/tests/auto/corelib/thread/qthread/tst_qthread.cpp index 3230472d5b..d7294c3ee6 100644 --- a/tests/auto/corelib/thread/qthread/tst_qthread.cpp +++ b/tests/auto/corelib/thread/qthread/tst_qthread.cpp @@ -1082,8 +1082,8 @@ void tst_QThread::wait2() thread.start(); timer.start(); QVERIFY(!thread.wait(Waiting_Thread::WaitTime)); - qint64 elapsed = timer.elapsed(); // On Windows, we sometimes get (WaitTime - 1). - QVERIFY2(elapsed >= Waiting_Thread::WaitTime - 1, qPrintable(QString::fromLatin1("elapsed: %1").arg(elapsed))); + qint64 elapsed = timer.elapsed(); // On Windows, we sometimes get (WaitTime - 9). + QVERIFY2(elapsed >= Waiting_Thread::WaitTime - 10, qPrintable(QString::fromLatin1("elapsed: %1").arg(elapsed))); timer.start(); thread.cond1.wakeOne(); -- cgit v1.2.3 From a56dd0b82855dd91d95159de4b568203a026b66c Mon Sep 17 00:00:00 2001 From: Edward Welbourne Date: Mon, 18 Jan 2016 17:07:56 +0100 Subject: tst_QDateTimeEdit: Use base method, not direct member access A test was directly accessing the .text member of QDateTimeParser (which presently has nothing private). Use the virtual .displayText() method of this base instead, to let the base have some hope of data-hiding (maybe, some day). Change-Id: I8b6e39fba130de56f117bffb2aec346197969c5b Reviewed-by: Timur Pocheptsov --- tests/auto/widgets/widgets/qdatetimeedit/tst_qdatetimeedit.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/auto/widgets/widgets/qdatetimeedit/tst_qdatetimeedit.cpp b/tests/auto/widgets/widgets/qdatetimeedit/tst_qdatetimeedit.cpp index 08a28f3ea0..ee54b16990 100644 --- a/tests/auto/widgets/widgets/qdatetimeedit/tst_qdatetimeedit.cpp +++ b/tests/auto/widgets/widgets/qdatetimeedit/tst_qdatetimeedit.cpp @@ -3749,7 +3749,7 @@ void tst_QDateTimeEdit::dateEditCorrectSectionSize() QTest::keyClick(&edit, keyPair.first, keyPair.second); QDateTimeEditPrivate* edit_d_ptr(static_cast(qt_widget_private(&edit))); - QCOMPARE(edit_d_ptr->text, expectedDisplayString); + QCOMPARE(edit_d_ptr->QDateTimeParser::displayText(), expectedDisplayString); } #endif -- cgit v1.2.3 From 4b1c343e5e8f75b567e88541c1b8ea89a3a5b666 Mon Sep 17 00:00:00 2001 From: Kai Koehne Date: Tue, 15 Nov 2016 15:11:00 +0100 Subject: Doc: Add missing reference to qInfo() Change-Id: I7438aa8ff9fddf2e0155ffe0d442f96d4d9265d4 Reviewed-by: Leena Miettinen --- src/corelib/global/qlogging.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/corelib/global/qlogging.cpp b/src/corelib/global/qlogging.cpp index eb26b6198d..6b95449b3d 100644 --- a/src/corelib/global/qlogging.cpp +++ b/src/corelib/global/qlogging.cpp @@ -1748,7 +1748,7 @@ void qErrnoWarning(int code, const char *msg, ...) \snippet code/src_corelib_global_qglobal.cpp 23 - \sa QtMessageHandler, QtMsgType, qDebug(), qWarning(), qCritical(), qFatal(), + \sa QtMessageHandler, QtMsgType, qDebug(), qInfo(), qWarning(), qCritical(), qFatal(), {Debugging Techniques} */ -- cgit v1.2.3 From 0d2f0164f45cb626c40a7c95026ba00fa56ac249 Mon Sep 17 00:00:00 2001 From: Kai Koehne Date: Tue, 15 Nov 2016 15:12:16 +0100 Subject: Also release winmain, qopenglextensions under commercial licenses Add commercial licenses as an alternative to BSD for code that is statically linked into applications by default. BSD requires attribution even for commercial customers, which is not intended. This is a manual backport of parts of change 71404b0be146 in 5.7, and should be dropped when merging to 5.7. [ChangeLog][License Changes] Static libraries that are linked into executables (winmain and qopenglextensions) are now licensed under BSD _and_ commercial licenses. Change-Id: I0d33bc09c06548d63b11a39027e9bb12c1b9a915 Reviewed-by: Lars Knoll --- header.BSD-NEW | 50 ++++++++++++++++++++++++++++++ src/openglextensions/qopenglextensions.cpp | 14 +++++++-- src/openglextensions/qopenglextensions.h | 14 +++++++-- src/winmain/qtmain_win.cpp | 16 ++++++++-- src/winmain/qtmain_winrt.cpp | 16 ++++++++-- util/glgen/qopenglextensions.cpp.header | 14 +++++++-- util/glgen/qopenglextensions.h.header | 14 +++++++-- 7 files changed, 124 insertions(+), 14 deletions(-) create mode 100644 header.BSD-NEW diff --git a/header.BSD-NEW b/header.BSD-NEW new file mode 100644 index 0000000000..980b021aad --- /dev/null +++ b/header.BSD-NEW @@ -0,0 +1,50 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the FOO module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD-NEW$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of The Qt Company Ltd nor the names of its +** contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + diff --git a/src/openglextensions/qopenglextensions.cpp b/src/openglextensions/qopenglextensions.cpp index 37c5a5d1f0..f35d5b298a 100644 --- a/src/openglextensions/qopenglextensions.cpp +++ b/src/openglextensions/qopenglextensions.cpp @@ -5,8 +5,18 @@ ** ** This file is part of the QtGui module of the Qt Toolkit. ** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: +** $QT_BEGIN_LICENSE:BSD-NEW$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: ** ** "Redistribution and use in source and binary forms, with or without ** modification, are permitted provided that the following conditions are diff --git a/src/openglextensions/qopenglextensions.h b/src/openglextensions/qopenglextensions.h index c9d1ef1267..7ecdee44c0 100644 --- a/src/openglextensions/qopenglextensions.h +++ b/src/openglextensions/qopenglextensions.h @@ -5,8 +5,18 @@ ** ** This file is part of the QtGui module of the Qt Toolkit. ** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: +** $QT_BEGIN_LICENSE:BSD-NEW$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: ** ** "Redistribution and use in source and binary forms, with or without ** modification, are permitted provided that the following conditions are diff --git a/src/winmain/qtmain_win.cpp b/src/winmain/qtmain_win.cpp index 2944e07e00..da3d722aa6 100644 --- a/src/winmain/qtmain_win.cpp +++ b/src/winmain/qtmain_win.cpp @@ -1,12 +1,22 @@ /**************************************************************************** ** -** Copyright (C) 2015 The Qt Company Ltd. +** Copyright (C) 2016 The Qt Company Ltd. ** Contact: http://www.qt.io/licensing/ ** ** This file is part of the Windows main function of the Qt Toolkit. ** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: +** $QT_BEGIN_LICENSE:BSD-NEW$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: ** ** "Redistribution and use in source and binary forms, with or without ** modification, are permitted provided that the following conditions are diff --git a/src/winmain/qtmain_winrt.cpp b/src/winmain/qtmain_winrt.cpp index 81ca07e447..a11efc1b74 100644 --- a/src/winmain/qtmain_winrt.cpp +++ b/src/winmain/qtmain_winrt.cpp @@ -1,12 +1,22 @@ /**************************************************************************** ** -** Copyright (C) 2015 The Qt Company Ltd. +** Copyright (C) 2016 The Qt Company Ltd. ** Contact: http://www.qt.io/licensing/ ** ** This file is part of the Windows main function of the Qt Toolkit. ** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: +** $QT_BEGIN_LICENSE:BSD-NEW$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: ** ** "Redistribution and use in source and binary forms, with or without ** modification, are permitted provided that the following conditions are diff --git a/util/glgen/qopenglextensions.cpp.header b/util/glgen/qopenglextensions.cpp.header index 1127d0bb20..a5ced11ce1 100644 --- a/util/glgen/qopenglextensions.cpp.header +++ b/util/glgen/qopenglextensions.cpp.header @@ -5,8 +5,18 @@ ** ** This file is part of the QtGui module of the Qt Toolkit. ** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: +** $QT_BEGIN_LICENSE:BSD-NEW$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: ** ** "Redistribution and use in source and binary forms, with or without ** modification, are permitted provided that the following conditions are diff --git a/util/glgen/qopenglextensions.h.header b/util/glgen/qopenglextensions.h.header index 8355163dcd..93dcb026d1 100644 --- a/util/glgen/qopenglextensions.h.header +++ b/util/glgen/qopenglextensions.h.header @@ -5,8 +5,18 @@ ** ** This file is part of the QtGui module of the Qt Toolkit. ** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: +** $QT_BEGIN_LICENSE:BSD-NEW$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: ** ** "Redistribution and use in source and binary forms, with or without ** modification, are permitted provided that the following conditions are -- cgit v1.2.3 From f1b4bd4790860e1ff5afcec111a359bc3a91cfda Mon Sep 17 00:00:00 2001 From: Peter Seiderer Date: Tue, 15 Nov 2016 20:09:47 +0100 Subject: eglfs: fix eglfs_mali compile for odroid-mali Avoid duplicated struct fbdev_window definition (introduced by commit 58bed4cda98e8e25db8adc61c7db73b6853077dc) by renaming the local shadow definition to struct shadow_fbdev_window. Task-number: QTBUG-57156 Change-Id: I72b03f09fc57ddcd0284d6d3554a5658e02b80fc Reviewed-by: Laszlo Agocs Reviewed-by: Julien Corjon --- .../eglfs/deviceintegration/eglfs_mali/qeglfsmaliintegration.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_mali/qeglfsmaliintegration.cpp b/src/plugins/platforms/eglfs/deviceintegration/eglfs_mali/qeglfsmaliintegration.cpp index 43decdf849..aeba83f9bf 100644 --- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_mali/qeglfsmaliintegration.cpp +++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_mali/qeglfsmaliintegration.cpp @@ -42,7 +42,7 @@ QT_BEGIN_NAMESPACE -struct fbdev_window { +struct shadow_fbdev_window { unsigned short width; unsigned short height; }; @@ -85,7 +85,7 @@ EGLNativeWindowType QEglFSMaliIntegration::createNativeWindow(QPlatformWindow *w Q_UNUSED(window); Q_UNUSED(format); - fbdev_window *fbwin = reinterpret_cast(malloc(sizeof(fbdev_window))); + shadow_fbdev_window *fbwin = reinterpret_cast(malloc(sizeof(shadow_fbdev_window))); if (NULL == fbwin) return 0; -- cgit v1.2.3 From 3691f7ca0c7117f18ea38ca3950ee9a8a91a53c8 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Fri, 20 Sep 2013 02:38:22 +0200 Subject: QFutureInterface: make accesses to 'state' thread-safe Introduce helper functions switch_{on,off,from_to} to make the code more readable, and prepare everything for later optimizations reducing the sizes of critical sections (by locking the mutex later, or even never). This commit, however, is only concerned with shutting up tsan. In waitForResult(), simplified the code by removing an unneeded if guard: the condition is checked in the while loop immediately following in the then-block, and the local variable declaration that precedes the loop is not worth guarding. Change-Id: I24bfd864ca96f862302536ad8662065e6f366fa8 Reviewed-by: David Faure --- src/corelib/thread/qfutureinterface.cpp | 109 ++++++++++++++++++-------------- src/corelib/thread/qfutureinterface_p.h | 2 +- 2 files changed, 64 insertions(+), 47 deletions(-) diff --git a/src/corelib/thread/qfutureinterface.cpp b/src/corelib/thread/qfutureinterface.cpp index 2fe038165b..a29f8ebba7 100644 --- a/src/corelib/thread/qfutureinterface.cpp +++ b/src/corelib/thread/qfutureinterface.cpp @@ -77,13 +77,33 @@ QFutureInterfaceBase::~QFutureInterfaceBase() delete d; } +static inline int switch_on(QAtomicInt &a, int which) +{ + return a.fetchAndOrRelaxed(which) | which; +} + +static inline int switch_off(QAtomicInt &a, int which) +{ + return a.fetchAndAndRelaxed(~which) & ~which; +} + +static inline int switch_from_to(QAtomicInt &a, int from, int to) +{ + int newValue; + int expected = a.load(); + do { + newValue = (expected & ~from) | to; + } while (!a.testAndSetRelaxed(expected, newValue, expected)); + return newValue; +} + void QFutureInterfaceBase::cancel() { QMutexLocker locker(&d->m_mutex); - if (d->state & Canceled) + if (d->state.load() & Canceled) return; - d->state = State((d->state & ~Paused) | Canceled); + switch_from_to(d->state, Paused, Canceled); d->waitCondition.wakeAll(); d->pausedWaitCondition.wakeAll(); d->sendCallOut(QFutureCallOutEvent(QFutureCallOutEvent::Canceled)); @@ -93,10 +113,10 @@ void QFutureInterfaceBase::setPaused(bool paused) { QMutexLocker locker(&d->m_mutex); if (paused) { - d->state = State(d->state | Paused); + switch_on(d->state, Paused); d->sendCallOut(QFutureCallOutEvent(QFutureCallOutEvent::Paused)); } else { - d->state = State(d->state & ~Paused); + switch_off(d->state, Paused); d->pausedWaitCondition.wakeAll(); d->sendCallOut(QFutureCallOutEvent(QFutureCallOutEvent::Resumed)); } @@ -105,29 +125,24 @@ void QFutureInterfaceBase::setPaused(bool paused) void QFutureInterfaceBase::togglePaused() { QMutexLocker locker(&d->m_mutex); - if (d->state & Paused) { - d->state = State(d->state & ~Paused); + if (d->state.load() & Paused) { + switch_off(d->state, Paused); d->pausedWaitCondition.wakeAll(); d->sendCallOut(QFutureCallOutEvent(QFutureCallOutEvent::Resumed)); } else { - d->state = State(d->state | Paused); + switch_on(d->state, Paused); d->sendCallOut(QFutureCallOutEvent(QFutureCallOutEvent::Paused)); } } void QFutureInterfaceBase::setThrottled(bool enable) { - // bail out if we are not changing the state - if ((enable && (d->state & Throttled)) || (!enable && !(d->state & Throttled))) - return; - - // lock and change the state QMutexLocker lock(&d->m_mutex); if (enable) { - d->state = State(d->state | Throttled); + switch_on(d->state, Throttled); } else { - d->state = State(d->state & ~Throttled); - if (!(d->state & Paused)) + switch_off(d->state, Throttled); + if (!(d->state.load() & Paused)) d->pausedWaitCondition.wakeAll(); } } @@ -178,11 +193,15 @@ bool QFutureInterfaceBase::waitForNextResult() void QFutureInterfaceBase::waitForResume() { // return early if possible to avoid taking the mutex lock. - if ((d->state & Paused) == false || (d->state & Canceled)) - return; + { + const int state = d->state.load(); + if (!(state & Paused) || (state & Canceled)) + return; + } QMutexLocker lock(&d->m_mutex); - if ((d->state & Paused) == false || (d->state & Canceled)) + const int state = d->state.load(); + if (!(state & Paused) || (state & Canceled)) return; // decrease active thread count since this thread will wait. @@ -230,7 +249,7 @@ bool QFutureInterfaceBase::isProgressUpdateNeeded() const void QFutureInterfaceBase::reportStarted() { QMutexLocker locker(&d->m_mutex); - if ((d->state & Started) || (d->state & Canceled) || (d->state & Finished)) + if (d->state.load() & (Started|Canceled|Finished)) return; d->setState(State(Started | Running)); @@ -246,11 +265,11 @@ void QFutureInterfaceBase::reportCanceled() void QFutureInterfaceBase::reportException(const QException &exception) { QMutexLocker locker(&d->m_mutex); - if ((d->state & Canceled) || (d->state & Finished)) + if (d->state.load() & (Canceled|Finished)) return; d->m_exceptionStore.setException(exception); - d->state = State(d->state | Canceled); + switch_on(d->state, Canceled); d->waitCondition.wakeAll(); d->pausedWaitCondition.wakeAll(); d->sendCallOut(QFutureCallOutEvent(QFutureCallOutEvent::Canceled)); @@ -260,8 +279,8 @@ void QFutureInterfaceBase::reportException(const QException &exception) void QFutureInterfaceBase::reportFinished() { QMutexLocker locker(&d->m_mutex); - if (!(d->state & Finished)) { - d->state = State((d->state & ~Running) | Finished); + if (!isFinished()) { + switch_from_to(d->state, Running, Finished); d->waitCondition.wakeAll(); d->sendCallOut(QFutureCallOutEvent(QFutureCallOutEvent::Finished)); } @@ -281,7 +300,7 @@ int QFutureInterfaceBase::expectedResultCount() bool QFutureInterfaceBase::queryState(State state) const { - return (d->state & state); + return d->state.load() & state; } void QFutureInterfaceBase::waitForResult(int resultIndex) @@ -289,7 +308,7 @@ void QFutureInterfaceBase::waitForResult(int resultIndex) d->m_exceptionStore.throwPossibleException(); QMutexLocker lock(&d->m_mutex); - if (!(d->state & Running)) + if (!isRunning()) return; lock.unlock(); @@ -299,11 +318,9 @@ void QFutureInterfaceBase::waitForResult(int resultIndex) lock.relock(); - if (d->state & Running) { - const int waitIndex = (resultIndex == -1) ? INT_MAX : resultIndex; - while ((d->state & Running) && d->internal_isResultReadyAt(waitIndex) == false) - d->waitCondition.wait(&d->m_mutex); - } + const int waitIndex = (resultIndex == -1) ? INT_MAX : resultIndex; + while (isRunning() && !d->internal_isResultReadyAt(waitIndex)) + d->waitCondition.wait(&d->m_mutex); d->m_exceptionStore.throwPossibleException(); } @@ -311,7 +328,7 @@ void QFutureInterfaceBase::waitForResult(int resultIndex) void QFutureInterfaceBase::waitForFinished() { QMutexLocker lock(&d->m_mutex); - const bool alreadyFinished = !(d->state & Running); + const bool alreadyFinished = !isRunning(); lock.unlock(); if (!alreadyFinished) { @@ -319,7 +336,7 @@ void QFutureInterfaceBase::waitForFinished() lock.relock(); - while (d->state & Running) + while (isRunning()) d->waitCondition.wait(&d->m_mutex); } @@ -328,7 +345,7 @@ void QFutureInterfaceBase::waitForFinished() void QFutureInterfaceBase::reportResultsReady(int beginIndex, int endIndex) { - if ((d->state & Canceled) || (d->state & Finished) || beginIndex == endIndex) + if (beginIndex == endIndex || (d->state.load() & (Canceled|Finished))) return; d->waitCondition.wakeAll(); @@ -390,7 +407,7 @@ void QFutureInterfaceBase::setProgressValueAndText(int progressValue, if (d->m_progressValue >= progressValue) return; - if ((d->state & Canceled) || (d->state & Finished)) + if (d->state.load() & (Canceled|Finished)) return; if (d->internal_updateProgress(progressValue, progressText)) { @@ -462,10 +479,10 @@ bool QFutureInterfaceBasePrivate::internal_waitForNextResult() if (m_results.hasNextResult()) return true; - while ((state & QFutureInterfaceBase::Running) && m_results.hasNextResult() == false) + while ((state.load() & QFutureInterfaceBase::Running) && m_results.hasNextResult() == false) waitCondition.wait(&m_mutex); - return (!(state & QFutureInterfaceBase::Canceled) && m_results.hasNextResult()); + return !(state.load() & QFutureInterfaceBase::Canceled) && m_results.hasNextResult(); } bool QFutureInterfaceBasePrivate::internal_updateProgress(int progress, @@ -488,16 +505,16 @@ bool QFutureInterfaceBasePrivate::internal_updateProgress(int progress, void QFutureInterfaceBasePrivate::internal_setThrottled(bool enable) { // bail out if we are not changing the state - if ((enable && (state & QFutureInterfaceBase::Throttled)) - || (!enable && !(state & QFutureInterfaceBase::Throttled))) + if ((enable && (state.load() & QFutureInterfaceBase::Throttled)) + || (!enable && !(state.load() & QFutureInterfaceBase::Throttled))) return; // change the state if (enable) { - state = QFutureInterfaceBase::State(state | QFutureInterfaceBase::Throttled); + switch_on(state, QFutureInterfaceBase::Throttled); } else { - state = QFutureInterfaceBase::State(state & ~QFutureInterfaceBase::Throttled); - if (!(state & QFutureInterfaceBase::Paused)) + switch_off(state, QFutureInterfaceBase::Throttled); + if (!(state.load() & QFutureInterfaceBase::Paused)) pausedWaitCondition.wakeAll(); } } @@ -532,7 +549,7 @@ void QFutureInterfaceBasePrivate::connectOutputInterface(QFutureCallOutInterface { QMutexLocker locker(&m_mutex); - if (state & QFutureInterfaceBase::Started) { + if (state.load() & QFutureInterfaceBase::Started) { interface->postCallOutEvent(QFutureCallOutEvent(QFutureCallOutEvent::Started)); interface->postCallOutEvent(QFutureCallOutEvent(QFutureCallOutEvent::ProgressRange, m_progressMinimum, @@ -552,13 +569,13 @@ void QFutureInterfaceBasePrivate::connectOutputInterface(QFutureCallOutInterface it.batchedAdvance(); } - if (state & QFutureInterfaceBase::Paused) + if (state.load() & QFutureInterfaceBase::Paused) interface->postCallOutEvent(QFutureCallOutEvent(QFutureCallOutEvent::Paused)); - if (state & QFutureInterfaceBase::Canceled) + if (state.load() & QFutureInterfaceBase::Canceled) interface->postCallOutEvent(QFutureCallOutEvent(QFutureCallOutEvent::Canceled)); - if (state & QFutureInterfaceBase::Finished) + if (state.load() & QFutureInterfaceBase::Finished) interface->postCallOutEvent(QFutureCallOutEvent(QFutureCallOutEvent::Finished)); outputConnections.append(interface); @@ -577,7 +594,7 @@ void QFutureInterfaceBasePrivate::disconnectOutputInterface(QFutureCallOutInterf void QFutureInterfaceBasePrivate::setState(QFutureInterfaceBase::State newState) { - state = newState; + state.store(newState); } QT_END_NAMESPACE diff --git a/src/corelib/thread/qfutureinterface_p.h b/src/corelib/thread/qfutureinterface_p.h index e2d588cd07..eb0c38421b 100644 --- a/src/corelib/thread/qfutureinterface_p.h +++ b/src/corelib/thread/qfutureinterface_p.h @@ -155,7 +155,7 @@ public: int m_progressValue; // TQ int m_progressMinimum; // TQ int m_progressMaximum; // TQ - QFutureInterfaceBase::State state; + QAtomicInt state; // reads and writes can happen unprotected, both must be atomic QElapsedTimer progressTime; QWaitCondition pausedWaitCondition; QtPrivate::ResultStoreBase m_results; -- cgit v1.2.3 From e798d0b18acfb6756a614aec3e7b4bcb1ef5ff58 Mon Sep 17 00:00:00 2001 From: Timur Pocheptsov Date: Mon, 21 Nov 2016 12:55:54 +0100 Subject: qnativesocketengine_winrt - do not shadow a variable We first hide identifier 'hr' and then later we check the one that was never correctly initialized. Task-number: QTBUG-57226 Change-Id: Ibbf1bb99aa752c2e4090caf4533dc5f5b71b5e41 Reviewed-by: Oliver Wolff --- src/network/socket/qnativesocketengine_winrt.cpp | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/network/socket/qnativesocketengine_winrt.cpp b/src/network/socket/qnativesocketengine_winrt.cpp index 32fafc2cb0..934c8fe785 100644 --- a/src/network/socket/qnativesocketengine_winrt.cpp +++ b/src/network/socket/qnativesocketengine_winrt.cpp @@ -252,19 +252,18 @@ bool QNativeSocketEngine::initialize(qintptr socketDescriptor, QAbstractSocket:: // Start processing incoming data if (d->socketType == QAbstractSocket::TcpSocket) { - HRESULT hr; - QEventDispatcherWinRT::runOnXamlThread([d, &hr, socket, this]() { + HRESULT hr = QEventDispatcherWinRT::runOnXamlThread([d, socket, this]() { ComPtr buffer; HRESULT hr = g->bufferFactory->Create(READ_BUFFER_SIZE, &buffer); - RETURN_OK_IF_FAILED("initialize(): Could not create buffer"); + RETURN_HR_IF_FAILED("initialize(): Could not create buffer"); ComPtr stream; hr = socket->get_InputStream(&stream); - RETURN_OK_IF_FAILED("initialize(): Could not obtain input stream"); + RETURN_HR_IF_FAILED("initialize(): Could not obtain input stream"); hr = stream->ReadAsync(buffer.Get(), READ_BUFFER_SIZE, InputStreamOptions_Partial, d->readOp.GetAddressOf()); - RETURN_OK_IF_FAILED_WITH_ARGS("initialize(): Failed to read from the socket buffer (%s).", + RETURN_HR_IF_FAILED_WITH_ARGS("initialize(): Failed to read from the socket buffer (%s).", socketDescription(this).constData()); hr = d->readOp->put_Completed(Callback(d, &QNativeSocketEnginePrivate::handleReadyRead).Get()); - RETURN_OK_IF_FAILED_WITH_ARGS("initialize(): Failed to set socket read callback (%s).", + RETURN_HR_IF_FAILED_WITH_ARGS("initialize(): Failed to set socket read callback (%s).", socketDescription(this).constData()); return S_OK; }); -- cgit v1.2.3 From ad788c1014ea7a84f4ad9c52f50b957074cb3e38 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Fri, 18 Nov 2016 12:39:36 +0100 Subject: tst_qstandardpaths: Disable WOW64 redirection on Windows The logo (microsoft.windows.softwarelogo.showdesktop.exe) is otherwise not found. Change-Id: Ic52329462612a027e2928922a1f9a541dcbc67a3 Reviewed-by: Jesus Fernandez Reviewed-by: Oliver Wolff --- .../auto/corelib/io/qstandardpaths/tst_qstandardpaths.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/tests/auto/corelib/io/qstandardpaths/tst_qstandardpaths.cpp b/tests/auto/corelib/io/qstandardpaths/tst_qstandardpaths.cpp index e1c277717d..92e66e20c2 100644 --- a/tests/auto/corelib/io/qstandardpaths/tst_qstandardpaths.cpp +++ b/tests/auto/corelib/io/qstandardpaths/tst_qstandardpaths.cpp @@ -38,6 +38,9 @@ #include #include #include +#if defined(Q_OS_WIN) && !defined(Q_OS_WINRT) && !defined(Q_OS_WINCE) +# include +#endif #ifdef Q_OS_UNIX #include @@ -131,6 +134,16 @@ static const char * const enumNames[MaxStandardLocation + 1 - int(QStandardPaths void tst_qstandardpaths::initTestCase() { +#if defined(Q_OS_WIN) && !defined(Q_OS_WINRT) && !defined(Q_OS_WINCE) + // Disable WOW64 redirection, see testFindExecutable() + if (QSysInfo::buildCpuArchitecture() != QSysInfo::currentCpuArchitecture()) { + void *oldMode; + const bool disabledDisableWow64FsRedirection = Wow64DisableWow64FsRedirection(&oldMode) == TRUE; + if (!disabledDisableWow64FsRedirection) + qErrnoWarning("Wow64DisableWow64FsRedirection() failed"); + QVERIFY(disabledDisableWow64FsRedirection); + } +#endif // Q_OS_WIN && !Q_OS_WINRT && !Q_OS_WINCE QVERIFY2(m_localConfigTempDir.isValid(), qPrintable(m_localConfigTempDir.errorString())); QVERIFY2(m_globalConfigTempDir.isValid(), qPrintable(m_globalConfigTempDir.errorString())); QVERIFY2(m_localAppTempDir.isValid(), qPrintable(m_localAppTempDir.errorString())); @@ -380,6 +393,7 @@ void tst_qstandardpaths::testFindExecutable_data() if (QSysInfo::windowsVersion() >= QSysInfo::WV_WINDOWS8) { // The logo executable on Windows 8 is perfectly suited for testing that the // suffix mechanism is not thrown off by dots in the name. + // Note: Requires disabling WOW64 redirection, see initTestCase() const QString logo = QLatin1String("microsoft.windows.softwarelogo.showdesktop"); const QString logoPath = cmdFi.absolutePath() + QLatin1Char('/') + logo + QLatin1String(".exe"); QTest::newRow("win8-logo") -- cgit v1.2.3 From 4bf5a3c885c26150317e83555c0c3213bd7b417e Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Wed, 28 Sep 2016 00:12:36 +0200 Subject: tst_QFormLayout: Fix UB (invalid enum value) in several functions The code coerced a -123 into a QFormLayout::ItemFlags, which, however, being an enum with enumeration values 0..2, only has valid numerical values 0..3. Fix by using 3 as the value to represent the invalid enum value, and store this in a constant so as not to distribute this magic number all around the test class. Change-Id: Ie5e93a69ef5a3acdde43030b022e0cce8aec484d Reviewed-by: Thiago Macieira Reviewed-by: Marc Mutz --- .../widgets/kernel/qformlayout/tst_qformlayout.cpp | 42 ++++++++++++---------- 1 file changed, 24 insertions(+), 18 deletions(-) diff --git a/tests/auto/widgets/kernel/qformlayout/tst_qformlayout.cpp b/tests/auto/widgets/kernel/qformlayout/tst_qformlayout.cpp index 5703d7e114..5b87c0114d 100644 --- a/tests/auto/widgets/kernel/qformlayout/tst_qformlayout.cpp +++ b/tests/auto/widgets/kernel/qformlayout/tst_qformlayout.cpp @@ -48,6 +48,10 @@ #include +// ItemRole has enumerators for numerical values 0..2, thus the only +// valid numerical values for storing into an ItemRole variable are 0..3: +Q_CONSTEXPR QFormLayout::ItemRole invalidRole = QFormLayout::ItemRole(3); + static inline void setFrameless(QWidget *w) { Qt::WindowFlags flags = w->windowFlags(); @@ -528,7 +532,7 @@ void tst_QFormLayout::insertRow_QWidget_QWidget() { int row = -1; - QFormLayout::ItemRole role = QFormLayout::ItemRole(-123); + QFormLayout::ItemRole role = invalidRole; layout->getWidgetPosition(lbl1, &row, &role); QCOMPARE(row, 0); QCOMPARE(int(role), int(QFormLayout::LabelRole)); @@ -536,7 +540,7 @@ void tst_QFormLayout::insertRow_QWidget_QWidget() { int row = -1; - QFormLayout::ItemRole role = QFormLayout::ItemRole(-123); + QFormLayout::ItemRole role = invalidRole; layout->getWidgetPosition(fld1, &row, &role); QCOMPARE(row, 0); QCOMPARE(int(role), int(QFormLayout::FieldRole)); @@ -597,7 +601,7 @@ void tst_QFormLayout::insertRow_QWidget_QLayout() { int row = -1; - QFormLayout::ItemRole role = QFormLayout::ItemRole(-123); + QFormLayout::ItemRole role = invalidRole; layout->getWidgetPosition(lbl1, &row, &role); QCOMPARE(row, 0); QCOMPARE(int(role), int(QFormLayout::LabelRole)); @@ -605,7 +609,7 @@ void tst_QFormLayout::insertRow_QWidget_QLayout() { int row = -1; - QFormLayout::ItemRole role = QFormLayout::ItemRole(-123); + QFormLayout::ItemRole role = invalidRole; layout->getLayoutPosition(fld1, &row, &role); QCOMPARE(row, 0); QCOMPARE(int(role), int(QFormLayout::FieldRole)); @@ -722,7 +726,7 @@ void tst_QFormLayout::setWidget() { int row = -1; - QFormLayout::ItemRole role = QFormLayout::ItemRole(-123); + QFormLayout::ItemRole role = invalidRole; layout.getWidgetPosition(&w1, &row, &role); QCOMPARE(row, 5); QCOMPARE(int(role), int(QFormLayout::LabelRole)); @@ -730,7 +734,7 @@ void tst_QFormLayout::setWidget() { int row = -1; - QFormLayout::ItemRole role = QFormLayout::ItemRole(-123); + QFormLayout::ItemRole role = invalidRole; layout.getWidgetPosition(&w2, &row, &role); QCOMPARE(row, 3); QCOMPARE(int(role), int(QFormLayout::FieldRole)); @@ -738,7 +742,7 @@ void tst_QFormLayout::setWidget() { int row = -1; - QFormLayout::ItemRole role = QFormLayout::ItemRole(-123); + QFormLayout::ItemRole role = invalidRole; layout.getWidgetPosition(&w3, &row, &role); QCOMPARE(row, 3); QCOMPARE(int(role), int(QFormLayout::LabelRole)); @@ -746,18 +750,20 @@ void tst_QFormLayout::setWidget() { int row = -1; - QFormLayout::ItemRole role = QFormLayout::ItemRole(-123); + QFormLayout::ItemRole role = invalidRole; layout.getWidgetPosition(&w4, &row, &role); + // not found QCOMPARE(row, -1); - QCOMPARE(int(role), -123); + QCOMPARE(int(role), int(invalidRole)); } { int row = -1; - QFormLayout::ItemRole role = QFormLayout::ItemRole(-123); + QFormLayout::ItemRole role = invalidRole; layout.getWidgetPosition(0, &row, &role); + // not found QCOMPARE(row, -1); - QCOMPARE(int(role), -123); + QCOMPARE(int(role), int(invalidRole)); } } @@ -790,7 +796,7 @@ void tst_QFormLayout::setLayout() { int row = -1; - QFormLayout::ItemRole role = QFormLayout::ItemRole(-123); + QFormLayout::ItemRole role = invalidRole; layout.getLayoutPosition(&l1, &row, &role); QCOMPARE(row, 5); QCOMPARE(int(role), int(QFormLayout::LabelRole)); @@ -798,7 +804,7 @@ void tst_QFormLayout::setLayout() { int row = -1; - QFormLayout::ItemRole role = QFormLayout::ItemRole(-123); + QFormLayout::ItemRole role = invalidRole; layout.getLayoutPosition(&l2, &row, &role); QCOMPARE(row, 3); QCOMPARE(int(role), int(QFormLayout::FieldRole)); @@ -806,7 +812,7 @@ void tst_QFormLayout::setLayout() { int row = -1; - QFormLayout::ItemRole role = QFormLayout::ItemRole(-123); + QFormLayout::ItemRole role = invalidRole; layout.getLayoutPosition(&l3, &row, &role); QCOMPARE(row, 3); QCOMPARE(int(role), int(QFormLayout::LabelRole)); @@ -814,18 +820,18 @@ void tst_QFormLayout::setLayout() { int row = -1; - QFormLayout::ItemRole role = QFormLayout::ItemRole(-123); + QFormLayout::ItemRole role = invalidRole; layout.getLayoutPosition(&l4, &row, &role); QCOMPARE(row, -1); - QCOMPARE(int(role), -123); + QCOMPARE(int(role), int(invalidRole)); } { int row = -1; - QFormLayout::ItemRole role = QFormLayout::ItemRole(-123); + QFormLayout::ItemRole role = invalidRole; layout.getLayoutPosition(0, &row, &role); QCOMPARE(row, -1); - QCOMPARE(int(role), -123); + QCOMPARE(int(role), int(invalidRole)); } } -- cgit v1.2.3 From 0a203faa7f0bb836afbdd3addfba99190f69ff5f Mon Sep 17 00:00:00 2001 From: Vyacheslav Koscheev Date: Mon, 21 Nov 2016 13:17:47 +0700 Subject: Adjust comment to "new" spec name Change-Id: I58250de09f10637b145a5f43c3764a86e47bce96 Reviewed-by: Oswald Buddenhagen --- mkspecs/android-clang/qmake.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mkspecs/android-clang/qmake.conf b/mkspecs/android-clang/qmake.conf index b25a4399f3..c33bbe7eed 100644 --- a/mkspecs/android-clang/qmake.conf +++ b/mkspecs/android-clang/qmake.conf @@ -1,4 +1,4 @@ -# qmake configuration for building with android-g++ +# qmake configuration for building with android-clang MAKEFILE_GENERATOR = UNIX QMAKE_PLATFORM = android QMAKE_COMPILER = gcc clang llvm -- cgit v1.2.3 From 38675e18fcc841228141568a2ecfafdeb99eba2a Mon Sep 17 00:00:00 2001 From: Oliver Wolff Date: Thu, 17 Nov 2016 10:40:44 +0100 Subject: Add support for Visual Studio 2017 Tested with RC Task-number: QTBUG-57086 Change-Id: I21f56edca3852b52edd2c5fdcce76817141e8d4a Reviewed-by: Friedemann Kleint --- mkspecs/win32-msvc2017/qmake.conf | 10 +++++++++ mkspecs/win32-msvc2017/qplatformdefs.h | 34 +++++++++++++++++++++++++++++++ qmake/Makefile.win32 | 2 +- qmake/generators/win32/msvc_objectmodel.h | 3 ++- qmake/generators/win32/msvc_vcproj.cpp | 11 ++++++++++ qmake/library/qmakeevaluator.cpp | 13 +++++++++++- src/corelib/global/qlibraryinfo.cpp | 4 +++- tools/configure/configureapp.cpp | 3 ++- tools/configure/environment.cpp | 6 ++++++ tools/configure/environment.h | 3 ++- 10 files changed, 83 insertions(+), 6 deletions(-) create mode 100644 mkspecs/win32-msvc2017/qmake.conf create mode 100644 mkspecs/win32-msvc2017/qplatformdefs.h diff --git a/mkspecs/win32-msvc2017/qmake.conf b/mkspecs/win32-msvc2017/qmake.conf new file mode 100644 index 0000000000..b8351eb3fe --- /dev/null +++ b/mkspecs/win32-msvc2017/qmake.conf @@ -0,0 +1,10 @@ +# +# qmake configuration for win32-msvc2017 +# +# Written for Microsoft Visual C++ 2017 +# + +MSC_VER = 1910 +MSVC_VER = 15.0 +include(../common/msvc-desktop.conf) +load(qt_config) diff --git a/mkspecs/win32-msvc2017/qplatformdefs.h b/mkspecs/win32-msvc2017/qplatformdefs.h new file mode 100644 index 0000000000..7100e3aa41 --- /dev/null +++ b/mkspecs/win32-msvc2017/qplatformdefs.h @@ -0,0 +1,34 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the qmake spec of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL21$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** 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 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** As a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "../win32-msvc2005/qplatformdefs.h" diff --git a/qmake/Makefile.win32 b/qmake/Makefile.win32 index e61e9503f3..96d9cb62cf 100644 --- a/qmake/Makefile.win32 +++ b/qmake/Makefile.win32 @@ -21,7 +21,7 @@ LINKER = link CFLAGS_EXTRA = /Zc:wchar_t- ! elseif "$(QMAKESPEC)" == "win32-msvc2008" || "$(QMAKESPEC)" == "win32-msvc2010" || "$(QMAKESPEC)" == "win32-msvc2012" || "$(QMAKESPEC)" == "win32-msvc2013" CFLAGS_EXTRA = /MP /D_CRT_SECURE_NO_WARNINGS /D_SCL_SECURE_NO_WARNINGS $(CFLAGS_CRT) -! elseif "$(QMAKESPEC)" == "win32-msvc2015" +! elseif "$(QMAKESPEC)" == "win32-msvc2015" || "$(QMAKESPEC)" == "win32-msvc2017" CFLAGS_EXTRA = /MP /D_CRT_SECURE_NO_WARNINGS /D_SCL_SECURE_NO_WARNINGS /Zc:strictStrings /w44456 /w44457 /w44458 /wd4577 $(CFLAGS_CRT) ! else ! error Unsupported compiler for this Makefile diff --git a/qmake/generators/win32/msvc_objectmodel.h b/qmake/generators/win32/msvc_objectmodel.h index 96923ba23d..7f924a9a2b 100644 --- a/qmake/generators/win32/msvc_objectmodel.h +++ b/qmake/generators/win32/msvc_objectmodel.h @@ -57,7 +57,8 @@ enum DotNET { NET2010 = 0xa0, NET2012 = 0xb0, NET2013 = 0xc0, - NET2015 = 0xd0 + NET2015 = 0xd0, + NET2017 = 0xe0 }; /* diff --git a/qmake/generators/win32/msvc_vcproj.cpp b/qmake/generators/win32/msvc_vcproj.cpp index 5e3e11fd5c..d4930d9a05 100644 --- a/qmake/generators/win32/msvc_vcproj.cpp +++ b/qmake/generators/win32/msvc_vcproj.cpp @@ -70,6 +70,7 @@ struct DotNetCombo { const char *versionStr; const char *regKey; } dotNetCombo[] = { + {NET2017, "MSVC.NET 2017 (15.0)", "Software\\Microsoft\\VisualStudio\\SxS\\VS7\\15.0"}, {NET2015, "MSVC.NET 2015 (14.0)", "Software\\Microsoft\\VisualStudio\\14.0\\Setup\\VC\\ProductDir"}, {NET2013, "MSVC.NET 2013 (12.0)", "Software\\Microsoft\\VisualStudio\\12.0\\Setup\\VC\\ProductDir"}, {NET2013, "MSVC.NET 2013 Express Edition (12.0)", "Software\\Microsoft\\VCExpress\\12.0\\Setup\\VC\\ProductDir"}, @@ -164,6 +165,8 @@ const char _slnHeader120[] = "Microsoft Visual Studio Solution File, Format "\n# Visual Studio 2013"; const char _slnHeader140[] = "Microsoft Visual Studio Solution File, Format Version 12.00" "\n# Visual Studio 2015"; +const char _slnHeader141[] = "Microsoft Visual Studio Solution File, Format Version 12.00" + "\n# Visual Studio 2017"; // The following UUID _may_ change for later servicepacks... // If so we need to search through the registry at // HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\7.0\Projects @@ -394,6 +397,8 @@ QString VcprojGenerator::retrievePlatformToolSet() const return QStringLiteral("v120") + suffix; case NET2015: return QStringLiteral("v140") + suffix; + case NET2017: + return QStringLiteral("v141") + suffix; default: return QString(); } @@ -620,6 +625,9 @@ void VcprojGenerator::writeSubDirs(QTextStream &t) } switch (which_dotnet_version(project->first("MSVC_VER").toLatin1())) { + case NET2017: + t << _slnHeader141; + break; case NET2015: t << _slnHeader140; break; @@ -954,6 +962,9 @@ void VcprojGenerator::initProject() // Own elements ----------------------------- vcProject.Name = project->first("QMAKE_ORIG_TARGET").toQString(); switch (which_dotnet_version(project->first("MSVC_VER").toLatin1())) { + case NET2017: + vcProject.Version = "15.00"; + break; case NET2015: vcProject.Version = "14.00"; break; diff --git a/qmake/library/qmakeevaluator.cpp b/qmake/library/qmakeevaluator.cpp index cd5676093d..4083fc5291 100644 --- a/qmake/library/qmakeevaluator.cpp +++ b/qmake/library/qmakeevaluator.cpp @@ -973,6 +973,13 @@ static ProString msvcBinDirToQMakeArch(QString subdir) subdir = subdir.toLower(); if (subdir == QLatin1String("amd64")) return ProString("x86_64"); + // Since 2017 the folder structure from here is HostX64|X86/x64|x86 + idx = subdir.indexOf(QLatin1Char('\\')); + if (idx == -1) + return ProString("x86"); + subdir.remove(0, idx + 1); + if (subdir == QLatin1String("x64")) + return ProString("x86_64"); return ProString(subdir); } @@ -1064,8 +1071,12 @@ void QMakeEvaluator::loadDefaults() vars[ProKey("QMAKE_HOST.arch")] << archStr; # if defined(Q_CC_MSVC) // ### bogus condition, but nobody x-builds for msvc with a different qmake + // Since VS 2017 we need VCToolsInstallDir instead of VCINSTALLDIR + QString vcInstallDir = m_option->getEnv(QLatin1String("VCToolsInstallDir")); + if (vcInstallDir.isEmpty()) + vcInstallDir = m_option->getEnv(QLatin1String("VCINSTALLDIR")); vars[ProKey("QMAKE_TARGET.arch")] = msvcArchitecture( - m_option->getEnv(QLatin1String("VCINSTALLDIR")), + vcInstallDir, m_option->getEnv(QLatin1String("PATH"))); # endif #elif defined(Q_OS_UNIX) diff --git a/src/corelib/global/qlibraryinfo.cpp b/src/corelib/global/qlibraryinfo.cpp index 8bcacca13f..14be4c3475 100644 --- a/src/corelib/global/qlibraryinfo.cpp +++ b/src/corelib/global/qlibraryinfo.cpp @@ -310,8 +310,10 @@ QLibraryInfo::buildDate() # define COMPILER_STRING "MSVC 2012" # elif _MSC_VER < 1900 # define COMPILER_STRING "MSVC 2013" -# elif _MSC_VER < 2000 +# elif _MSC_VER < 1910 # define COMPILER_STRING "MSVC 2015" +# elif _MSC_VER < 2000 +# define COMPILER_STRING "MSVC 2017" # else # define COMPILER_STRING "MSVC _MSC_VER " QT_STRINGIFY(_MSC_VER) # endif diff --git a/tools/configure/configureapp.cpp b/tools/configure/configureapp.cpp index 88dcd8170b..a908db0707 100644 --- a/tools/configure/configureapp.cpp +++ b/tools/configure/configureapp.cpp @@ -1458,7 +1458,8 @@ void Configure::parseCmdLine() dictionary[ "QMAKESPEC" ].endsWith("-msvc2010") || dictionary[ "QMAKESPEC" ].endsWith("-msvc2012") || dictionary[ "QMAKESPEC" ].endsWith("-msvc2013") || - dictionary[ "QMAKESPEC" ].endsWith("-msvc2015")) { + dictionary[ "QMAKESPEC" ].endsWith("-msvc2015") || + dictionary[ "QMAKESPEC" ].endsWith("-msvc2017")) { if (dictionary[ "MAKE" ].isEmpty()) dictionary[ "MAKE" ] = "nmake"; dictionary[ "QMAKEMAKEFILE" ] = "Makefile.win32"; } else if (dictionary[ "QMAKESPEC" ] == QString("win32-g++")) { diff --git a/tools/configure/environment.cpp b/tools/configure/environment.cpp index 153a141d7a..f950945597 100644 --- a/tools/configure/environment.cpp +++ b/tools/configure/environment.cpp @@ -76,6 +76,7 @@ struct CompilerInfo{ {CC_MSVC2013, "Microsoft (R) Visual Studio 2013 C/C++ Compiler (12.0)", "Software\\Microsoft\\VisualStudio\\SxS\\VC7\\12.0", "cl.exe"}, // link.exe, lib.exe // Microsoft skipped version 13 {CC_MSVC2015, "Microsoft (R) Visual Studio 2015 C/C++ Compiler (14.0)", "Software\\Microsoft\\VisualStudio\\SxS\\VS7\\14.0", "cl.exe"}, // link.exe, lib.exe + {CC_MSVC2017, "Microsoft (R) Visual Studio 2017 C/C++ Compiler (15.0)", "Software\\Microsoft\\VisualStudio\\SxS\\VS7\\15.0", "cl.exe"}, // link.exe, lib.exe {CC_UNKNOWN, "Unknown", 0, 0}, }; @@ -101,6 +102,9 @@ QString Environment::detectQMakeSpec() { QString spec; switch (detectCompiler()) { + case CC_MSVC2017: + spec = "win32-msvc2017"; + break; case CC_MSVC2015: spec = "win32-msvc2015"; break; @@ -137,6 +141,8 @@ QString Environment::detectQMakeSpec() Compiler Environment::compilerFromQMakeSpec(const QString &qmakeSpec) { + if (qmakeSpec == QLatin1String("win32-msvc2017")) + return CC_MSVC2017; if (qmakeSpec == QLatin1String("win32-msvc2015")) return CC_MSVC2015; if (qmakeSpec == QLatin1String("win32-msvc2013")) diff --git a/tools/configure/environment.h b/tools/configure/environment.h index d096782e70..6b0e9bb9fe 100644 --- a/tools/configure/environment.h +++ b/tools/configure/environment.h @@ -46,7 +46,8 @@ enum Compiler { CC_MSVC2010 = 0xA0, CC_MSVC2012 = 0xB0, CC_MSVC2013 = 0xC0, - CC_MSVC2015 = 0xD0 + CC_MSVC2015 = 0xD0, + CC_MSVC2017 = 0xE0 }; struct CompilerInfo; -- cgit v1.2.3 From 9f17c245893e296d5c92ed1ef1e5d08896b469b1 Mon Sep 17 00:00:00 2001 From: Oliver Wolff Date: Thu, 17 Nov 2016 10:40:44 +0100 Subject: Enable constexpr support for Visual Studio 2017 Change-Id: I894789c41cc2c1a327c14d0526e658520d096085 Reviewed-by: Friedemann Kleint Reviewed-by: Thiago Macieira --- src/corelib/global/qcompilerdetection.h | 3 +++ src/corelib/thread/qbasicatomic.h | 5 +++++ 2 files changed, 8 insertions(+) diff --git a/src/corelib/global/qcompilerdetection.h b/src/corelib/global/qcompilerdetection.h index e324c043af..25e6e4c6bf 100644 --- a/src/corelib/global/qcompilerdetection.h +++ b/src/corelib/global/qcompilerdetection.h @@ -931,6 +931,9 @@ # define Q_COMPILER_THREADSAFE_STATICS # define Q_COMPILER_UNIFORM_INIT # endif +# if _MSC_VER >= 1910 +# define Q_COMPILER_CONSTEXPR +# endif # endif /* __cplusplus */ #endif /* Q_CC_MSVC */ diff --git a/src/corelib/thread/qbasicatomic.h b/src/corelib/thread/qbasicatomic.h index 7960174277..c1e01a3212 100644 --- a/src/corelib/thread/qbasicatomic.h +++ b/src/corelib/thread/qbasicatomic.h @@ -78,6 +78,9 @@ # error "Qt has not been ported to this platform" #endif +QT_WARNING_PUSH +QT_WARNING_DISABLE_MSVC(4522) + QT_BEGIN_NAMESPACE #if 0 @@ -340,4 +343,6 @@ public: QT_END_NAMESPACE +QT_WARNING_POP + #endif // QBASICATOMIC_H -- cgit v1.2.3 From 3cd457bdad6eee4a703ef9773b80165a272fbdc7 Mon Sep 17 00:00:00 2001 From: Andy Shaw Date: Mon, 21 Nov 2016 11:38:43 +0100 Subject: Handle RemovePath correctly when calling matches() Change-Id: Ied324a537df127e676fad26b42e658a9d5aeec9b Reviewed-by: David Faure --- src/corelib/io/qurl.cpp | 3 ++ tests/auto/corelib/io/qurl/tst_qurl.cpp | 50 +++++++++++++++++++++++++++++++++ 2 files changed, 53 insertions(+) diff --git a/src/corelib/io/qurl.cpp b/src/corelib/io/qurl.cpp index 7512bcd83f..de78d09dd9 100644 --- a/src/corelib/io/qurl.cpp +++ b/src/corelib/io/qurl.cpp @@ -3703,6 +3703,9 @@ bool QUrl::matches(const QUrl &url, FormattingOptions options) const if ((d->sectionIsPresent & mask) != (url.d->sectionIsPresent & mask)) return false; + if (options & QUrl::RemovePath) + return true; + // Compare paths, after applying path-related options QString path1; d->appendPath(path1, options, QUrlPrivate::Path); diff --git a/tests/auto/corelib/io/qurl/tst_qurl.cpp b/tests/auto/corelib/io/qurl/tst_qurl.cpp index 8f99047df3..670b72acc8 100644 --- a/tests/auto/corelib/io/qurl/tst_qurl.cpp +++ b/tests/auto/corelib/io/qurl/tst_qurl.cpp @@ -182,6 +182,8 @@ private slots: void streaming(); void detach(); void testThreading(); + void matches_data(); + void matches(); private: void testThreadingHelper(); @@ -4023,6 +4025,54 @@ void tst_QUrl::testThreading() delete s_urlStorage; } +void tst_QUrl::matches_data() +{ + QTest::addColumn("urlStrOne"); + QTest::addColumn("urlStrTwo"); + QTest::addColumn("options"); + QTest::addColumn("matches"); + + QTest::newRow("matchingString-none") << "http://www.website.com/directory/?#ref" + << "http://www.website.com/directory/?#ref" + << uint(QUrl::None) << true; + QTest::newRow("nonMatchingString-none") << "http://www.website.com/directory/?#ref" + << "http://www.nomatch.com/directory/?#ref" + << uint(QUrl::None) << false; + QTest::newRow("matchingHost-removePath") << "http://www.website.com/directory" + << "http://www.website.com/differentdir" + << uint(QUrl::RemovePath) << true; + QTest::newRow("nonMatchingHost-removePath") << "http://www.website.com/directory" + << "http://www.different.com/differentdir" + << uint(QUrl::RemovePath) << false; + QTest::newRow("matchingHost-removePathAuthority") << "http://user:pass@www.website.com/directory" + << "http://www.website.com/differentdir" + << uint(QUrl::RemovePath | QUrl::RemoveAuthority) + << true; + QTest::newRow("nonMatchingHost-removePathAuthority") << "http://user:pass@www.website.com/directory" + << "http://user:pass@www.different.com/differentdir" + << uint(QUrl::RemovePath | QUrl::RemoveAuthority) + << true; + QTest::newRow("matchingHostAuthority-removePathAuthority") + << "http://user:pass@www.website.com/directory" << "http://www.website.com/differentdir" + << uint(QUrl::RemovePath | QUrl::RemoveAuthority) << true; + QTest::newRow("nonMatchingAuthority-removePathAuthority") + << "http://user:pass@www.website.com/directory" + << "http://otheruser:otherpass@www.website.com/directory" + << uint(QUrl::RemovePath | QUrl::RemoveAuthority) << true; +} + +void tst_QUrl::matches() +{ + QFETCH(QString, urlStrOne); + QFETCH(QString, urlStrTwo); + QFETCH(uint, options); + QFETCH(bool, matches); + + QUrl urlOne(urlStrOne); + QUrl urlTwo(urlStrTwo); + QCOMPARE(urlOne.matches(urlTwo, QUrl::FormattingOptions(options)), matches); +} + QTEST_MAIN(tst_QUrl) #include "tst_qurl.moc" -- cgit v1.2.3 From e1f0e08e9a290689f2778ffcfafc133f8a1b99cf Mon Sep 17 00:00:00 2001 From: Jesus Fernandez Date: Fri, 18 Nov 2016 17:39:01 +0100 Subject: Add more information for QKeySequence::toString on macOS MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The previous documentation said: "On OS X, the string returned resembles the sequence that is shown in the menu bar." That was not completely true because the string returned depends on the format passed to the function. Task-number: QTWEBSITE-744 Change-Id: I1b7d9367547326670d1b3a8cfe48f066910f5a10 Reviewed-by: Topi Reiniö --- src/gui/kernel/qkeysequence.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/gui/kernel/qkeysequence.cpp b/src/gui/kernel/qkeysequence.cpp index ea71e34e4b..77c5ae7a02 100644 --- a/src/gui/kernel/qkeysequence.cpp +++ b/src/gui/kernel/qkeysequence.cpp @@ -1517,7 +1517,9 @@ bool QKeySequence::isDetached() const If the key sequence has no keys, an empty string is returned. On \macos, the string returned resembles the sequence that is - shown in the menu bar. + shown in the menu bar if \a format is + QKeySequence::NativeText; otherwise, the string uses the + "portable" format, suitable for writing to a file. \sa fromString() */ -- cgit v1.2.3 From a9af3c85022994cfe18a05cd92db9fc0b0ad902c Mon Sep 17 00:00:00 2001 From: Kai Koehne Date: Fri, 16 Sep 2016 11:27:00 +0200 Subject: win: Show Tech Preview license Show the tech preview license for commercial users if -confirm-license is not set. This matches what the configure shell script is doing, too. Task-number: QTBUG-55676 Change-Id: I69f5553ab53dfcdc14c200e682c024a6cebee8fe Reviewed-by: Oswald Buddenhagen --- tools/configure/configureapp.cpp | 34 ++++++++++++++++++++-------------- tools/configure/tools.cpp | 8 +------- 2 files changed, 21 insertions(+), 21 deletions(-) diff --git a/tools/configure/configureapp.cpp b/tools/configure/configureapp.cpp index a908db0707..2b7a1d6b07 100644 --- a/tools/configure/configureapp.cpp +++ b/tools/configure/configureapp.cpp @@ -4550,11 +4550,6 @@ Configure::ProjectType Configure::projectType(const QString& proFileName) bool Configure::showLicense(QString orgLicenseFile) { - if (dictionary["LICENSE_CONFIRMED"] == "yes") { - cout << "You have already accepted the terms of the license." << endl << endl; - return true; - } - bool showLgpl2 = true; QString licenseFile = orgLicenseFile; QString theLicense; @@ -4665,21 +4660,32 @@ void Configure::readLicense() } } if (hasOpenSource && openSource) { - cout << endl << "This is the " << dictionary["PLATFORM NAME"] << " Open Source Edition." << endl; + cout << endl << "This is the " << dictionary["PLATFORM NAME"] << " Open Source Edition." << endl << endl; dictionary["LICENSEE"] = "Open Source"; dictionary["EDITION"] = "OpenSource"; - cout << endl; - if (!showLicense(dictionary["LICENSE FILE"])) { - cout << "Configuration aborted since license was not accepted"; - dictionary["DONE"] = "error"; - return; - } } else if (openSource) { cout << endl << "Cannot find the GPL license files! Please download the Open Source version of the library." << endl; dictionary["DONE"] = "error"; + } else { + QString tpLicense = sourcePath + "/LICENSE.PREVIEW.COMMERCIAL"; + if (QFile::exists(tpLicense)) { + cout << endl << "This is the Qt Preview Edition." << endl << endl; + + dictionary["EDITION"] = "Preview"; + dictionary["LICENSE FILE"] = tpLicense; + } else { + Tools::checkLicense(dictionary, sourcePath, buildPath); + } } - else { - Tools::checkLicense(dictionary, sourcePath, buildPath); + + if (dictionary["LICENSE_CONFIRMED"] != "yes") { + if (!showLicense(dictionary["LICENSE FILE"])) { + cout << "Configuration aborted since license was not accepted" << endl; + dictionary["DONE"] = "error"; + return; + } + } else if (dictionary["LICHECK"].isEmpty()) { // licheck executable shows license + cout << "You have already accepted the terms of the license." << endl << endl; } } diff --git a/tools/configure/tools.cpp b/tools/configure/tools.cpp index 095e798332..02c74282cd 100644 --- a/tools/configure/tools.cpp +++ b/tools/configure/tools.cpp @@ -47,13 +47,6 @@ using namespace std; void Tools::checkLicense(QMap &dictionary, const QString &sourcePath, const QString &buildPath) { - QString tpLicense = sourcePath + "/LICENSE.PREVIEW.COMMERCIAL"; - if (QFile::exists(tpLicense)) { - dictionary["EDITION"] = "Preview"; - dictionary["LICENSE FILE"] = tpLicense; - return; - } - dictionary["LICHECK"] = "licheck.exe"; const QString licenseChecker = @@ -80,6 +73,7 @@ void Tools::checkLicense(QMap &dictionary, } else { foreach (const QString &var, licheckOutput.split('\n')) dictionary[var.section('=', 0, 0).toUpper()] = var.section('=', 1, 1); + dictionary["LICENSE_CONFIRMED"] = "yes"; } } else { cout << endl << "Error: Could not find licheck.exe" << endl -- cgit v1.2.3 From cff48c7845ccf51ac53a550a43dec78428124f70 Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Mon, 21 Nov 2016 12:46:46 +0100 Subject: eglfs: Avoid unexpectedly flushing QPA input events Flushing all events to ensure that the expose (or other queued events) get processed right away is dangerous. Instead, pass ExcludeUserInputEvents like many other platform plugins do. This way queued input events do not get processed at an unexpected point in time and so do not interfere with modal dialogs for instance. Task-number: QTBUG-57229 Change-Id: I9da09e62627d26485fb5a37fc190cb4a4bcb28b6 Reviewed-by: Andy Nichols --- src/plugins/platforms/eglfs/qeglfsintegration.cpp | 2 +- src/plugins/platforms/eglfs/qeglfswindow.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/plugins/platforms/eglfs/qeglfsintegration.cpp b/src/plugins/platforms/eglfs/qeglfsintegration.cpp index bb62506f33..2a6f3aa7cf 100644 --- a/src/plugins/platforms/eglfs/qeglfsintegration.cpp +++ b/src/plugins/platforms/eglfs/qeglfsintegration.cpp @@ -176,7 +176,7 @@ QPlatformBackingStore *QEglFSIntegration::createPlatformBackingStore(QWindow *wi QPlatformWindow *QEglFSIntegration::createPlatformWindow(QWindow *window) const { - QWindowSystemInterface::flushWindowSystemEvents(); + QWindowSystemInterface::flushWindowSystemEvents(QEventLoop::ExcludeUserInputEvents); QEglFSWindow *w = qt_egl_device_integration()->createWindow(window); w->create(); if (window->type() != Qt::ToolTip) diff --git a/src/plugins/platforms/eglfs/qeglfswindow.cpp b/src/plugins/platforms/eglfs/qeglfswindow.cpp index 84856831c3..3cc7079fbb 100644 --- a/src/plugins/platforms/eglfs/qeglfswindow.cpp +++ b/src/plugins/platforms/eglfs/qeglfswindow.cpp @@ -208,7 +208,7 @@ void QEglFSWindow::setVisible(bool visible) QWindowSystemInterface::handleExposeEvent(wnd, QRect(QPoint(0, 0), wnd->geometry().size())); if (visible) - QWindowSystemInterface::flushWindowSystemEvents(); + QWindowSystemInterface::flushWindowSystemEvents(QEventLoop::ExcludeUserInputEvents); } void QEglFSWindow::setGeometry(const QRect &r) -- cgit v1.2.3 From 53edaf0fb7146e20029afcdbb57003025db8b7bf Mon Sep 17 00:00:00 2001 From: Jesus Fernandez Date: Tue, 22 Nov 2016 15:27:44 +0100 Subject: Document QMAKE_OBJECTIVE_CFLAGS Task-number: QTBUG-57264 Change-Id: Iae06d9428d320a99cfd070154ed7bc94ec450b91 Reviewed-by: Oswald Buddenhagen --- qmake/doc/src/qmake-manual.qdoc | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/qmake/doc/src/qmake-manual.qdoc b/qmake/doc/src/qmake-manual.qdoc index ccb79f4a9f..fe67568c51 100644 --- a/qmake/doc/src/qmake-manual.qdoc +++ b/qmake/doc/src/qmake-manual.qdoc @@ -2057,6 +2057,12 @@ value of this variable is typically handled by qmake or \l{#QMAKESPEC}{qmake.conf} and rarely needs to be modified. + \section1 QMAKE_OBJECTIVE_CFLAGS + + Specifies the Objective C/C++ compiler flags for building + a project. These flags are used in addition to QMAKE_CFLAGS and + QMAKE_CXXFLAGS. + \section1 QMAKE_POST_LINK Specifies the command to execute after linking the \l{TARGET} -- cgit v1.2.3 From e2b856d56290e9b3eaaf889b3e0a08badbaa6046 Mon Sep 17 00:00:00 2001 From: Timur Pocheptsov Date: Thu, 17 Nov 2016 16:10:11 +0100 Subject: QDir::tempPath - use NSTemporaryDirectory on Darwin MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Instead of hardcoded "/tmp". Task-number: QTBUG-57165 Change-Id: I9d3ae157c22ce131281b8279149eea87a26244e8 Reviewed-by: Morten Johan Sørvig --- src/corelib/io/qfilesystemengine_unix.cpp | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/src/corelib/io/qfilesystemengine_unix.cpp b/src/corelib/io/qfilesystemengine_unix.cpp index 3cc27bf847..a3b28a8d95 100644 --- a/src/corelib/io/qfilesystemengine_unix.cpp +++ b/src/corelib/io/qfilesystemengine_unix.cpp @@ -59,6 +59,13 @@ #include #endif +#if defined(Q_OS_DARWIN) +// We cannot include (it's an Objective-C header), but +// we need these declarations: +Q_FORWARD_DECLARE_OBJC_CLASS(NSString); +extern "C" NSString *NSTemporaryDirectory(); +#endif + QT_BEGIN_NAMESPACE #if defined(Q_OS_DARWIN) @@ -706,8 +713,17 @@ QString QFileSystemEngine::tempPath() return QDir::cleanPath(temp); #else QString temp = QFile::decodeName(qgetenv("TMPDIR")); - if (temp.isEmpty()) - temp = QLatin1String("/tmp"); + if (temp.isEmpty()) { +#if defined(Q_OS_DARWIN) && !defined(QT_BOOTSTRAPPED) + if (NSString *nsPath = NSTemporaryDirectory()) { + temp = QString::fromCFString((CFStringRef)nsPath); + } else { +#else + { +#endif + temp = QLatin1String("/tmp"); + } + } return QDir::cleanPath(temp); #endif } -- cgit v1.2.3