From e4e87a2ece1e0c9901514fea094f31863b64b570 Mon Sep 17 00:00:00 2001 From: Andy Shaw Date: Wed, 7 Mar 2018 15:12:13 +0100 Subject: [PATCH 01/23] sqlite: Prevent a crash when sqlite does not detect any parameters When using a virtual table inside a SQLite database it is possible that it does not report the right number of parameters. Therefore we need to account for this case to prevent it from crashing when trying to bind parameters it thinks does not exist. Task-number: QTBUG-66816 Change-Id: I3ff70bb1fe73091f43c3df53616f75858e451cfd Reviewed-by: Jarek Kobus Reviewed-by: Edward Welbourne --- src/plugins/sqldrivers/sqlite/qsql_sqlite.cpp | 5 ++- .../sql/kernel/qsqlquery/tst_qsqlquery.cpp | 41 +++++++++++++++++++ 2 files changed, 45 insertions(+), 1 deletion(-) diff --git a/src/plugins/sqldrivers/sqlite/qsql_sqlite.cpp b/src/plugins/sqldrivers/sqlite/qsql_sqlite.cpp index d1a6582c5a..f715d3cba3 100644 --- a/src/plugins/sqldrivers/sqlite/qsql_sqlite.cpp +++ b/src/plugins/sqldrivers/sqlite/qsql_sqlite.cpp @@ -467,7 +467,10 @@ bool QSQLiteResult::exec() #if (SQLITE_VERSION_NUMBER >= 3003011) // In the case of the reuse of a named placeholder - if (paramCount < values.count()) { + // We need to check explicitly that paramCount is greater than 1, as sqlite + // can end up in a case where for virtual tables it returns 0 even though it + // has parameters + if (paramCount > 1 && paramCount < values.count()) { const auto countIndexes = [](int counter, const QList& indexList) { return counter + indexList.length(); }; diff --git a/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp b/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp index a51865897f..c4a27a3175 100644 --- a/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp +++ b/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp @@ -176,6 +176,8 @@ private slots: void emptyTableNavigate(); void timeStampParsing_data() { generic_data(); } void timeStampParsing(); + void sqliteVirtualTable_data() { generic_data("QSQLITE"); } + void sqliteVirtualTable(); #ifdef NOT_READY_YET void task_229811(); @@ -4623,5 +4625,44 @@ void tst_QSqlQuery::dateTime() } } +void tst_QSqlQuery::sqliteVirtualTable() +{ + // Virtual tables can behave differently when it comes to prepared + // queries, so we need to check these explicitly + QFETCH(QString, dbName); + QSqlDatabase db = QSqlDatabase::database(dbName); + CHECK_DATABASE(db); + const auto tableName = qTableName("sqliteVirtual", __FILE__, db); + QSqlQuery qry(db); + QVERIFY_SQL(qry, exec("create virtual table " + tableName + " using fts3(id, name)")); + + // Delibrately malform the query to try and provoke a potential crash situation + QVERIFY_SQL(qry, prepare("select * from " + tableName + " where name match '?'")); + qry.addBindValue("Andy"); + QVERIFY(!qry.exec()); + + QVERIFY_SQL(qry, prepare("insert into " + tableName + "(id, name) VALUES (?, ?)")); + qry.addBindValue(1); + qry.addBindValue("Andy"); + QVERIFY_SQL(qry, exec()); + + QVERIFY_SQL(qry, exec("select * from " + tableName)); + QVERIFY(qry.next()); + QCOMPARE(qry.value(0).toInt(), 1); + QCOMPARE(qry.value(1).toString(), "Andy"); + + QVERIFY_SQL(qry, prepare("insert into " + tableName + "(id, name) values (:id, :name)")); + qry.bindValue(":id", 2); + qry.bindValue(":name", "Peter"); + QVERIFY_SQL(qry, exec()); + + QVERIFY_SQL(qry, prepare("select * from " + tableName + " where name match ?")); + qry.addBindValue("Peter"); + QVERIFY_SQL(qry, exec()); + QVERIFY(qry.next()); + QCOMPARE(qry.value(0).toInt(), 2); + QCOMPARE(qry.value(1).toString(), "Peter"); +} + QTEST_MAIN( tst_QSqlQuery ) #include "tst_qsqlquery.moc" From 44137dc65ab1121fc360f6f006b7515648f0bae3 Mon Sep 17 00:00:00 2001 From: Andy Shaw Date: Fri, 9 Mar 2018 14:25:54 +0100 Subject: [PATCH 02/23] XCode: Fix the output paths for extra compilers with fileFixify() This ensures that the generated XCode project can correctly find any files that are referenced via a path containing "..". Task-number: QTBUG-35131 Change-Id: I049bc2279b4c515a82acd61142d25b8c240e8f6e Reviewed-by: Oswald Buddenhagen --- qmake/generators/mac/pbuilder_pbx.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/qmake/generators/mac/pbuilder_pbx.cpp b/qmake/generators/mac/pbuilder_pbx.cpp index db7a1b2714..3b1f904253 100644 --- a/qmake/generators/mac/pbuilder_pbx.cpp +++ b/qmake/generators/mac/pbuilder_pbx.cpp @@ -779,8 +779,9 @@ ProjectBuilderMakefileGenerator::writeMakeParts(QTextStream &t) mkt << "\\\n\t"; ++added; const QString file_name = fileFixify(fn, FileFixifyFromOutdir); + const QString tmpOut = fileFixify(tmp_out.first().toQString(), FileFixifyFromOutdir); mkt << ' ' << escapeDependencyPath(Option::fixPathToTargetOS( - replaceExtraCompilerVariables(tmp_out.first().toQString(), file_name, QString(), NoShell))); + replaceExtraCompilerVariables(tmpOut, file_name, QString(), NoShell))); } } } From 9b68dc19bf3973d3a46439c4b8667ad3beba167d Mon Sep 17 00:00:00 2001 From: Andy Shaw Date: Thu, 22 Feb 2018 13:45:34 +0100 Subject: [PATCH 03/23] MySQL: Fix tests This fixes the following: - tst_QSqlDatabase::recordMySQL() to account for performance improvements done for small integral types - tst_QSqlQuery::nextResult() so that NUMERIC results are seen as doubles - tst_QSqlQuery::timeStampParsing() so that MySQL accepts the CREATE TABLE statement Change-Id: I68fb1d06dac12d500bb4596463f5bdd65cc9c226 Reviewed-by: Edward Welbourne --- .../auto/sql/kernel/qsqldatabase/tst_qsqldatabase.cpp | 8 ++++---- tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp | 10 +++++----- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/tests/auto/sql/kernel/qsqldatabase/tst_qsqldatabase.cpp b/tests/auto/sql/kernel/qsqldatabase/tst_qsqldatabase.cpp index 89978319a0..4130b364f4 100644 --- a/tests/auto/sql/kernel/qsqldatabase/tst_qsqldatabase.cpp +++ b/tests/auto/sql/kernel/qsqldatabase/tst_qsqldatabase.cpp @@ -890,10 +890,10 @@ void tst_QSqlDatabase::recordMySQL() static QDateTime dt(QDate::currentDate(), QTime(1, 2, 3, 0)); static const FieldDef fieldDefs[] = { - FieldDef("tinyint", QVariant::Int, 127), - FieldDef("tinyint unsigned", QVariant::UInt, 255), - FieldDef("smallint", QVariant::Int, 32767), - FieldDef("smallint unsigned", QVariant::UInt, 65535), + FieldDef("tinyint", static_cast(QMetaType::Char), 127), + FieldDef("tinyint unsigned", static_cast(QMetaType::UChar), 255), + FieldDef("smallint", static_cast(QMetaType::Short), 32767), + FieldDef("smallint unsigned", static_cast(QMetaType::UShort), 65535), FieldDef("mediumint", QVariant::Int, 8388607), FieldDef("mediumint unsigned", QVariant::UInt, 16777215), FieldDef("integer", QVariant::Int, 2147483647), diff --git a/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp b/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp index c4a27a3175..6843ff7d4a 100644 --- a/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp +++ b/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp @@ -3035,11 +3035,7 @@ void tst_QSqlQuery::nextResult() QCOMPARE( q.record().field( 0 ).type(), QVariant::String ); QCOMPARE( q.record().field( 1 ).name().toUpper(), QString( "NUM" ) ); - - if (dbType == QSqlDriver::MySqlServer) - QCOMPARE( q.record().field( 1 ).type(), QVariant::String ); - else - QCOMPARE( q.record().field( 1 ).type(), QVariant::Double ); + QCOMPARE(q.record().field(1).type(), QVariant::Double); QVERIFY( q.next() ); // Move to first row of the second result set @@ -3289,6 +3285,10 @@ void tst_QSqlQuery::timeStampParsing() QVERIFY_SQL(q, exec(QStringLiteral("CREATE TABLE ") + tableName + QStringLiteral("(" "id serial NOT NULL, " "datefield timestamp, primary key(id));"))); + } else if (dbType == QSqlDriver::MySqlServer) { + QVERIFY_SQL(q, exec(QStringLiteral("CREATE TABLE ") + tableName + QStringLiteral("(" + "id integer NOT NULL AUTO_INCREMENT," + "datefield timestamp, primary key(id));"))); } else { QVERIFY_SQL(q, exec(QStringLiteral("CREATE TABLE ") + tableName + QStringLiteral("(" "\"id\" integer NOT NULL PRIMARY KEY AUTOINCREMENT," From daa7f5375c58464bbe92744599f1e2258445e259 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Sun, 25 Feb 2018 17:41:11 -0800 Subject: [PATCH 04/23] q{,Utf8}Printable: avoid creating a copy of a QString MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We have this QString() constructor call to permit things that convert to QString but aren't QString to be used in qPrintable, like a QStringBuilder-powered fast operator+ expression, like: qPrintable(string1 + ": " + string2) Unfortunately, it meant that we unnecessarily created a QString copy if the input was already QString. Change-Id: Iecab8770aa5840aba8edfffd1516bc94cec791a9 Reviewed-by: Olivier Goffart (Woboq GmbH) Reviewed-by: Oswald Buddenhagen Reviewed-by: MÃ¥rten Nordheim Reviewed-by: Thiago Macieira --- src/corelib/global/qglobal.h | 5 +++-- src/corelib/tools/qstring.h | 6 ++++++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/corelib/global/qglobal.h b/src/corelib/global/qglobal.h index 33885021ba..e31d4d9ad7 100644 --- a/src/corelib/global/qglobal.h +++ b/src/corelib/global/qglobal.h @@ -747,12 +747,13 @@ Q_CORE_EXPORT Q_DECL_CONST_FUNCTION bool qSharedBuild() Q_DECL_NOTHROW; # define QT_DEBUG #endif +// QtPrivate::asString defined in qstring.h #ifndef qPrintable -# define qPrintable(string) QString(string).toLocal8Bit().constData() +# define qPrintable(string) QtPrivate::asString(string).toLocal8Bit().constData() #endif #ifndef qUtf8Printable -# define qUtf8Printable(string) QString(string).toUtf8().constData() +# define qUtf8Printable(string) QtPrivate::asString(string).toUtf8().constData() #endif /* diff --git a/src/corelib/tools/qstring.h b/src/corelib/tools/qstring.h index 0138ae4098..b8f4d49831 100644 --- a/src/corelib/tools/qstring.h +++ b/src/corelib/tools/qstring.h @@ -1857,6 +1857,12 @@ QT_DEPRECATED inline QString escape(const QString &plain) { #endif } +namespace QtPrivate { +// used by qPrintable() and qUtf8Printable() macros +inline const QString &asString(const QString &s) { return s; } +inline QString &&asString(QString &&s) { return std::move(s); } +} + QT_END_NAMESPACE #if defined(QT_USE_FAST_OPERATOR_PLUS) || defined(QT_USE_QSTRINGBUILDER) From d3121e3888ae43a7dc074f5d8acc26b1973a7726 Mon Sep 17 00:00:00 2001 From: Albert Astals Cid Date: Fri, 16 Mar 2018 17:01:54 +0100 Subject: [PATCH 05/23] Fix QPageLayout() not initializing units by using the other QPageLayout constructor Task-number: QTBUG-47551 Change-Id: I9c3635d4a460437febefdfb9d259d508b61c1f29 Reviewed-by: David Faure --- src/gui/painting/qpagelayout.cpp | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/src/gui/painting/qpagelayout.cpp b/src/gui/painting/qpagelayout.cpp index f3f7f5f956..2634a448a5 100644 --- a/src/gui/painting/qpagelayout.cpp +++ b/src/gui/painting/qpagelayout.cpp @@ -123,7 +123,6 @@ class QPageLayoutPrivate : public QSharedData { public: - QPageLayoutPrivate(); QPageLayoutPrivate(const QPageSize &pageSize, QPageLayout::Orientation orientation, const QMarginsF &margins, QPageLayout::Unit units, const QMarginsF &minMargins); @@ -166,12 +165,6 @@ private: QMarginsF m_maxMargins; }; -QPageLayoutPrivate::QPageLayoutPrivate() - : m_orientation(QPageLayout::Landscape), - m_mode(QPageLayout::StandardMode) -{ -} - QPageLayoutPrivate::QPageLayoutPrivate(const QPageSize &pageSize, QPageLayout::Orientation orientation, const QMarginsF &margins, QPageLayout::Unit units, const QMarginsF &minMargins) @@ -356,7 +349,7 @@ QRectF QPageLayoutPrivate::paintRect() const */ QPageLayout::QPageLayout() - : d(new QPageLayoutPrivate()) + : QPageLayout(QPageSize(), QPageLayout::Landscape, QMarginsF()) { } From efa6e989125b3a9cf54a408aae8a86ef4bddf778 Mon Sep 17 00:00:00 2001 From: Johan Klokkhammer Helsing Date: Tue, 13 Mar 2018 13:04:40 +0100 Subject: [PATCH 06/23] QPixmap don't assume QPlatformScreen::format is opaque QRasterPlatformPixmap::systemOpaqueFormat returned QPlatformScreen::format without checking that the format was actually opaque. This caused several QPixmap tests to fail on Wayland because Wayland compositors don't communicate the native format of the screen, just a list of supported pixel formats, so we just return ARGB32_premultiplied in QWaylandScreen::format(). Rename the method systemOpaqueFormat to systemNativeFormat since that's how it's used most of the time. And do a conversion when we actually care whether the format is opaque or not. Task-number: QTBUG-51748 Change-Id: I47dc1c3f185fb802016ca361206d47d02e8d3cf1 Reviewed-by: Eirik Aavitsland Reviewed-by: Allan Sandfeld Jensen --- src/gui/image/qimage_p.h | 30 ++++++++++++++++++++ src/gui/image/qpixmap_raster.cpp | 9 +++--- src/gui/image/qpixmap_raster_p.h | 2 +- tests/auto/gui/image/qpixmap/tst_qpixmap.cpp | 14 --------- 4 files changed, 36 insertions(+), 19 deletions(-) diff --git a/src/gui/image/qimage_p.h b/src/gui/image/qimage_p.h index befecbfe8b..f5fea2ed00 100644 --- a/src/gui/image/qimage_p.h +++ b/src/gui/image/qimage_p.h @@ -172,6 +172,31 @@ inline int qt_depthForFormat(QImage::Format format) #pragma optimize("", on) #endif +inline QImage::Format qt_opaqueVersion(QImage::Format format) +{ + switch (format) { + case QImage::Format_ARGB8565_Premultiplied: + return QImage::Format_RGB16; + case QImage::Format_ARGB8555_Premultiplied: + return QImage::Format_RGB555; + case QImage::Format_ARGB6666_Premultiplied: + return QImage::Format_RGB666; + case QImage::Format_ARGB4444_Premultiplied: + return QImage::Format_RGB444; + case QImage::Format_RGBA8888: + case QImage::Format_RGBA8888_Premultiplied: + return QImage::Format_RGBX8888; + case QImage::Format_A2BGR30_Premultiplied: + return QImage::Format_BGR30; + case QImage::Format_A2RGB30_Premultiplied: + return QImage::Format_RGB30; + case QImage::Format_ARGB32_Premultiplied: + case QImage::Format_ARGB32: + default: + return QImage::Format_RGB32; + } +} + inline QImage::Format qt_alphaVersion(QImage::Format format) { switch (format) { @@ -201,6 +226,11 @@ inline QImage::Format qt_maybeAlphaVersionWithSameDepth(QImage::Format format) return qt_depthForFormat(format) == qt_depthForFormat(toFormat) ? toFormat : format; } +inline QImage::Format qt_opaqueVersionForPainting(QImage::Format format) +{ + return qt_opaqueVersion(format); +} + inline QImage::Format qt_alphaVersionForPainting(QImage::Format format) { QImage::Format toFormat = qt_alphaVersion(format); diff --git a/src/gui/image/qpixmap_raster.cpp b/src/gui/image/qpixmap_raster.cpp index 51b4309e0a..431002d032 100644 --- a/src/gui/image/qpixmap_raster.cpp +++ b/src/gui/image/qpixmap_raster.cpp @@ -89,7 +89,7 @@ QRasterPlatformPixmap::~QRasterPlatformPixmap() { } -QImage::Format QRasterPlatformPixmap::systemOpaqueFormat() +QImage::Format QRasterPlatformPixmap::systemNativeFormat() { if (!QGuiApplication::primaryScreen()) return QImage::Format_RGB32; @@ -107,7 +107,7 @@ void QRasterPlatformPixmap::resize(int width, int height) if (pixelType() == BitmapType) format = QImage::Format_MonoLSB; else - format = systemOpaqueFormat(); + format = systemNativeFormat(); image = QImage(width, height, format); w = width; @@ -314,8 +314,9 @@ void QRasterPlatformPixmap::createPixmapForImage(QImage sourceImage, Qt::ImageCo ? QImage::Format_ARGB32_Premultiplied : QImage::Format_RGB32; } else { - QImage::Format opaqueFormat = systemOpaqueFormat(); - QImage::Format alphaFormat = qt_alphaVersionForPainting(opaqueFormat); + QImage::Format nativeFormat = systemNativeFormat(); + QImage::Format opaqueFormat = qt_opaqueVersionForPainting(nativeFormat); + QImage::Format alphaFormat = qt_alphaVersionForPainting(nativeFormat); if (!sourceImage.hasAlphaChannel()) { format = opaqueFormat; diff --git a/src/gui/image/qpixmap_raster_p.h b/src/gui/image/qpixmap_raster_p.h index cff962181a..fe2a1e581d 100644 --- a/src/gui/image/qpixmap_raster_p.h +++ b/src/gui/image/qpixmap_raster_p.h @@ -88,7 +88,7 @@ protected: void createPixmapForImage(QImage sourceImage, Qt::ImageConversionFlags flags); void setImage(const QImage &image); QImage image; - static QImage::Format systemOpaqueFormat(); + static QImage::Format systemNativeFormat(); private: friend class QPixmap; diff --git a/tests/auto/gui/image/qpixmap/tst_qpixmap.cpp b/tests/auto/gui/image/qpixmap/tst_qpixmap.cpp index de6713596d..e3bda6c2df 100644 --- a/tests/auto/gui/image/qpixmap/tst_qpixmap.cpp +++ b/tests/auto/gui/image/qpixmap/tst_qpixmap.cpp @@ -527,16 +527,8 @@ void tst_QPixmap::fill_transparent() QVERIFY(pixmap.hasAlphaChannel()); } -static bool isPlatformWayland() -{ - return QGuiApplication::platformName().startsWith(QLatin1String("wayland"), Qt::CaseInsensitive); -} - void tst_QPixmap::mask() { - if (isPlatformWayland()) - QSKIP("Wayland: This fails. See QTBUG-66983."); - QPixmap pm(100, 100); QBitmap bm(100, 100); @@ -778,9 +770,6 @@ void tst_QPixmap::convertFromImageNoDetach() void tst_QPixmap::convertFromImageNoDetach2() { - if (isPlatformWayland()) - QSKIP("Wayland: This fails. See QTBUG-66984."); - QPixmap randomPixmap(10, 10); if (randomPixmap.handle()->classId() != QPlatformPixmap::RasterClass) QSKIP("Test only valid for raster pixmaps"); @@ -1455,9 +1444,6 @@ void tst_QPixmap::fromImageReaderAnimatedGif() void tst_QPixmap::task_246446() { - if (isPlatformWayland()) - QSKIP("Wayland: This fails. See QTBUG-66985."); - // This crashed without the bugfix in 246446 QPixmap pm(10, 10); pm.fill(Qt::transparent); // force 32-bit depth From 2417cade46d5680fe4a23ad2e3d1607b3989c758 Mon Sep 17 00:00:00 2001 From: Johan Klokkhammer Helsing Date: Wed, 14 Mar 2018 16:47:11 +0100 Subject: [PATCH 07/23] tst_QOpenGLWindow: Move resizing to separate test Resizing is broken on Wayland EGL on Intel Mesa. Move resizing into a separate test and skip it on Wayland it until it's fixed in Mesa. Task-number: QTBUG-66848 Change-Id: I9450a5a588b0f5d8f0bd0210aae2dc72aa48d622 Reviewed-by: Pier Luigi Fiorini Reviewed-by: Laszlo Agocs --- .../qopenglwindow/tst_qopenglwindow.cpp | 25 +++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/tests/auto/gui/kernel/qopenglwindow/tst_qopenglwindow.cpp b/tests/auto/gui/kernel/qopenglwindow/tst_qopenglwindow.cpp index 8ffd1bb9b4..a971450ee8 100644 --- a/tests/auto/gui/kernel/qopenglwindow/tst_qopenglwindow.cpp +++ b/tests/auto/gui/kernel/qopenglwindow/tst_qopenglwindow.cpp @@ -42,6 +42,7 @@ private slots: void initTestCase(); void create(); void basic(); + void resize(); void painter(); void partial_data(); void partial(); @@ -115,8 +116,7 @@ void tst_QOpenGLWindow::basic() // Check that the virtuals are invoked. QCOMPARE(w.initCount, 1); - int resCount = w.resizeCount; - QVERIFY(resCount >= 1); + QVERIFY(w.resizeCount >= 1); QVERIFY(w.paintCount >= 1); // Check that something has been drawn; @@ -132,6 +132,27 @@ void tst_QOpenGLWindow::basic() QCOMPARE(v[2], GLint(w.width() * w.devicePixelRatio())); QCOMPARE(v[3], GLint(w.height() * w.devicePixelRatio())); w.doneCurrent(); +} + +static bool isPlatformWayland() +{ + return QGuiApplication::platformName().startsWith(QLatin1String("wayland"), Qt::CaseInsensitive); +} + +void tst_QOpenGLWindow::resize() +{ + if (isPlatformWayland()) + QSKIP("Wayland: Crashes on Intel Mesa due to a driver bug (QTBUG-66848)."); + + Window w; + w.reset(); + w.resize(640, 480); + w.show(); + QVERIFY(QTest::qWaitForWindowExposed(&w)); + + // Check that the virtuals are invoked. + int resCount = w.resizeCount; + QVERIFY(resCount >= 1); // Check that a future resize triggers resizeGL. w.resize(800, 600); From 38597dd08083f1f5cbf947cd3b0290065f2872c6 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Sat, 10 Mar 2018 11:17:47 -0800 Subject: [PATCH 08/23] Atomic: silence MSVC warning in the generic fetchAndSub MSVC atomics still use the generic version, instead of qatomic_cxx11.h. The implementation of fetchAndSub is implemented on top of fetchAndAdd, but produced a warning with unsigned types. Change-Id: I72f5230ad59948f784eafffd151aa53435b75298 Reviewed-by: Lars Knoll --- src/corelib/thread/qgenericatomic.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/corelib/thread/qgenericatomic.h b/src/corelib/thread/qgenericatomic.h index 5c4c02a2ec..89c4fe9a11 100644 --- a/src/corelib/thread/qgenericatomic.h +++ b/src/corelib/thread/qgenericatomic.h @@ -253,12 +253,15 @@ template struct QGenericAtomicOps return BaseClass::fetchAndAddRelaxed(_q_value, valueToAdd); } +QT_WARNING_PUSH +QT_WARNING_DISABLE_MSVC(4146) // unary minus operator applied to unsigned type, result still unsigned template static Q_ALWAYS_INLINE T fetchAndSubRelaxed(T &_q_value, typename QAtomicAdditiveType::AdditiveT operand) Q_DECL_NOTHROW { // implement fetchAndSub on top of fetchAndAdd return fetchAndAddRelaxed(_q_value, -operand); } +QT_WARNING_POP template static Q_ALWAYS_INLINE T fetchAndSubAcquire(T &_q_value, typename QAtomicAdditiveType::AdditiveT operand) Q_DECL_NOTHROW From 90493e16b8dd9edc6176d0abc255422edbbb05c3 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Sun, 18 Mar 2018 09:38:00 -0700 Subject: [PATCH 09/23] Atomics: remove qatomic_msvc.h No longer needed. The comment about missing constexpr support is incorrect: MSVC 2015 does have constexpr issues, but they don't affect our use of std::atomic. Change-Id: Ie9d9215342d449c48a11fffd151d11208137f00d Reviewed-by: Lars Knoll --- src/corelib/arch/arch.pri | 2 - src/corelib/arch/qatomic_msvc.h | 485 ------------------------------ src/corelib/thread/qbasicatomic.h | 16 +- 3 files changed, 2 insertions(+), 501 deletions(-) delete mode 100644 src/corelib/arch/qatomic_msvc.h diff --git a/src/corelib/arch/arch.pri b/src/corelib/arch/arch.pri index e490617c6b..c9e54d1972 100644 --- a/src/corelib/arch/arch.pri +++ b/src/corelib/arch/arch.pri @@ -1,5 +1,3 @@ -win32:HEADERS += arch/qatomic_msvc.h - HEADERS += \ arch/qatomic_bootstrap.h \ arch/qatomic_cxx11.h diff --git a/src/corelib/arch/qatomic_msvc.h b/src/corelib/arch/qatomic_msvc.h deleted file mode 100644 index 5eae2bdc48..0000000000 --- a/src/corelib/arch/qatomic_msvc.h +++ /dev/null @@ -1,485 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Copyright (C) 2016 Intel Corporation. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtCore module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** 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. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QATOMIC_MSVC_H -#define QATOMIC_MSVC_H - -#include - -//////////////////////////////////////////////////////////////////////////////////////////////////// - -// use compiler intrinsics for all atomic functions -# define QT_INTERLOCKED_PREFIX _ -# define QT_INTERLOCKED_PROTOTYPE -# define QT_INTERLOCKED_DECLARE_PROTOTYPES -# define QT_INTERLOCKED_INTRINSIC -# define Q_ATOMIC_INT16_IS_SUPPORTED - -# ifdef _WIN64 -# define Q_ATOMIC_INT64_IS_SUPPORTED -# endif - -//////////////////////////////////////////////////////////////////////////////////////////////////// -// Prototype declaration - -#define QT_INTERLOCKED_CONCAT_I(prefix, suffix) \ - prefix ## suffix -#define QT_INTERLOCKED_CONCAT(prefix, suffix) \ - QT_INTERLOCKED_CONCAT_I(prefix, suffix) - -// MSVC intrinsics prefix function names with an underscore. Also, if platform -// SDK headers have been included, the Interlocked names may be defined as -// macros. -// To avoid double underscores, we paste the prefix with Interlocked first and -// then the remainder of the function name. -#define QT_INTERLOCKED_FUNCTION(name) \ - QT_INTERLOCKED_CONCAT( \ - QT_INTERLOCKED_CONCAT(QT_INTERLOCKED_PREFIX, Interlocked), name) - -#ifndef QT_INTERLOCKED_VOLATILE -# define QT_INTERLOCKED_VOLATILE volatile -#endif - -#ifndef QT_INTERLOCKED_PREFIX -#define QT_INTERLOCKED_PREFIX -#endif - -#ifndef QT_INTERLOCKED_PROTOTYPE -#define QT_INTERLOCKED_PROTOTYPE -#endif - -#ifdef QT_INTERLOCKED_DECLARE_PROTOTYPES -#undef QT_INTERLOCKED_DECLARE_PROTOTYPES - -extern "C" { - - long QT_INTERLOCKED_PROTOTYPE QT_INTERLOCKED_FUNCTION( Increment )(long QT_INTERLOCKED_VOLATILE *); - long QT_INTERLOCKED_PROTOTYPE QT_INTERLOCKED_FUNCTION( Decrement )(long QT_INTERLOCKED_VOLATILE *); - long QT_INTERLOCKED_PROTOTYPE QT_INTERLOCKED_FUNCTION( CompareExchange )(long QT_INTERLOCKED_VOLATILE *, long, long); - long QT_INTERLOCKED_PROTOTYPE QT_INTERLOCKED_FUNCTION( Exchange )(long QT_INTERLOCKED_VOLATILE *, long); - long QT_INTERLOCKED_PROTOTYPE QT_INTERLOCKED_FUNCTION( ExchangeAdd )(long QT_INTERLOCKED_VOLATILE *, long); - -# if !defined(__i386__) && !defined(_M_IX86) - void * QT_INTERLOCKED_FUNCTION( CompareExchangePointer )(void * QT_INTERLOCKED_VOLATILE *, void *, void *); - void * QT_INTERLOCKED_FUNCTION( ExchangePointer )(void * QT_INTERLOCKED_VOLATILE *, void *); - __int64 QT_INTERLOCKED_FUNCTION( ExchangeAdd64 )(__int64 QT_INTERLOCKED_VOLATILE *, __int64); -# endif - -# ifdef Q_ATOMIC_INT16_IS_SUPPORTED - short QT_INTERLOCKED_PROTOTYPE QT_INTERLOCKED_FUNCTION( Increment16 )(short QT_INTERLOCKED_VOLATILE *); - short QT_INTERLOCKED_PROTOTYPE QT_INTERLOCKED_FUNCTION( Decrement16 )(short QT_INTERLOCKED_VOLATILE *); - short QT_INTERLOCKED_PROTOTYPE QT_INTERLOCKED_FUNCTION( CompareExchange16 )(short QT_INTERLOCKED_VOLATILE *, short, short); - short QT_INTERLOCKED_PROTOTYPE QT_INTERLOCKED_FUNCTION( Exchange16 )(short QT_INTERLOCKED_VOLATILE *, short); - short QT_INTERLOCKED_PROTOTYPE QT_INTERLOCKED_FUNCTION( ExchangeAdd16 )(short QT_INTERLOCKED_VOLATILE *, short); -# endif -# ifdef Q_ATOMIC_INT64_IS_SUPPORTED - __int64 QT_INTERLOCKED_PROTOTYPE QT_INTERLOCKED_FUNCTION( Increment64 )(__int64 QT_INTERLOCKED_VOLATILE *); - __int64 QT_INTERLOCKED_PROTOTYPE QT_INTERLOCKED_FUNCTION( Decrement64 )(__int64 QT_INTERLOCKED_VOLATILE *); - __int64 QT_INTERLOCKED_PROTOTYPE QT_INTERLOCKED_FUNCTION( CompareExchange64 )(__int64 QT_INTERLOCKED_VOLATILE *, __int64, __int64); - __int64 QT_INTERLOCKED_PROTOTYPE QT_INTERLOCKED_FUNCTION( Exchange64 )(__int64 QT_INTERLOCKED_VOLATILE *, __int64); - //above already: qint64 QT_INTERLOCKED_PROTOTYPE QT_INTERLOCKED_FUNCTION( ExchangeAdd64 )(qint64 QT_INTERLOCKED_VOLATILE *, qint64); -# endif -} - -#endif // QT_INTERLOCKED_DECLARE_PROTOTYPES - -#undef QT_INTERLOCKED_PROTOTYPE - -//////////////////////////////////////////////////////////////////////////////////////////////////// - -#ifdef QT_INTERLOCKED_INTRINSIC -#undef QT_INTERLOCKED_INTRINSIC - -# pragma intrinsic (_InterlockedIncrement) -# pragma intrinsic (_InterlockedDecrement) -# pragma intrinsic (_InterlockedExchange) -# pragma intrinsic (_InterlockedCompareExchange) -# pragma intrinsic (_InterlockedExchangeAdd) - -# if !defined(_M_IX86) -# pragma intrinsic (_InterlockedCompareExchangePointer) -# pragma intrinsic (_InterlockedExchangePointer) -# pragma intrinsic (_InterlockedExchangeAdd64) -# endif - -#endif // QT_INTERLOCKED_INTRINSIC - -//////////////////////////////////////////////////////////////////////////////////////////////////// -// Interlocked* replacement macros - -#if defined(__i386__) || defined(_M_IX86) - -# define QT_INTERLOCKED_COMPARE_EXCHANGE_POINTER(value, newValue, expectedValue) \ - reinterpret_cast( \ - QT_INTERLOCKED_FUNCTION(CompareExchange)( \ - reinterpret_cast(value), \ - long(newValue), \ - long(expectedValue))) - -# define QT_INTERLOCKED_EXCHANGE_POINTER(value, newValue) \ - QT_INTERLOCKED_FUNCTION(Exchange)( \ - reinterpret_cast(value), \ - long(newValue)) - -# define QT_INTERLOCKED_EXCHANGE_ADD_POINTER(value, valueToAdd) \ - QT_INTERLOCKED_FUNCTION(ExchangeAdd)( \ - reinterpret_cast(value), \ - (valueToAdd)) - -#else // !defined(__i386__) && !defined(_M_IX86) - -# define QT_INTERLOCKED_COMPARE_EXCHANGE_POINTER(value, newValue, expectedValue) \ - QT_INTERLOCKED_FUNCTION(CompareExchangePointer)( \ - (void * QT_INTERLOCKED_VOLATILE *)(value), \ - (void *) (newValue), \ - (void *) (expectedValue)) - -# define QT_INTERLOCKED_EXCHANGE_POINTER(value, newValue) \ - QT_INTERLOCKED_FUNCTION(ExchangePointer)( \ - (void * QT_INTERLOCKED_VOLATILE *)(value), \ - (void *) (newValue)) - -# define QT_INTERLOCKED_EXCHANGE_ADD_POINTER(value, valueToAdd) \ - QT_INTERLOCKED_FUNCTION(ExchangeAdd64)( \ - reinterpret_cast(value), \ - (valueToAdd)) - -#endif // !defined(__i386__) && !defined(_M_IX86) - -//////////////////////////////////////////////////////////////////////////////////////////////////// - -QT_BEGIN_NAMESPACE - -#if 0 -// silence syncqt warnings -QT_END_NAMESPACE -#pragma qt_sync_skip_header_check -#pragma qt_sync_stop_processing -#endif - -#define Q_ATOMIC_INT_REFERENCE_COUNTING_IS_ALWAYS_NATIVE -#define Q_ATOMIC_INT_REFERENCE_COUNTING_IS_WAIT_FREE - -#define Q_ATOMIC_INT_TEST_AND_SET_IS_ALWAYS_NATIVE -#define Q_ATOMIC_INT_TEST_AND_SET_IS_WAIT_FREE - -#define Q_ATOMIC_INT_FETCH_AND_STORE_IS_ALWAYS_NATIVE -#define Q_ATOMIC_INT_FETCH_AND_STORE_IS_WAIT_FREE - -#define Q_ATOMIC_INT_FETCH_AND_ADD_IS_ALWAYS_NATIVE -#define Q_ATOMIC_INT_FETCH_AND_ADD_IS_WAIT_FREE - -#define Q_ATOMIC_INT32_IS_SUPPORTED - -#define Q_ATOMIC_INT32_REFERENCE_COUNTING_IS_ALWAYS_NATIVE -#define Q_ATOMIC_INT32_REFERENCE_COUNTING_IS_WAIT_FREE - -#define Q_ATOMIC_INT32_TEST_AND_SET_IS_ALWAYS_NATIVE -#define Q_ATOMIC_INT32_TEST_AND_SET_IS_WAIT_FREE - -#define Q_ATOMIC_INT32_FETCH_AND_STORE_IS_ALWAYS_NATIVE -#define Q_ATOMIC_INT32_FETCH_AND_STORE_IS_WAIT_FREE - -#define Q_ATOMIC_INT32_FETCH_AND_ADD_IS_ALWAYS_NATIVE -#define Q_ATOMIC_INT32_FETCH_AND_ADD_IS_WAIT_FREE - -#define Q_ATOMIC_POINTER_TEST_AND_SET_IS_ALWAYS_NATIVE -#define Q_ATOMIC_POINTER_TEST_AND_SET_IS_WAIT_FREE - -#define Q_ATOMIC_POINTER_FETCH_AND_STORE_IS_ALWAYS_NATIVE -#define Q_ATOMIC_POINTER_FETCH_AND_STORE_IS_WAIT_FREE - -#define Q_ATOMIC_POINTER_FETCH_AND_ADD_IS_ALWAYS_NATIVE -#define Q_ATOMIC_POINTER_FETCH_AND_ADD_IS_WAIT_FREE - -#ifdef Q_ATOMIC_INT16_IS_SUPPORTED -# define Q_ATOMIC_INT16_REFERENCE_COUNTING_IS_ALWAYS_NATIVE -# define Q_ATOMIC_INT16_REFERENCE_COUNTING_IS_WAIT_FREE - -# define Q_ATOMIC_INT16_TEST_AND_SET_IS_ALWAYS_NATIVE -# define Q_ATOMIC_INT16_TEST_AND_SET_IS_WAIT_FREE - -# define Q_ATOMIC_INT16_FETCH_AND_STORE_IS_ALWAYS_NATIVE -# define Q_ATOMIC_INT16_FETCH_AND_STORE_IS_WAIT_FREE - -# define Q_ATOMIC_INT16_FETCH_AND_ADD_IS_ALWAYS_NATIVE -# define Q_ATOMIC_INT16_FETCH_AND_ADD_IS_WAIT_FREE - -template<> struct QAtomicOpsSupport<2> { enum { IsSupported = 1 }; }; -#endif - -#ifdef Q_ATOMIC_INT64_IS_SUPPORTED -# define Q_ATOMIC_INT64_REFERENCE_COUNTING_IS_ALWAYS_NATIVE -# define Q_ATOMIC_INT64_REFERENCE_COUNTING_IS_WAIT_FREE - -# define Q_ATOMIC_INT64_TEST_AND_SET_IS_ALWAYS_NATIVE -# define Q_ATOMIC_INT64_TEST_AND_SET_IS_WAIT_FREE - -# define Q_ATOMIC_INT64_FETCH_AND_STORE_IS_ALWAYS_NATIVE -# define Q_ATOMIC_INT64_FETCH_AND_STORE_IS_WAIT_FREE - -# define Q_ATOMIC_INT64_FETCH_AND_ADD_IS_ALWAYS_NATIVE -# define Q_ATOMIC_INT64_FETCH_AND_ADD_IS_WAIT_FREE - -template<> struct QAtomicOpsSupport<8> { enum { IsSupported = 1 }; }; -#endif - -//////////////////////////////////////////////////////////////////////////////////////////////////// - -template struct QAtomicWindowsType { typedef typename QIntegerForSize::Signed Type; }; -template <> struct QAtomicWindowsType<4> { typedef long Type; }; - - -template struct QAtomicOpsBySize : QGenericAtomicOps > -{ - static inline Q_DECL_CONSTEXPR bool isReferenceCountingNative() Q_DECL_NOTHROW { return true; } - static inline Q_DECL_CONSTEXPR bool isReferenceCountingWaitFree() Q_DECL_NOTHROW { return true; } - template static bool ref(T &_q_value) Q_DECL_NOTHROW; - template static bool deref(T &_q_value) Q_DECL_NOTHROW; - - static inline Q_DECL_CONSTEXPR bool isTestAndSetNative() Q_DECL_NOTHROW { return true; } - static inline Q_DECL_CONSTEXPR bool isTestAndSetWaitFree() Q_DECL_NOTHROW { return true; } - template static bool testAndSetRelaxed(T &_q_value, T expectedValue, T newValue) Q_DECL_NOTHROW; - template - static bool testAndSetRelaxed(T &_q_value, T expectedValue, T newValue, T *currentValue) Q_DECL_NOTHROW; - - static inline Q_DECL_CONSTEXPR bool isFetchAndStoreNative() Q_DECL_NOTHROW { return true; } - static inline Q_DECL_CONSTEXPR bool isFetchAndStoreWaitFree() Q_DECL_NOTHROW { return true; } - template static T fetchAndStoreRelaxed(T &_q_value, T newValue) Q_DECL_NOTHROW; - - static inline Q_DECL_CONSTEXPR bool isFetchAndAddNative() Q_DECL_NOTHROW { return true; } - static inline Q_DECL_CONSTEXPR bool isFetchAndAddWaitFree() Q_DECL_NOTHROW { return true; } - template static T fetchAndAddRelaxed(T &_q_value, typename QAtomicAdditiveType::AdditiveT valueToAdd) Q_DECL_NOTHROW; - -private: - typedef typename QAtomicWindowsType::Type Type; - template static inline Type *atomic(T *t) - { Q_STATIC_ASSERT(sizeof(T) == sizeof(Type)); return reinterpret_cast(t); } - template static inline Type value(T t) - { Q_STATIC_ASSERT(sizeof(T) == sizeof(Type)); return Type(t); } -}; - -template -struct QAtomicOps : QAtomicOpsBySize -{ - typedef T Type; -}; - -template<> template -inline bool QAtomicOpsBySize<4>::ref(T &_q_value) Q_DECL_NOTHROW -{ - return QT_INTERLOCKED_FUNCTION(Increment)(atomic(&_q_value)) != 0; -} - -template<> template -inline bool QAtomicOpsBySize<4>::deref(T &_q_value) Q_DECL_NOTHROW -{ - return QT_INTERLOCKED_FUNCTION(Decrement)(atomic(&_q_value)) != 0; -} - -template<> template -inline bool QAtomicOpsBySize<4>::testAndSetRelaxed(T &_q_value, T expectedValue, T newValue) Q_DECL_NOTHROW -{ - return QT_INTERLOCKED_FUNCTION(CompareExchange)(atomic(&_q_value), value(newValue), value(expectedValue)) == value(expectedValue); -} - -template<> template -inline bool QAtomicOpsBySize<4>::testAndSetRelaxed(T &_q_value, T expectedValue, T newValue, T *currentValue) Q_DECL_NOTHROW -{ - *currentValue = T(QT_INTERLOCKED_FUNCTION(CompareExchange)(atomic(&_q_value), newValue, expectedValue)); - return *currentValue == expectedValue; -} - -template<> template -inline T QAtomicOpsBySize<4>::fetchAndStoreRelaxed(T &_q_value, T newValue) Q_DECL_NOTHROW -{ - return QT_INTERLOCKED_FUNCTION(Exchange)(atomic(&_q_value), value(newValue)); -} - -template<> template -inline T QAtomicOpsBySize<4>::fetchAndAddRelaxed(T &_q_value, typename QAtomicAdditiveType::AdditiveT valueToAdd) Q_DECL_NOTHROW -{ - return QT_INTERLOCKED_FUNCTION(ExchangeAdd)(atomic(&_q_value), value(valueToAdd * QAtomicAdditiveType::AddScale)); -} - -#ifdef Q_ATOMIC_INT16_IS_SUPPORTED -template<> template -inline bool QAtomicOpsBySize<2>::ref(T &_q_value) Q_DECL_NOTHROW -{ - return QT_INTERLOCKED_FUNCTION(Increment16)(atomic(&_q_value)) != 0; -} - -template<> template -inline bool QAtomicOpsBySize<2>::deref(T &_q_value) Q_DECL_NOTHROW -{ - return QT_INTERLOCKED_FUNCTION(Decrement16)(atomic(&_q_value)) != 0; -} - -template<> template -inline bool QAtomicOpsBySize<2>::testAndSetRelaxed(T &_q_value, T expectedValue, T newValue) Q_DECL_NOTHROW -{ - return QT_INTERLOCKED_FUNCTION(CompareExchange16)(atomic(&_q_value), value(newValue), value(expectedValue)) == value(expectedValue); -} - -template<> template -inline bool QAtomicOpsBySize<2>::testAndSetRelaxed(T &_q_value, T expectedValue, T newValue, T *currentValue) Q_DECL_NOTHROW -{ - *currentValue = T(QT_INTERLOCKED_FUNCTION(CompareExchange16)(atomic(&_q_value), newValue, expectedValue)); - return *currentValue == expectedValue; -} - -template<> template -inline T QAtomicOpsBySize<2>::fetchAndStoreRelaxed(T &_q_value, T newValue) Q_DECL_NOTHROW -{ - return QT_INTERLOCKED_FUNCTION(Exchange16)(atomic(&_q_value), value(newValue)); -} - -template<> template -inline T QAtomicOpsBySize<2>::fetchAndAddRelaxed(T &_q_value, typename QAtomicAdditiveType::AdditiveT valueToAdd) Q_DECL_NOTHROW -{ - return QT_INTERLOCKED_FUNCTION(ExchangeAdd16)(atomic(&_q_value), value(valueToAdd * QAtomicAdditiveType::AddScale)); -} -#endif - -#ifdef Q_ATOMIC_INT64_IS_SUPPORTED -template<> template -inline bool QAtomicOpsBySize<8>::ref(T &_q_value) Q_DECL_NOTHROW -{ - return QT_INTERLOCKED_FUNCTION(Increment64)(atomic(&_q_value)) != 0; -} - -template<> template -inline bool QAtomicOpsBySize<8>::deref(T &_q_value) Q_DECL_NOTHROW -{ - return QT_INTERLOCKED_FUNCTION(Decrement64)(atomic(&_q_value)) != 0; -} - -template<> template -inline bool QAtomicOpsBySize<8>::testAndSetRelaxed(T &_q_value, T expectedValue, T newValue) Q_DECL_NOTHROW -{ - return QT_INTERLOCKED_FUNCTION(CompareExchange64)(atomic(&_q_value), value(newValue), value(expectedValue)) == value(expectedValue); -} - -template<> template -inline bool QAtomicOpsBySize<8>::testAndSetRelaxed(T &_q_value, T expectedValue, T newValue, T *currentValue) Q_DECL_NOTHROW -{ - *currentValue = T(QT_INTERLOCKED_FUNCTION(CompareExchange64)(atomic(&_q_value), newValue, expectedValue)); - return *currentValue == expectedValue; -} - -template<> template -inline T QAtomicOpsBySize<8>::fetchAndStoreRelaxed(T &_q_value, T newValue) Q_DECL_NOTHROW -{ - return QT_INTERLOCKED_FUNCTION(Exchange64)(atomic(&_q_value), value(newValue)); -} - -template<> template -inline T QAtomicOpsBySize<8>::fetchAndAddRelaxed(T &_q_value, typename QAtomicAdditiveType::AdditiveT valueToAdd) Q_DECL_NOTHROW -{ - return QT_INTERLOCKED_FUNCTION(ExchangeAdd64)(atomic(&_q_value), value(valueToAdd * QAtomicAdditiveType::AddScale)); -} -#endif - -// Specialization for pointer types, since we have Interlocked*Pointer() variants in some configurations -template -struct QAtomicOps : QGenericAtomicOps > -{ - typedef T *Type; - - static inline Q_DECL_CONSTEXPR bool isTestAndSetNative() Q_DECL_NOTHROW { return true; } - static inline Q_DECL_CONSTEXPR bool isTestAndSetWaitFree() Q_DECL_NOTHROW { return true; } - static bool testAndSetRelaxed(T *&_q_value, T *expectedValue, T *newValue) Q_DECL_NOTHROW; - static bool testAndSetRelaxed(T *&_q_value, T *expectedValue, T *newValue, T **currentValue) Q_DECL_NOTHROW; - - static inline Q_DECL_CONSTEXPR bool isFetchAndStoreNative() Q_DECL_NOTHROW { return true; } - static inline Q_DECL_CONSTEXPR bool isFetchAndStoreWaitFree() Q_DECL_NOTHROW { return true; } - static T *fetchAndStoreRelaxed(T *&_q_value, T *newValue) Q_DECL_NOTHROW; - - static inline Q_DECL_CONSTEXPR bool isFetchAndAddNative() Q_DECL_NOTHROW { return true; } - static inline Q_DECL_CONSTEXPR bool isFetchAndAddWaitFree() Q_DECL_NOTHROW { return true; } - static T *fetchAndAddRelaxed(T *&_q_value, qptrdiff valueToAdd) Q_DECL_NOTHROW; -}; - -template -inline bool QAtomicOps::testAndSetRelaxed(T *&_q_value, T *expectedValue, T *newValue) Q_DECL_NOTHROW -{ - return QT_INTERLOCKED_COMPARE_EXCHANGE_POINTER(&_q_value, newValue, expectedValue) == expectedValue; -} - -template -inline bool QAtomicOps::testAndSetRelaxed(T *&_q_value, T *expectedValue, T *newValue, T **currentValue) Q_DECL_NOTHROW -{ - *currentValue = reinterpret_cast(QT_INTERLOCKED_COMPARE_EXCHANGE_POINTER(&_q_value, newValue, expectedValue)); - return *currentValue == expectedValue; -} - -template -inline T *QAtomicOps::fetchAndStoreRelaxed(T *&_q_value, T *newValue) Q_DECL_NOTHROW -{ - return reinterpret_cast(QT_INTERLOCKED_EXCHANGE_POINTER(&_q_value, newValue)); -} - -template -inline T *QAtomicOps::fetchAndAddRelaxed(T *&_q_value, qptrdiff valueToAdd) Q_DECL_NOTHROW -{ - return reinterpret_cast(QT_INTERLOCKED_EXCHANGE_ADD_POINTER(&_q_value, valueToAdd * sizeof(T))); -} - -//////////////////////////////////////////////////////////////////////////////////////////////////// -// Cleanup - -#undef QT_INTERLOCKED_CONCAT_I -#undef QT_INTERLOCKED_CONCAT -#undef QT_INTERLOCKED_FUNCTION -#undef QT_INTERLOCKED_PREFIX - -#undef QT_INTERLOCKED_VOLATILE - -#undef QT_INTERLOCKED_INCREMENT -#undef QT_INTERLOCKED_DECREMENT -#undef QT_INTERLOCKED_COMPARE_EXCHANGE -#undef QT_INTERLOCKED_EXCHANGE -#undef QT_INTERLOCKED_EXCHANGE_ADD -#undef QT_INTERLOCKED_COMPARE_EXCHANGE_POINTER -#undef QT_INTERLOCKED_EXCHANGE_POINTER -#undef QT_INTERLOCKED_EXCHANGE_ADD_POINTER - -QT_END_NAMESPACE -#endif // QATOMIC_MSVC_H diff --git a/src/corelib/thread/qbasicatomic.h b/src/corelib/thread/qbasicatomic.h index 92db7a6228..aacd12f220 100644 --- a/src/corelib/thread/qbasicatomic.h +++ b/src/corelib/thread/qbasicatomic.h @@ -1,7 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2011 Thiago Macieira -** Copyright (C) 2016 Intel Corporation. +** Copyright (C) 2018 Intel Corporation. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the QtCore module of the Qt Toolkit. @@ -45,20 +45,8 @@ #if defined(QT_BOOTSTRAPPED) # include - -// If C++11 atomics are supported, use them! -// Note that constexpr support is sometimes disabled in QNX builds but its -// library has . -#elif defined(Q_COMPILER_ATOMICS) && (defined(Q_COMPILER_CONSTEXPR) || defined(Q_OS_QNX)) -# include - -// We only support one fallback: MSVC, because even on version 2015, it lacks full constexpr support -#elif defined(Q_CC_MSVC) -# include - -// No fallback #else -# error "Qt requires C++11 support" +# include #endif QT_WARNING_PUSH From 9fa2626ef8760fe2923af5b47d027e63d9333776 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Sun, 18 Mar 2018 09:40:01 -0700 Subject: [PATCH 10/23] Remove src/corelib/arch, merging with src/corelib/thread There is no more architecture-specific code. Change-Id: Ie9d9215342d449c48a11fffd151d11411cd73fc7 Reviewed-by: Lars Knoll --- src/corelib/arch/arch.pri | 5 ----- src/corelib/corelib.pro | 1 - src/corelib/{arch => thread}/qatomic_bootstrap.h | 0 src/corelib/{arch => thread}/qatomic_cxx11.h | 0 src/corelib/thread/thread.pri | 4 ++++ 5 files changed, 4 insertions(+), 6 deletions(-) delete mode 100644 src/corelib/arch/arch.pri rename src/corelib/{arch => thread}/qatomic_bootstrap.h (100%) rename src/corelib/{arch => thread}/qatomic_cxx11.h (100%) diff --git a/src/corelib/arch/arch.pri b/src/corelib/arch/arch.pri deleted file mode 100644 index c9e54d1972..0000000000 --- a/src/corelib/arch/arch.pri +++ /dev/null @@ -1,5 +0,0 @@ -HEADERS += \ - arch/qatomic_bootstrap.h \ - arch/qatomic_cxx11.h - -qtConfig(std-atomic64): QMAKE_USE += libatomic diff --git a/src/corelib/corelib.pro b/src/corelib/corelib.pro index 3db2e2ceb8..7f62a6f1b0 100644 --- a/src/corelib/corelib.pro +++ b/src/corelib/corelib.pro @@ -32,7 +32,6 @@ ANDROID_PERMISSIONS = \ freebsd|openbsd: QMAKE_LFLAGS_NOUNDEF = include(animation/animation.pri) -include(arch/arch.pri) include(global/global.pri) include(thread/thread.pri) include(tools/tools.pri) diff --git a/src/corelib/arch/qatomic_bootstrap.h b/src/corelib/thread/qatomic_bootstrap.h similarity index 100% rename from src/corelib/arch/qatomic_bootstrap.h rename to src/corelib/thread/qatomic_bootstrap.h diff --git a/src/corelib/arch/qatomic_cxx11.h b/src/corelib/thread/qatomic_cxx11.h similarity index 100% rename from src/corelib/arch/qatomic_cxx11.h rename to src/corelib/thread/qatomic_cxx11.h diff --git a/src/corelib/thread/thread.pri b/src/corelib/thread/thread.pri index e4972a57b3..47775f3fde 100644 --- a/src/corelib/thread/thread.pri +++ b/src/corelib/thread/thread.pri @@ -10,6 +10,8 @@ HEADERS += thread/qmutex.h \ thread/qthreadstorage.h \ thread/qwaitcondition.h \ thread/qatomic.h \ + thread/qatomic_bootstrap.h \ + thread/qatomic_cxx11.h \ thread/qbasicatomic.h \ thread/qgenericatomic.h @@ -67,3 +69,5 @@ win32 { thread/qthread_unix.cpp \ thread/qwaitcondition_unix.cpp } + +qtConfig(std-atomic64): QMAKE_USE += libatomic From 081c001deb75fa38385d3ff8cbbdb4f788529133 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Mon, 5 Mar 2018 19:53:37 -0800 Subject: [PATCH 11/23] QSemaphore: fix deadlock when the woken up thread wakes up another When the thread that got woken up by release() is supposed to release() to wake up another thread, we were deadlocking. This happened because we cleared the bit indicating that there was contention when the first release(). Instead of storing a single bit, we now store the number of threads waiting. Task-number: QTBUG-66875 Change-Id: I72f5230ad59948f784eafffd15193873502ecba4 Reviewed-by: Lars Knoll --- src/corelib/thread/qsemaphore.cpp | 131 ++++++++++++------ .../thread/qsemaphore/tst_qsemaphore.cpp | 69 +++++++++ 2 files changed, 157 insertions(+), 43 deletions(-) diff --git a/src/corelib/thread/qsemaphore.cpp b/src/corelib/thread/qsemaphore.cpp index 012628ef63..f4674fcc1d 100644 --- a/src/corelib/thread/qsemaphore.cpp +++ b/src/corelib/thread/qsemaphore.cpp @@ -1,7 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2017 The Qt Company Ltd. -** Copyright (C) 2017 Intel Corporation. +** Copyright (C) 2018 Intel Corporation. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the QtCore module of the Qt Toolkit. @@ -119,28 +119,37 @@ using namespace QtFutex; acquire tokens. Which ones get woken up is unspecified. If the system has the ability to wake up a precise number of threads, has - Linux's FUTEX_WAKE_OP functionality, and is 64-bit, we'll use the high word - as a copy of the low word, but the sign bit indicating the presence of a - thread waiting for multiple tokens. So when releasing n tokens on those - systems, we tell the kernel to wake up n single-token threads and all of - the multi-token ones, then clear that wait bit. Which threads get woken up - is unspecified, but it's likely single-token threads will get woken up - first. + Linux's FUTEX_WAKE_OP functionality, and is 64-bit, instead of using a + single bit indicating a contended semaphore, we'll store the total number + of waiters in the high word. Additionally, all multi-token waiters will be + waiting on that high word. So when releasing n tokens on those systems, we + tell the kernel to wake up n single-token threads and all of the + multi-token ones. Which threads get woken up is unspecified, but it's + likely single-token threads will get woken up first. */ -static const quint32 futexContendedBit = 1U << 31; + +#if defined(FUTEX_OP) && QT_POINTER_SIZE > 4 +static Q_CONSTEXPR bool futexHasWaiterCount = true; +#else +static Q_CONSTEXPR bool futexHasWaiterCount = false; +#endif + +static const quintptr futexNeedsWakeAllBit = + Q_UINT64_C(1) << (sizeof(quintptr) * CHAR_BIT - 1); static int futexAvailCounter(quintptr v) { // the low 31 bits - return int(v & (futexContendedBit - 1)); + return int(v & 0x7fffffffU); } -static quintptr futexCounterParcel(int n) +static bool futexNeedsWake(quintptr v) { - // replicate the 31 bits if we're on 64-bit - quint64 nn = quint32(n); - nn |= (nn << 32); - return quintptr(nn); + // If we're counting waiters, the number of waiters is stored in the low 31 + // bits of the high word (that is, bits 32-62). If we're not, then we use + // bit 31 to indicate anyone is waiting. Either way, if any bit 31 or above + // is set, there are waiters. + return v >> 31; } static QBasicAtomicInteger *futexLow32(QBasicAtomicInteger *ptr) @@ -152,9 +161,6 @@ static QBasicAtomicInteger *futexLow32(QBasicAtomicInteger *p return result; } -#ifdef FUTEX_OP -// quintptr might be 32bit, in which case we want this to be 0, without implicitly casting. -static const quintptr futexMultiWaiterBit = static_cast(Q_UINT64_C(1) << 63); static QBasicAtomicInteger *futexHigh32(QBasicAtomicInteger *ptr) { auto result = reinterpret_cast *>(ptr); @@ -163,18 +169,21 @@ static QBasicAtomicInteger *futexHigh32(QBasicAtomicInteger * #endif return result; } -#endif -template bool futexSemaphoreTryAcquire(QBasicAtomicInteger &u, int n, int timeout) +template bool +futexSemaphoreTryAcquire_loop(QBasicAtomicInteger &u, quintptr curValue, quintptr nn, int timeout) { QDeadlineTimer timer(IsTimed ? QDeadlineTimer(timeout) : QDeadlineTimer()); - quintptr curValue = u.loadAcquire(); qint64 remainingTime = timeout * Q_INT64_C(1000) * 1000; + int n = int(unsigned(nn)); + + // we're called after one testAndSet, so start by waiting first + goto start_wait; + forever { - int available = futexAvailCounter(curValue); - if (available >= n) { + if (futexAvailCounter(curValue) >= n) { // try to acquire - quintptr newValue = curValue - futexCounterParcel(n); + quintptr newValue = curValue - nn; if (u.testAndSetOrdered(curValue, newValue, curValue)) return true; // succeeded! continue; @@ -184,19 +193,18 @@ template bool futexSemaphoreTryAcquire(QBasicAtomicInteger 1 && sizeof(curValue) >= sizeof(int)) { - bitsToSet |= futexMultiWaiterBit; - ptr = futexHigh32(&u); + if (n > 1 || !futexHasWaiterCount) { + u.fetchAndOrRelaxed(futexNeedsWakeAllBit); + curValue |= futexNeedsWakeAllBit; + if (n > 1 && futexHasWaiterCount) { + ptr = futexHigh32(&u); + //curValue >>= 32; // but this is UB in 32-bit, so roundabout: + curValue = quint64(curValue) >> 32; + } } -#endif - - // the value is the same for either branch - u.fetchAndOrRelaxed(bitsToSet); - curValue |= bitsToSet; if (IsTimed && remainingTime > 0) { bool timedout = !futexWait(*ptr, curValue, remainingTime); @@ -212,6 +220,47 @@ template bool futexSemaphoreTryAcquire(QBasicAtomicInteger bool futexSemaphoreTryAcquire(QBasicAtomicInteger &u, int n, int timeout) +{ + // Try to acquire without waiting (we still loop because the testAndSet + // call can fail). + quintptr curValue = u.loadAcquire(); + while (futexAvailCounter(curValue) >= n) { + // try to acquire + quintptr newValue = curValue - n; + if (u.testAndSetOrdered(curValue, newValue, curValue)) + return true; // succeeded! + } + if (timeout == 0) + return false; + + // we need to wait + quintptr valueToSubtract = unsigned(n); + quintptr oneWaiter = quintptr(Q_UINT64_C(1) << 32); // zero on 32-bit + if (futexHasWaiterCount) { + // increase the waiter count + u.fetchAndAddRelaxed(oneWaiter); + + // We don't use the fetched value from above so futexWait() fails if + // it changed after the testAndSetOrdered above. + curValue += oneWaiter; + + // Also adjust valueToSubtract to subtract oneWaiter when we succeed in + // acquiring. + valueToSubtract += oneWaiter; + } + + if (futexSemaphoreTryAcquire_loop(u, curValue, valueToSubtract, timeout)) + return true; + + if (futexHasWaiterCount) { + // decrement the number of threads waiting + Q_ASSERT(futexHigh32(&u)->load() & 0x7fffffffU); + u.fetchAndSubRelaxed(oneWaiter); + } + return false; +} + class QSemaphorePrivate { public: inline QSemaphorePrivate(int n) : avail(n) { } @@ -289,10 +338,10 @@ void QSemaphore::release(int n) Q_ASSERT_X(n >= 0, "QSemaphore::release", "parameter 'n' must be non-negative"); if (futexAvailable()) { - quintptr prevValue = u.fetchAndAddRelease(futexCounterParcel(n)); - if (prevValue & futexContendedBit) { + quintptr prevValue = u.fetchAndAddRelease(n); + if (futexNeedsWake(prevValue)) { #ifdef FUTEX_OP - if (sizeof(u) == sizeof(int)) { + if (!futexHasWaiterCount) { /* On 32-bit systems, all waiters are waiting on the same address, so we'll wake them all and ask the kernel to clear the high bit. @@ -317,9 +366,6 @@ void QSemaphore::release(int n) the kernel to wake up n single-token waiters and all multi-token waiters (if any), then clear the multi-token wait bit. - That means we must clear the contention bit ourselves. See - below for handling the race. - atomic { int oldval = *upper; *upper = oldval & ~(1 << 31); @@ -332,7 +378,6 @@ void QSemaphore::release(int n) quint32 oparg = 31; quint32 cmp = FUTEX_OP_CMP_LT; quint32 cmparg = 0; - futexLow32(&u)->fetchAndAndRelease(futexContendedBit - 1); futexWakeOp(*futexLow32(&u), n, INT_MAX, *futexHigh32(&u), FUTEX_OP(op, oparg, cmp, cmparg)); } #else @@ -343,7 +388,7 @@ void QSemaphore::release(int n) // its acquisition anyway, so it has to wait; // 2) it did not see the new counter value, in which case its // futexWait will fail. - u.fetchAndAndRelease(futexContendedBit - 1); + u.fetchAndAndRelease(futexNeedsWakeAllBit - 1); futexWakeAll(u); #endif } diff --git a/tests/auto/corelib/thread/qsemaphore/tst_qsemaphore.cpp b/tests/auto/corelib/thread/qsemaphore/tst_qsemaphore.cpp index a67ecc2471..b7134d0454 100644 --- a/tests/auto/corelib/thread/qsemaphore/tst_qsemaphore.cpp +++ b/tests/auto/corelib/thread/qsemaphore/tst_qsemaphore.cpp @@ -37,6 +37,8 @@ class tst_QSemaphore : public QObject Q_OBJECT private slots: void acquire(); + void multiRelease(); + void multiAcquireRelease(); void tryAcquire(); void tryAcquireWithTimeout_data(); void tryAcquireWithTimeout(); @@ -149,6 +151,73 @@ void tst_QSemaphore::acquire() QCOMPARE(semaphore.available(), 0); } +void tst_QSemaphore::multiRelease() +{ + class Thread : public QThread + { + public: + QSemaphore &sem; + Thread(QSemaphore &sem) : sem(sem) {} + + void run() override + { + sem.acquire(); + } + }; + + QSemaphore sem; + QVector threads; + threads.resize(4); + + for (Thread *&t : threads) + t = new Thread(sem); + for (Thread *&t : threads) + t->start(); + + // wait for all threads to reach the sem.acquire() and then + // release them all + QTest::qSleep(1); + sem.release(threads.size()); + + for (Thread *&t : threads) + t->wait(); + qDeleteAll(threads); +} + +void tst_QSemaphore::multiAcquireRelease() +{ + class Thread : public QThread + { + public: + QSemaphore &sem; + Thread(QSemaphore &sem) : sem(sem) {} + + void run() override + { + sem.acquire(); + sem.release(); + } + }; + + QSemaphore sem; + QVector threads; + threads.resize(4); + + for (Thread *&t : threads) + t = new Thread(sem); + for (Thread *&t : threads) + t->start(); + + // wait for all threads to reach the sem.acquire() and then + // release them all + QTest::qSleep(1); + sem.release(); + + for (Thread *&t : threads) + t->wait(); + qDeleteAll(threads); +} + void tst_QSemaphore::tryAcquire() { QSemaphore semaphore; From dabc76de80e3b433a1a8e2354ca78a34389ea9f8 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Sat, 10 Mar 2018 11:26:04 -0800 Subject: [PATCH 12/23] QSemaphore: add minor optimization for 64-bit Linux systems Since we won't use the high bit of the low 32-bit word at all, we don't need the AND with 0x7fffffff either. Just cast. Change-Id: I72f5230ad59948f784eafffd151aa5a7dee995db Reviewed-by: Olivier Goffart (Woboq GmbH) --- src/corelib/thread/qsemaphore.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/corelib/thread/qsemaphore.cpp b/src/corelib/thread/qsemaphore.cpp index f4674fcc1d..c2e4d7d9d1 100644 --- a/src/corelib/thread/qsemaphore.cpp +++ b/src/corelib/thread/qsemaphore.cpp @@ -140,6 +140,13 @@ static const quintptr futexNeedsWakeAllBit = static int futexAvailCounter(quintptr v) { // the low 31 bits + if (futexHasWaiterCount) { + // the high bit of the low word isn't used + Q_ASSERT((v & 0x80000000U) == 0); + + // so we can be a little faster + return int(unsigned(v)); + } return int(v & 0x7fffffffU); } From 323b00e38c38cc864d136d70befd106400c50163 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Sat, 10 Feb 2018 10:08:16 -0800 Subject: [PATCH 13/23] QSharedDataPointer: use swap-and-move in the move constructor This makes the pointer that was in the moved-into object be destroyed before the return of this function (if the reference count was 1), instead of letting it live in the moved-from object. Task-number: QTBUG-66322 Change-Id: I3debfc11127e4516b505fffd151209292bd3adaa Reviewed-by: Lars Knoll --- src/corelib/tools/qshareddata.h | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/corelib/tools/qshareddata.h b/src/corelib/tools/qshareddata.h index dbf0907a0f..780f2331a8 100644 --- a/src/corelib/tools/qshareddata.h +++ b/src/corelib/tools/qshareddata.h @@ -115,7 +115,11 @@ public: #ifdef Q_COMPILER_RVALUE_REFS QSharedDataPointer(QSharedDataPointer &&o) Q_DECL_NOTHROW : d(o.d) { o.d = nullptr; } inline QSharedDataPointer &operator=(QSharedDataPointer &&other) Q_DECL_NOTHROW - { qSwap(d, other.d); return *this; } + { + QSharedDataPointer moved(std::move(other)); + swap(moved); + return *this; + } #endif inline bool operator!() const { return !d; } @@ -204,7 +208,11 @@ public: #ifdef Q_COMPILER_RVALUE_REFS inline QExplicitlySharedDataPointer(QExplicitlySharedDataPointer &&o) Q_DECL_NOTHROW : d(o.d) { o.d = nullptr; } inline QExplicitlySharedDataPointer &operator=(QExplicitlySharedDataPointer &&other) Q_DECL_NOTHROW - { qSwap(d, other.d); return *this; } + { + QExplicitlySharedDataPointer moved(std::move(other)); + swap(moved); + return *this; + } #endif inline bool operator!() const { return !d; } From 1cb439dc948d6e610da49331184f0a660ef57b4e Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Mon, 19 Mar 2018 09:08:01 +0100 Subject: [PATCH 14/23] Windows QPA: Fix potential crash in leave event handling Add a check for window != nullptr. Amends af5c8d04fb0c9ddda58925e4862e857c78a5e563. Task-number: QTBUG-67101 Task-number: QTBUG-57864 Change-Id: I2bbbbe514fc494fd569d0932d508c53c0544f665 Reviewed-by: Oliver Wolff --- src/plugins/platforms/windows/qwindowscontext.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/platforms/windows/qwindowscontext.cpp b/src/plugins/platforms/windows/qwindowscontext.cpp index 20d6e6e8d4..072012064f 100644 --- a/src/plugins/platforms/windows/qwindowscontext.cpp +++ b/src/plugins/platforms/windows/qwindowscontext.cpp @@ -1083,7 +1083,7 @@ bool QWindowsContext::windowsProc(HWND hwnd, UINT message, case QtWindows::LeaveEvent: { QWindow *window = platformWindow->window(); - while (window->flags() & Qt::WindowTransparentForInput) + while (window && (window->flags() & Qt::WindowTransparentForInput)) window = window->parent(); if (!window) return false; From 0ffb7c419a6d00fa8db00c811968d45ba5193856 Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Thu, 15 Mar 2018 16:54:25 +0100 Subject: [PATCH 15/23] Fix CONFIG+=qtquickcompiler and immediate resources with shadow builds MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Generated files should be added to RESOURCES with an absolute path. Task-number: QTBUG-67011 Change-Id: Ief82b576824df9abd0901970f076e30dfe57b7d0 Reviewed-by: Tor Arne Vestbø Reviewed-by: Oswald Buddenhagen --- mkspecs/features/resources.prf | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mkspecs/features/resources.prf b/mkspecs/features/resources.prf index 3f5979202c..ff45446219 100644 --- a/mkspecs/features/resources.prf +++ b/mkspecs/features/resources.prf @@ -33,7 +33,7 @@ for(resource, RESOURCES) { next() } - resource_file = $$RCC_DIR/qmake_$${resource}.qrc + resource_file = $$absolute_path($$RCC_DIR/qmake_$${resource}.qrc, $$OUT_PWD) isEmpty(BUILDS)|build_pass { # Collection of files, generate qrc file @@ -64,7 +64,7 @@ for(resource, RESOURCES) { "" \ "" - !write_file($$absolute_path($$resource_file, $$OUT_PWD), resource_file_content): \ + !write_file($$resource_file, resource_file_content): \ error() } From 91a52fc6a0a8b0fc40285967e5da05ea72e1d75b Mon Sep 17 00:00:00 2001 From: Mikhail Svetkin Date: Fri, 16 Mar 2018 17:02:21 +0100 Subject: [PATCH 16/23] widgets: Add a QT_CONFIG(style_stylesheet) guard for isWindowsStyle in QDockWidget Change-Id: Id471b91a415f1a677ced6022bdd05b7e1b72aad2 Reviewed-by: Richard Moe Gustavsen --- src/widgets/widgets/qdockwidget.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/widgets/widgets/qdockwidget.cpp b/src/widgets/widgets/qdockwidget.cpp index e17c2c1f4c..84cb78a474 100644 --- a/src/widgets/widgets/qdockwidget.cpp +++ b/src/widgets/widgets/qdockwidget.cpp @@ -160,9 +160,13 @@ bool QDockWidgetTitleButton::event(QEvent *event) static inline bool isWindowsStyle(const QStyle *style) { // Note: QStyleSheetStyle inherits QWindowsStyle - const QStyle *effectiveStyle = style->inherits("QStyleSheetStyle") - ? static_cast(style)->baseStyle() - : style; + const QStyle *effectiveStyle = style; + +#if QT_CONFIG(style_stylesheet) + if (style->inherits("QStyleSheetStyle")) + effectiveStyle = static_cast(style)->baseStyle(); +#endif + return effectiveStyle->inherits("QWindowsStyle"); } From 83c01a59098762fd2f1a75fff1b1d19b3c2c9f99 Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Wed, 7 Mar 2018 12:17:46 +0100 Subject: [PATCH 17/23] Fix display recognition for IBUS The parsing of the DISPLAY environment variable was wrong, and only worked by accident for DISPLAY=':[0-9]'. Task-number: QTBUG-62068 Change-Id: I6860e3907c9b1ad6e538d1b5d08628cd306b4aa1 Reviewed-by: Alexander Volkov Reviewed-by: Eskil Abrahamsen Blomfeldt --- .../platforminputcontexts/ibus/qibusplatforminputcontext.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/platforminputcontexts/ibus/qibusplatforminputcontext.cpp b/src/plugins/platforminputcontexts/ibus/qibusplatforminputcontext.cpp index 76f42d764d..02f92bbb18 100644 --- a/src/plugins/platforminputcontexts/ibus/qibusplatforminputcontext.cpp +++ b/src/plugins/platforminputcontexts/ibus/qibusplatforminputcontext.cpp @@ -647,7 +647,7 @@ QString QIBusPlatformInputContextPrivate::getSocketPath() if (pos2 > 0) displayNumber = display.mid(pos, pos2 - pos); else - displayNumber = display.right(pos); + displayNumber = display.mid(pos); if (debug) qDebug() << "host=" << host << "displayNumber" << displayNumber; From f4b6ea2ae2619bd4f7f7ef2d5255341d8da5726f Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Mon, 19 Mar 2018 15:40:31 +0100 Subject: [PATCH 18/23] Fix infinite recursion on stack trying load empty glyhs Loading empty glyphs in some fonts would cause the application to crash with an infinite recusion on the stack between qfontengine and qfontengine_ft: 12 0x00007ffff6954395 in QFontEngine::alphaMapForGlyph (this=0x7fb0c0, glyph=50, subPixelPosition=..., t=...) at text/qfontengine.cpp:877 13 0x00007fffee7d104e in QFontEngineFT::alphaMapForGlyph (this=0x7fb0c0, g=50, subPixelPosition=..., t=...) at freetype/qfontengine_ft.cpp:2096 14 0x00007fffee7d0ea8 in QFontEngineFT::alphaMapForGlyph (this=0x7fb0c0, g=50, subPixelPosition=...) at freetype/qfontengine_ft.cpp:2078 15 0x00007ffff6954395 in QFontEngine::alphaMapForGlyph (this=0x7fb0c0, glyph=50, subPixelPosition=..., t=...) at text/qfontengine.cpp:877 16 0x00007fffee7d104e in QFontEngineFT::alphaMapForGlyph (this=0x7fb0c0, g=50, subPixelPosition=..., t=...) at freetype/qfontengine_ft.cpp:2096 17 0x00007fffee7d0ea8 in QFontEngineFT::alphaMapForGlyph (this=0x7fb0c0, g=50, subPixelPosition=...) at freetype/qfontengine_ft.cpp:2078 18 0x00007ffff6954395 in QFontEngine::alphaMapForGlyph (this=0x7fb0c0, glyph=50, subPixelPosition=..., t=...) at text/qfontengine.cpp:877 ... Fix this by trusting the freetype fontengine that it could load the glyph, as the base class anyway can't do better. Task-number: QTBUG-62331 Task-number: QTBUG-66617 Change-Id: I6c7c24d24ec0f71a66fa519c04a336f276e418f6 Reviewed-by: Simon Hausmann Reviewed-by: Eskil Abrahamsen Blomfeldt --- .../fontdatabases/freetype/qfontengine_ft.cpp | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/platformsupport/fontdatabases/freetype/qfontengine_ft.cpp b/src/platformsupport/fontdatabases/freetype/qfontengine_ft.cpp index cc0246b64a..dabe2bc09e 100644 --- a/src/platformsupport/fontdatabases/freetype/qfontengine_ft.cpp +++ b/src/platformsupport/fontdatabases/freetype/qfontengine_ft.cpp @@ -2090,10 +2090,7 @@ QImage QFontEngineFT::alphaMapForGlyph(glyph_t g, QFixed subPixelPosition, const if (!cacheEnabled && glyph != &emptyGlyph) delete glyph; - if (!img.isNull()) - return img; - - return QFontEngine::alphaMapForGlyph(g, subPixelPosition, t); + return img; } QImage QFontEngineFT::alphaRGBMapForGlyph(glyph_t g, QFixed subPixelPosition, const QTransform &t) From dd74f5d347d0a5a21527142f85114374e2d90646 Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Fri, 9 Feb 2018 15:21:04 +0100 Subject: [PATCH 19/23] Gui: Properly use the standarditemmodel feature Require it in the headers and exclude the implementation from the build if disabled. Change-Id: Ida3303f8595f47b469e92d68e8bccc3957d943b6 Reviewed-by: Oswald Buddenhagen --- src/gui/itemmodels/itemmodels.pri | 2 ++ src/gui/itemmodels/qstandarditemmodel.cpp | 4 ---- src/gui/itemmodels/qstandarditemmodel.h | 7 ++----- src/gui/itemmodels/qstandarditemmodel_p.h | 6 ++---- 4 files changed, 6 insertions(+), 13 deletions(-) diff --git a/src/gui/itemmodels/itemmodels.pri b/src/gui/itemmodels/itemmodels.pri index 65bcd7c1ba..cab0594174 100644 --- a/src/gui/itemmodels/itemmodels.pri +++ b/src/gui/itemmodels/itemmodels.pri @@ -1,3 +1,5 @@ +!qtConfig(standarditemmodel): return() + HEADERS += \ itemmodels/qstandarditemmodel.h \ itemmodels/qstandarditemmodel_p.h \ diff --git a/src/gui/itemmodels/qstandarditemmodel.cpp b/src/gui/itemmodels/qstandarditemmodel.cpp index 050c9a662b..c340bddc51 100644 --- a/src/gui/itemmodels/qstandarditemmodel.cpp +++ b/src/gui/itemmodels/qstandarditemmodel.cpp @@ -39,8 +39,6 @@ #include "qstandarditemmodel.h" -#ifndef QT_NO_STANDARDITEMMODEL - #include #include #include @@ -3259,5 +3257,3 @@ bool QStandardItemModel::dropMimeData(const QMimeData *data, Qt::DropAction acti QT_END_NAMESPACE #include "moc_qstandarditemmodel.cpp" - -#endif // QT_NO_STANDARDITEMMODEL diff --git a/src/gui/itemmodels/qstandarditemmodel.h b/src/gui/itemmodels/qstandarditemmodel.h index d8f06b629a..d1c04d6b51 100644 --- a/src/gui/itemmodels/qstandarditemmodel.h +++ b/src/gui/itemmodels/qstandarditemmodel.h @@ -49,11 +49,10 @@ #include #endif +QT_REQUIRE_CONFIG(standarditemmodel); + QT_BEGIN_NAMESPACE - -#ifndef QT_NO_STANDARDITEMMODEL - template class QList; class QStandardItemModel; @@ -454,8 +453,6 @@ Q_GUI_EXPORT QDataStream &operator>>(QDataStream &in, QStandardItem &item); Q_GUI_EXPORT QDataStream &operator<<(QDataStream &out, const QStandardItem &item); #endif -#endif // QT_NO_STANDARDITEMMODEL - QT_END_NAMESPACE #endif //QSTANDARDITEMMODEL_H diff --git a/src/gui/itemmodels/qstandarditemmodel_p.h b/src/gui/itemmodels/qstandarditemmodel_p.h index bd28ec3029..d3ff2787a5 100644 --- a/src/gui/itemmodels/qstandarditemmodel_p.h +++ b/src/gui/itemmodels/qstandarditemmodel_p.h @@ -54,8 +54,6 @@ #include #include "private/qabstractitemmodel_p.h" -#ifndef QT_NO_STANDARDITEMMODEL - #include #include #include @@ -63,6 +61,8 @@ #include #include +QT_REQUIRE_CONFIG(standarditemmodel); + QT_BEGIN_NAMESPACE class QStandardItemData @@ -224,6 +224,4 @@ public: QT_END_NAMESPACE -#endif // QT_NO_STANDARDITEMMODEL - #endif // QSTANDARDITEMMODEL_P_H From 5a4787dca01c302dd462a76222dfbf28c8951a8d Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Fri, 9 Feb 2018 14:29:21 +0100 Subject: [PATCH 20/23] Modernize the "regularexpression" feature Use QT_CONFIG(regularexpression), disentangle it from QT_BOOTSTRAPPED, switch it off in the bootstrap build, remove the #ifdefs from qregularexpression.{h|cpp}, and add QT_REQUIRE_CONFIG(regularexpression) to the header. qregularexpression.{h|cpp} are already correctly excluded in tools.pri if !qtConfig(regularexpression). Change-Id: I21de154a6a118b76f99003d3acb72ac1e220d302 Reviewed-by: Oswald Buddenhagen --- src/corelib/global/qlogging.cpp | 4 +-- src/corelib/io/qstandardpaths_unix.cpp | 2 ++ src/corelib/kernel/qmetatype.cpp | 17 ++++++----- src/corelib/kernel/qmetatype_p.h | 2 +- src/corelib/kernel/qobject.cpp | 8 +++-- src/corelib/kernel/qobject.h | 6 ++-- src/corelib/kernel/qvariant.cpp | 16 +++++----- src/corelib/kernel/qvariant.h | 16 +++++----- src/corelib/tools/qregularexpression.cpp | 4 --- src/corelib/tools/qregularexpression.h | 6 ++-- src/corelib/tools/qstring.cpp | 30 ++++++++----------- src/corelib/tools/qstring.h | 8 ++--- src/corelib/tools/qstringlist.cpp | 22 ++++++-------- src/corelib/tools/qstringlist.h | 24 +++++---------- src/gui/opengl/qopenglshaderprogram.cpp | 1 - src/gui/text/qtextdocument.cpp | 6 ++-- src/gui/text/qtextdocument.h | 2 +- src/gui/util/qvalidator.cpp | 4 +-- src/gui/util/qvalidator.h | 8 +++-- .../windows/qwindowsfontdatabase_ft.cpp | 2 +- .../eglfs/api/qeglfsdeviceintegration.cpp | 2 +- src/plugins/platformthemes/platformthemes.pro | 2 +- src/plugins/sqldrivers/sqlite/qsql_sqlite.cpp | 10 +++---- src/testlib/qtestcase.cpp | 4 +-- src/testlib/qtestcase.h | 2 +- src/testlib/qtestlog.cpp | 10 ++++--- src/widgets/dialogs/qcolordialog.cpp | 2 +- tests/shared/emulationdetector.h | 4 +-- 28 files changed, 107 insertions(+), 117 deletions(-) diff --git a/src/corelib/global/qlogging.cpp b/src/corelib/global/qlogging.cpp index 99c57c3b7a..17002c4231 100644 --- a/src/corelib/global/qlogging.cpp +++ b/src/corelib/global/qlogging.cpp @@ -91,8 +91,7 @@ # include "private/qcore_unix_p.h" #endif -#ifndef QT_BOOTSTRAPPED -#if !defined QT_NO_REGULAREXPRESSION +#if QT_CONFIG(regularexpression) # ifdef __UCLIBC__ # if __UCLIBC_HAS_BACKTRACE__ # define QLOGGING_HAVE_BACKTRACE @@ -106,6 +105,7 @@ extern char *__progname; #endif +#ifndef QT_BOOTSTRAPPED #if defined(Q_OS_LINUX) && (defined(__GLIBC__) || QT_HAS_INCLUDE()) # include diff --git a/src/corelib/io/qstandardpaths_unix.cpp b/src/corelib/io/qstandardpaths_unix.cpp index e49edd9a40..748ce67dac 100644 --- a/src/corelib/io/qstandardpaths_unix.cpp +++ b/src/corelib/io/qstandardpaths_unix.cpp @@ -42,7 +42,9 @@ #include #include #include +#if QT_CONFIG(regularexpression) #include +#endif #include #include #include diff --git a/src/corelib/kernel/qmetatype.cpp b/src/corelib/kernel/qmetatype.cpp index 5abc2ebd70..518381712a 100644 --- a/src/corelib/kernel/qmetatype.cpp +++ b/src/corelib/kernel/qmetatype.cpp @@ -53,12 +53,15 @@ #include "qdatastream.h" #include "qmetatypeswitcher_p.h" +#if QT_CONFIG(regularexpression) +# include "qregularexpression.h" +#endif + #ifndef QT_BOOTSTRAPPED # include "qbitarray.h" # include "qurl.h" # include "qvariant.h" # include "qabstractitemmodel.h" -# include "qregularexpression.h" # include "qjsonvalue.h" # include "qjsonobject.h" # include "qjsonarray.h" @@ -1481,12 +1484,12 @@ bool QMetaType::save(QDataStream &stream, int type, const void *data) stream << *static_cast(data); break; #endif -#ifndef QT_BOOTSTRAPPED -#ifndef QT_NO_REGULAREXPRESSION +#if QT_CONFIG(regularexpression) case QMetaType::QRegularExpression: stream << *static_cast(data); break; -#endif // QT_NO_REGULAREXPRESSION +#endif // QT_CONFIG(regularexpression) +#ifndef QT_BOOTSTRAPPED case QMetaType::QEasingCurve: stream << *static_cast(data); break; @@ -1711,12 +1714,12 @@ bool QMetaType::load(QDataStream &stream, int type, void *data) stream >> *static_cast< NS(QRegExp)*>(data); break; #endif -#ifndef QT_BOOTSTRAPPED -#ifndef QT_NO_REGULAREXPRESSION +#if QT_CONFIG(regularexpression) case QMetaType::QRegularExpression: stream >> *static_cast< NS(QRegularExpression)*>(data); break; -#endif // QT_NO_REGULAREXPRESSION +#endif // QT_CONFIG(regularexpression) +#ifndef QT_BOOTSTRAPPED case QMetaType::QEasingCurve: stream >> *static_cast< NS(QEasingCurve)*>(data); break; diff --git a/src/corelib/kernel/qmetatype_p.h b/src/corelib/kernel/qmetatype_p.h index 6f1334d082..0bf6bcb922 100644 --- a/src/corelib/kernel/qmetatype_p.h +++ b/src/corelib/kernel/qmetatype_p.h @@ -219,7 +219,7 @@ template<> struct TypeDefinition { static const bool IsAvailable = fals #ifdef QT_NO_REGEXP template<> struct TypeDefinition { static const bool IsAvailable = false; }; #endif -#if defined(QT_BOOTSTRAPPED) || defined(QT_NO_REGULAREXPRESSION) +#if !QT_CONFIG(regularexpression) template<> struct TypeDefinition { static const bool IsAvailable = false; }; #endif #ifdef QT_NO_SHORTCUT diff --git a/src/corelib/kernel/qobject.cpp b/src/corelib/kernel/qobject.cpp index 9e1c3a50cb..dcc1bb5814 100644 --- a/src/corelib/kernel/qobject.cpp +++ b/src/corelib/kernel/qobject.cpp @@ -50,7 +50,9 @@ #include "qvariant.h" #include "qmetaobject.h" #include -#include +#if QT_CONFIG(regularexpression) +# include +#endif #include #include #include @@ -1921,7 +1923,7 @@ void qt_qFindChildren_helper(const QObject *parent, const QRegExp &re, } #endif // QT_NO_REGEXP -#ifndef QT_NO_REGULAREXPRESSION +#if QT_CONFIG(regularexpression) /*! \internal */ @@ -1943,7 +1945,7 @@ void qt_qFindChildren_helper(const QObject *parent, const QRegularExpression &re qt_qFindChildren_helper(obj, re, mo, list, options); } } -#endif // QT_NO_REGULAREXPRESSION +#endif // QT_CONFIG(regularexpression) /*! \internal diff --git a/src/corelib/kernel/qobject.h b/src/corelib/kernel/qobject.h index 0e608a3208..aac9bcdee9 100644 --- a/src/corelib/kernel/qobject.h +++ b/src/corelib/kernel/qobject.h @@ -74,7 +74,7 @@ class QWidget; #ifndef QT_NO_REGEXP class QRegExp; #endif -#ifndef QT_NO_REGULAREXPRESSION +#if QT_CONFIG(regularexpression) class QRegularExpression; #endif #ifndef QT_NO_USERDATA @@ -187,7 +187,7 @@ public: } #endif -#ifndef QT_NO_REGULAREXPRESSION +#if QT_CONFIG(regularexpression) template inline QList findChildren(const QRegularExpression &re, Qt::FindChildOptions options = Qt::FindChildrenRecursively) const { @@ -197,7 +197,7 @@ public: reinterpret_cast *>(&list), options); return list; } -#endif +#endif // QT_CONFIG(regularexpression) inline const QObjectList &children() const { return d_ptr->children; } diff --git a/src/corelib/kernel/qvariant.cpp b/src/corelib/kernel/qvariant.cpp index f77831c703..c3c36e05d7 100644 --- a/src/corelib/kernel/qvariant.cpp +++ b/src/corelib/kernel/qvariant.cpp @@ -48,7 +48,9 @@ #include "qdatetime.h" #include "qeasingcurve.h" #include "qlist.h" +#if QT_CONFIG(regularexpression) #include "qregularexpression.h" +#endif #include "qstring.h" #include "qstringlist.h" #include "qurl.h" @@ -1941,12 +1943,12 @@ QVariant::QVariant(const QRegExp ®Exp) : d(RegExp) { v_construct(&d, regExp); } #endif // QT_NO_REGEXP -#ifndef QT_BOOTSTRAPPED -#ifndef QT_NO_REGULAREXPRESSION +#if QT_CONFIG(regularexpression) QVariant::QVariant(const QRegularExpression &re) : d(RegularExpression) { v_construct(&d, re); } -#endif +#endif // QT_CONFIG(regularexpression) +#ifndef QT_BOOTSTRAPPED QVariant::QVariant(const QUuid &uuid) : d(Uuid) { v_construct(&d, uuid); } @@ -2650,7 +2652,7 @@ QRegExp QVariant::toRegExp() const } #endif -#ifndef QT_BOOTSTRAPPED +#if QT_CONFIG(regularexpression) /*! \fn QRegularExpression QVariant::toRegularExpression() const \since 5.0 @@ -2660,13 +2662,13 @@ QRegExp QVariant::toRegExp() const \sa canConvert(), convert() */ -#ifndef QT_NO_REGULAREXPRESSION QRegularExpression QVariant::toRegularExpression() const { return qVariantToHelper(d, handlerManager); } -#endif // QT_NO_REGULAREXPRESSION +#endif // QT_CONFIG(regularexpression) +#ifndef QT_BOOTSTRAPPED /*! \since 5.0 @@ -2758,7 +2760,7 @@ QJsonDocument QVariant::toJsonDocument() const { return qVariantToHelper(d, handlerManager); } -#endif +#endif // QT_BOOTSTRAPPED /*! \fn QChar QVariant::toChar() const diff --git a/src/corelib/kernel/qvariant.h b/src/corelib/kernel/qvariant.h index 7ce4e1a4d8..361768ef00 100644 --- a/src/corelib/kernel/qvariant.h +++ b/src/corelib/kernel/qvariant.h @@ -81,9 +81,9 @@ class QRectF; #ifndef QT_NO_REGEXP class QRegExp; #endif // QT_NO_REGEXP -#ifndef QT_NO_REGULAREXPRESSION +#if QT_CONFIG(regularexpression) class QRegularExpression; -#endif // QT_NO_REGULAREXPRESSION +#endif // QT_CONFIG(regularexpression) class QTextFormat; class QTextLength; class QUrl; @@ -248,10 +248,10 @@ class Q_CORE_EXPORT QVariant #ifndef QT_NO_REGEXP QVariant(const QRegExp ®Exp); #endif // QT_NO_REGEXP -#ifndef QT_BOOTSTRAPPED -#ifndef QT_NO_REGULAREXPRESSION +#if QT_CONFIG(regularexpression) QVariant(const QRegularExpression &re); -#endif // QT_NO_REGULAREXPRESSION +#endif // QT_CONFIG(regularexpression) +#ifndef QT_BOOTSTRAPPED QVariant(const QUrl &url); QVariant(const QEasingCurve &easing); QVariant(const QUuid &uuid); @@ -322,10 +322,10 @@ class Q_CORE_EXPORT QVariant #ifndef QT_NO_REGEXP QRegExp toRegExp() const; #endif // QT_NO_REGEXP -#ifndef QT_BOOTSTRAPPED -#ifndef QT_NO_REGULAREXPRESSION +#if QT_CONFIG(regularexpression) QRegularExpression toRegularExpression() const; -#endif // QT_NO_REGULAREXPRESSION +#endif // QT_CONFIG(regularexpression) +#ifndef QT_BOOTSTRAPPED QUrl toUrl() const; QEasingCurve toEasingCurve() const; QUuid toUuid() const; diff --git a/src/corelib/tools/qregularexpression.cpp b/src/corelib/tools/qregularexpression.cpp index 86bc99716d..13eff07c04 100644 --- a/src/corelib/tools/qregularexpression.cpp +++ b/src/corelib/tools/qregularexpression.cpp @@ -41,8 +41,6 @@ #include "qregularexpression.h" -#ifndef QT_NO_REGULAREXPRESSION - #include #include #include @@ -2912,5 +2910,3 @@ static const char *pcreCompileErrorCodes[] = #endif // #if 0 QT_END_NAMESPACE - -#endif // QT_NO_REGULAREXPRESSION diff --git a/src/corelib/tools/qregularexpression.h b/src/corelib/tools/qregularexpression.h index 050841e70e..398fc9ec9c 100644 --- a/src/corelib/tools/qregularexpression.h +++ b/src/corelib/tools/qregularexpression.h @@ -43,13 +43,13 @@ #include -#ifndef QT_NO_REGULAREXPRESSION - #include #include #include #include +QT_REQUIRE_CONFIG(regularexpression); + QT_BEGIN_NAMESPACE class QStringView; @@ -277,6 +277,4 @@ Q_DECLARE_SHARED(QRegularExpressionMatchIterator) QT_END_NAMESPACE -#endif // QT_NO_REGULAREXPRESSION - #endif // QREGULAREXPRESSION_H diff --git a/src/corelib/tools/qstring.cpp b/src/corelib/tools/qstring.cpp index b56ad34546..f6360f5504 100644 --- a/src/corelib/tools/qstring.cpp +++ b/src/corelib/tools/qstring.cpp @@ -40,7 +40,9 @@ #include "qstringlist.h" #include "qregexp.h" +#if QT_CONFIG(regularexpression) #include "qregularexpression.h" +#endif #include "qunicodetables_p.h" #ifndef QT_NO_TEXTCODEC #include @@ -3695,7 +3697,7 @@ int QString::lastIndexOf(const QStringRef &str, int from, Qt::CaseSensitivity cs } -#if !(defined(QT_NO_REGEXP) && defined(QT_NO_REGULAREXPRESSION)) +#if !(defined(QT_NO_REGEXP) && !QT_CONFIG(regularexpression)) struct QStringCapture { int pos; @@ -3862,8 +3864,7 @@ QString& QString::replace(const QRegExp &rx, const QString &after) } #endif -#ifndef QT_NO_REGULAREXPRESSION -#ifndef QT_BOOTSTRAPPED +#if QT_CONFIG(regularexpression) /*! \overload replace() \since 5.0 @@ -3991,8 +3992,7 @@ QString &QString::replace(const QRegularExpression &re, const QString &after) return *this; } -#endif // QT_BOOTSTRAPPED -#endif // QT_NO_REGULAREXPRESSION +#endif // QT_CONFIG(regularexpression) /*! Returns the number of (potentially overlapping) occurrences of @@ -4207,8 +4207,7 @@ int QString::count(const QRegExp& rx) const } #endif // QT_NO_REGEXP -#ifndef QT_NO_REGULAREXPRESSION -#ifndef QT_BOOTSTRAPPED +#if QT_CONFIG(regularexpression) /*! \overload indexOf() \since 5.0 @@ -4386,8 +4385,7 @@ int QString::count(const QRegularExpression &re) const } return count; } -#endif // QT_BOOTSTRAPPED -#endif // QT_NO_REGULAREXPRESSION +#endif // QT_CONFIG(regularexpression) /*! \fn int QString::count() const @@ -4509,7 +4507,7 @@ QString QString::section(const QString &sep, int start, int end, SectionFlags fl return ret; } -#if !(defined(QT_NO_REGEXP) && defined(QT_NO_REGULAREXPRESSION)) +#if !(defined(QT_NO_REGEXP) && !QT_CONFIG(regularexpression)) class qt_section_chunk { public: qt_section_chunk() {} @@ -4619,8 +4617,7 @@ QString QString::section(const QRegExp ®, int start, int end, SectionFlags fl } #endif -#ifndef QT_NO_REGULAREXPRESSION -#ifndef QT_BOOTSTRAPPED +#if QT_CONFIG(regularexpression) /*! \overload section() \since 5.0 @@ -4664,8 +4661,7 @@ QString QString::section(const QRegularExpression &re, int start, int end, Secti return extractSections(sections, start, end, flags); } -#endif // QT_BOOTSTRAPPED -#endif // QT_NO_REGULAREXPRESSION +#endif // QT_CONFIG(regularexpression) /*! Returns a substring that contains the \a n leftmost characters @@ -7586,8 +7582,7 @@ QVector QString::splitRef(const QRegExp &rx, SplitBehavior behavior) } #endif -#ifndef QT_NO_REGULAREXPRESSION -#ifndef QT_BOOTSTRAPPED +#if QT_CONFIG(regularexpression) namespace { template static ResultList splitString(const QString &source, MidMethod mid, const QRegularExpression &re, @@ -7667,8 +7662,7 @@ QVector QString::splitRef(const QRegularExpression &re, SplitBehavio { return splitString >(*this, &QString::midRef, re, behavior); } -#endif // QT_BOOTSTRAPPED -#endif // QT_NO_REGULAREXPRESSION +#endif // QT_CONFIG(regularexpression) /*! \enum QString::NormalizationForm diff --git a/src/corelib/tools/qstring.h b/src/corelib/tools/qstring.h index b8f4d49831..f27f7efa2b 100644 --- a/src/corelib/tools/qstring.h +++ b/src/corelib/tools/qstring.h @@ -353,7 +353,7 @@ public: inline bool contains(QRegExp &rx) const { return indexOf(rx) != -1; } #endif -#ifndef QT_NO_REGULAREXPRESSION +#if QT_CONFIG(regularexpression) int indexOf(const QRegularExpression &re, int from = 0) const; int indexOf(const QRegularExpression &re, int from, QRegularExpressionMatch *rmatch) const; // ### Qt 6: merge overloads int lastIndexOf(const QRegularExpression &re, int from = -1) const; @@ -377,7 +377,7 @@ public: #ifndef QT_NO_REGEXP QString section(const QRegExp ®, int start, int end = -1, SectionFlags flags = SectionDefault) const; #endif -#ifndef QT_NO_REGULAREXPRESSION +#if QT_CONFIG(regularexpression) QString section(const QRegularExpression &re, int start, int end = -1, SectionFlags flags = SectionDefault) const; #endif Q_REQUIRED_RESULT QString left(int n) const; @@ -502,7 +502,7 @@ public: inline QString &remove(const QRegExp &rx) { return replace(rx, QString()); } #endif -#ifndef QT_NO_REGULAREXPRESSION +#if QT_CONFIG(regularexpression) QString &replace(const QRegularExpression &re, const QString &after); inline QString &remove(const QRegularExpression &re) { return replace(re, QString()); } @@ -522,7 +522,7 @@ public: Q_REQUIRED_RESULT QStringList split(const QRegExp &sep, SplitBehavior behavior = KeepEmptyParts) const; Q_REQUIRED_RESULT QVector splitRef(const QRegExp &sep, SplitBehavior behavior = KeepEmptyParts) const; #endif -#ifndef QT_NO_REGULAREXPRESSION +#if QT_CONFIG(regularexpression) Q_REQUIRED_RESULT QStringList split(const QRegularExpression &sep, SplitBehavior behavior = KeepEmptyParts) const; Q_REQUIRED_RESULT QVector splitRef(const QRegularExpression &sep, SplitBehavior behavior = KeepEmptyParts) const; #endif diff --git a/src/corelib/tools/qstringlist.cpp b/src/corelib/tools/qstringlist.cpp index 17f6bd8539..d10d9ad9d0 100644 --- a/src/corelib/tools/qstringlist.cpp +++ b/src/corelib/tools/qstringlist.cpp @@ -39,7 +39,9 @@ #include #include -#include +#if QT_CONFIG(regularexpression) +# include +#endif #include @@ -361,8 +363,7 @@ QStringList QtPrivate::QStringList_filter(const QStringList *that, const QRegExp } #endif -#ifndef QT_BOOTSTRAPPED -#ifndef QT_NO_REGULAREXPRESSION +#if QT_CONFIG(regularexpression) /*! \fn QStringList QStringList::filter(const QRegularExpression &re) const \overload @@ -380,8 +381,7 @@ QStringList QtPrivate::QStringList_filter(const QStringList *that, const QRegula } return res; } -#endif // QT_NO_REGULAREXPRESSION -#endif // QT_BOOTSTRAPPED +#endif // QT_CONFIG(regularexpression) /*! \fn QStringList &QStringList::replaceInStrings(const QString &before, const QString &after, Qt::CaseSensitivity cs) @@ -436,8 +436,7 @@ void QtPrivate::QStringList_replaceInStrings(QStringList *that, const QRegExp &r } #endif -#ifndef QT_BOOTSTRAPPED -#ifndef QT_NO_REGULAREXPRESSION +#if QT_CONFIG(regularexpression) /*! \fn QStringList &QStringList::replaceInStrings(const QRegularExpression &re, const QString &after) \overload @@ -466,8 +465,7 @@ void QtPrivate::QStringList_replaceInStrings(QStringList *that, const QRegularEx for (int i = 0; i < that->size(); ++i) (*that)[i].replace(re, after); } -#endif // QT_NO_REGULAREXPRESSION -#endif // QT_BOOTSTRAPPED +#endif // QT_CONFIG(regularexpression) static int accumulatedSize(const QStringList &list, int seplen) { @@ -674,8 +672,7 @@ int QtPrivate::QStringList_lastIndexOf(const QStringList *that, QRegExp &rx, int } #endif -#ifndef QT_BOOTSTRAPPED -#ifndef QT_NO_REGULAREXPRESSION +#if QT_CONFIG(regularexpression) /*! \fn int QStringList::indexOf(const QRegularExpression &re, int from) const \overload @@ -732,8 +729,7 @@ int QtPrivate::QStringList_lastIndexOf(const QStringList *that, const QRegularEx } return -1; } -#endif // QT_NO_REGULAREXPRESSION -#endif // QT_BOOTSTRAPPED +#endif // QT_CONFIG(regularexpression) /*! \fn int QStringList::removeDuplicates() diff --git a/src/corelib/tools/qstringlist.h b/src/corelib/tools/qstringlist.h index b11856d9be..e58445b8c0 100644 --- a/src/corelib/tools/qstringlist.h +++ b/src/corelib/tools/qstringlist.h @@ -84,12 +84,10 @@ public: inline QStringList &replaceInStrings(const QRegExp &rx, const QString &after); #endif -#ifndef QT_BOOTSTRAPPED -#ifndef QT_NO_REGULAREXPRESSION +#if QT_CONFIG(regularexpression) inline QStringList filter(const QRegularExpression &re) const; inline QStringList &replaceInStrings(const QRegularExpression &re, const QString &after); -#endif // QT_NO_REGULAREXPRESSION -#endif // QT_BOOTSTRAPPED +#endif // QT_CONFIG(regularexpression) #ifndef Q_QDOC private: @@ -138,12 +136,10 @@ public: inline int lastIndexOf(QRegExp &rx, int from = -1) const; #endif -#ifndef QT_BOOTSTRAPPED -#ifndef QT_NO_REGULAREXPRESSION +#if QT_CONFIG(regularexpression) inline int indexOf(const QRegularExpression &re, int from = 0) const; inline int lastIndexOf(const QRegularExpression &re, int from = -1) const; -#endif // QT_NO_REGULAREXPRESSION -#endif // QT_BOOTSTRAPPED +#endif // QT_CONFIG(regularexpression) using QList::indexOf; using QList::lastIndexOf; @@ -179,14 +175,12 @@ namespace QtPrivate { int Q_CORE_EXPORT QStringList_lastIndexOf(const QStringList *that, QRegExp &rx, int from); #endif -#ifndef QT_BOOTSTRAPPED -#ifndef QT_NO_REGULAREXPRESSION +#if QT_CONFIG(regularexpression) void Q_CORE_EXPORT QStringList_replaceInStrings(QStringList *that, const QRegularExpression &rx, const QString &after); QStringList Q_CORE_EXPORT QStringList_filter(const QStringList *that, const QRegularExpression &re); int Q_CORE_EXPORT QStringList_indexOf(const QStringList *that, const QRegularExpression &re, int from); int Q_CORE_EXPORT QStringList_lastIndexOf(const QStringList *that, const QRegularExpression &re, int from); -#endif // QT_NO_REGULAREXPRESSION -#endif // QT_BOOTSTRAPPED +#endif // QT_CONFIG(regularexpression) } inline void QListSpecialMethods::sort(Qt::CaseSensitivity cs) @@ -275,8 +269,7 @@ inline int QStringList::lastIndexOf(QRegExp &rx, int from) const } #endif -#ifndef QT_BOOTSTRAPPED -#ifndef QT_NO_REGULAREXPRESSION +#if QT_CONFIG(regularexpression) inline QStringList &QListSpecialMethods::replaceInStrings(const QRegularExpression &rx, const QString &after) { QtPrivate::QStringList_replaceInStrings(self(), rx, after); @@ -297,8 +290,7 @@ inline int QStringList::lastIndexOf(const QRegularExpression &rx, int from) cons { return QtPrivate::QStringList_lastIndexOf(this, rx, from); } -#endif // QT_NO_REGULAREXPRESSION -#endif // QT_BOOTSTRAPPED +#endif // QT_CONFIG(regularexpression) #endif // Q_QDOC QT_END_NAMESPACE diff --git a/src/gui/opengl/qopenglshaderprogram.cpp b/src/gui/opengl/qopenglshaderprogram.cpp index 1fe30f7e0e..2ae9c6d327 100644 --- a/src/gui/opengl/qopenglshaderprogram.cpp +++ b/src/gui/opengl/qopenglshaderprogram.cpp @@ -46,7 +46,6 @@ #include #include #include -#include #include #include #include diff --git a/src/gui/text/qtextdocument.cpp b/src/gui/text/qtextdocument.cpp index e27b388762..44d1b2f201 100644 --- a/src/gui/text/qtextdocument.cpp +++ b/src/gui/text/qtextdocument.cpp @@ -47,7 +47,9 @@ #include "qtextlist.h" #include #include +#if QT_CONFIG(regularexpression) #include +#endif #include #include #include @@ -1488,7 +1490,7 @@ QTextCursor QTextDocument::find(const QRegExp &expr, const QTextCursor &cursor, } #endif // QT_REGEXP -#ifndef QT_NO_REGULAREXPRESSION +#if QT_CONFIG(regularexpression) static bool findInBlock(const QTextBlock &block, const QRegularExpression &expression, int offset, QTextDocument::FindFlags options, QTextCursor *cursor) { @@ -1613,7 +1615,7 @@ QTextCursor QTextDocument::find(const QRegularExpression &expr, const QTextCurso } return find(expr, pos, options); } -#endif // QT_NO_REGULAREXPRESSION +#endif // QT_CONFIG(regularexpression) /*! \fn QTextObject *QTextDocument::createObject(const QTextFormat &format) diff --git a/src/gui/text/qtextdocument.h b/src/gui/text/qtextdocument.h index c847d3ce88..64e39d4648 100644 --- a/src/gui/text/qtextdocument.h +++ b/src/gui/text/qtextdocument.h @@ -175,7 +175,7 @@ public: QTextCursor find(const QRegExp &expr, const QTextCursor &cursor, FindFlags options = FindFlags()) const; #endif -#ifndef QT_NO_REGULAREXPRESSION +#if QT_CONFIG(regularexpression) QTextCursor find(const QRegularExpression &expr, int from = 0, FindFlags options = FindFlags()) const; QTextCursor find(const QRegularExpression &expr, const QTextCursor &cursor, FindFlags options = FindFlags()) const; #endif diff --git a/src/gui/util/qvalidator.cpp b/src/gui/util/qvalidator.cpp index 1709012291..7982ad967e 100644 --- a/src/gui/util/qvalidator.cpp +++ b/src/gui/util/qvalidator.cpp @@ -916,7 +916,7 @@ void QRegExpValidator::setRegExp(const QRegExp& rx) #endif -#ifndef QT_NO_REGULAREXPRESSION +#if QT_CONFIG(regularexpression) /*! \class QRegularExpressionValidator @@ -1067,7 +1067,7 @@ void QRegularExpressionValidatorPrivate::setRegularExpression(const QRegularExpr } } -#endif // QT_NO_REGULAREXPRESSION +#endif // QT_CONFIG(regularexpression) QT_END_NAMESPACE diff --git a/src/gui/util/qvalidator.h b/src/gui/util/qvalidator.h index ad23092537..cc7cbcb559 100644 --- a/src/gui/util/qvalidator.h +++ b/src/gui/util/qvalidator.h @@ -45,7 +45,9 @@ #include #include #include -#include +#if QT_CONFIG(regularexpression) +# include +#endif #include QT_BEGIN_NAMESPACE @@ -194,7 +196,7 @@ private: #endif // QT_NO_REGEXP -#ifndef QT_NO_REGULAREXPRESSION +#if QT_CONFIG(regularexpression) class QRegularExpressionValidatorPrivate; @@ -223,7 +225,7 @@ private: Q_DECLARE_PRIVATE(QRegularExpressionValidator) }; -#endif // QT_NO_REGULAREXPRESSION +#endif // QT_CONFIG(regularexpression) #endif // QT_NO_VALIDATOR diff --git a/src/platformsupport/fontdatabases/windows/qwindowsfontdatabase_ft.cpp b/src/platformsupport/fontdatabases/windows/qwindowsfontdatabase_ft.cpp index 78477de38a..299dfd40cd 100644 --- a/src/platformsupport/fontdatabases/windows/qwindowsfontdatabase_ft.cpp +++ b/src/platformsupport/fontdatabases/windows/qwindowsfontdatabase_ft.cpp @@ -119,7 +119,7 @@ static FontKeys &fontKeys() QSettings::NativeFormat); const QStringList allKeys = fontRegistry.allKeys(); const QString trueType = QStringLiteral("(TrueType)"); -#ifndef QT_NO_REGULAREXPRESSION +#if QT_CONFIG(regularexpression) const QRegularExpression sizeListMatch(QStringLiteral("\\s(\\d+,)+\\d+")); #else const QRegExp sizeListMatch(QLatin1String("\\s(\\d+,)+\\d+")); diff --git a/src/plugins/platforms/eglfs/api/qeglfsdeviceintegration.cpp b/src/plugins/platforms/eglfs/api/qeglfsdeviceintegration.cpp index 1b8f50a1c6..f151713400 100644 --- a/src/plugins/platforms/eglfs/api/qeglfsdeviceintegration.cpp +++ b/src/plugins/platforms/eglfs/api/qeglfsdeviceintegration.cpp @@ -140,7 +140,7 @@ QByteArray QEglFSDeviceIntegration::fbDeviceName() const int QEglFSDeviceIntegration::framebufferIndex() const { int fbIndex = 0; -#ifndef QT_NO_REGULAREXPRESSION +#if QT_CONFIG(regularexpression) QRegularExpression fbIndexRx(QLatin1String("fb(\\d+)")); QRegularExpressionMatch match = fbIndexRx.match(QString::fromLocal8Bit(fbDeviceName())); if (match.hasMatch()) diff --git a/src/plugins/platformthemes/platformthemes.pro b/src/plugins/platformthemes/platformthemes.pro index ebf92ba9d5..17b1d91c6a 100644 --- a/src/plugins/platformthemes/platformthemes.pro +++ b/src/plugins/platformthemes/platformthemes.pro @@ -1,6 +1,6 @@ TEMPLATE = subdirs QT_FOR_CONFIG += widgets-private -qtConfig(dbus): SUBDIRS += flatpak +qtConfig(dbus):qtConfig(regularexpression): SUBDIRS += flatpak qtHaveModule(widgets):qtConfig(gtk3): SUBDIRS += gtk3 diff --git a/src/plugins/sqldrivers/sqlite/qsql_sqlite.cpp b/src/plugins/sqldrivers/sqlite/qsql_sqlite.cpp index f715d3cba3..cb3d905f46 100644 --- a/src/plugins/sqldrivers/sqlite/qsql_sqlite.cpp +++ b/src/plugins/sqldrivers/sqlite/qsql_sqlite.cpp @@ -51,7 +51,7 @@ #include #include #include -#ifndef QT_NO_REGULAREXPRESSION +#if QT_CONFIG(regularexpression) #include #include #endif @@ -625,7 +625,7 @@ QVariant QSQLiteResult::handle() const ///////////////////////////////////////////////////////// -#ifndef QT_NO_REGULAREXPRESSION +#if QT_CONFIG(regularexpression) static void _q_regexp(sqlite3_context* context, int argc, sqlite3_value** argv) { if (Q_UNLIKELY(argc != 2)) { @@ -724,7 +724,7 @@ bool QSQLiteDriver::open(const QString & db, const QString &, const QString &, c bool sharedCache = false; bool openReadOnlyOption = false; bool openUriOption = false; -#ifndef QT_NO_REGULAREXPRESSION +#if QT_CONFIG(regularexpression) static const QLatin1String regexpConnectOption = QLatin1String("QSQLITE_ENABLE_REGEXP"); bool defineRegexp = false; int regexpCacheSize = 25; @@ -748,7 +748,7 @@ bool QSQLiteDriver::open(const QString & db, const QString &, const QString &, c } else if (option == QLatin1String("QSQLITE_ENABLE_SHARED_CACHE")) { sharedCache = true; } -#ifndef QT_NO_REGULAREXPRESSION +#if QT_CONFIG(regularexpression) else if (option.startsWith(regexpConnectOption)) { option = option.mid(regexpConnectOption.size()).trimmed(); if (option.isEmpty()) { @@ -777,7 +777,7 @@ bool QSQLiteDriver::open(const QString & db, const QString &, const QString &, c sqlite3_busy_timeout(d->access, timeOut); setOpen(true); setOpenError(false); -#ifndef QT_NO_REGULAREXPRESSION +#if QT_CONFIG(regularexpression) if (defineRegexp) { auto cache = new QCache(regexpCacheSize); sqlite3_create_function_v2(d->access, "regexp", 2, SQLITE_UTF8, cache, &_q_regexp, NULL, diff --git a/src/testlib/qtestcase.cpp b/src/testlib/qtestcase.cpp index 7e9c03dbd4..d53530dadd 100644 --- a/src/testlib/qtestcase.cpp +++ b/src/testlib/qtestcase.cpp @@ -1971,7 +1971,7 @@ void QTest::ignoreMessage(QtMsgType type, const char *message) QTestLog::ignoreMessage(type, message); } -#ifndef QT_NO_REGULAREXPRESSION +#if QT_CONFIG(regularexpression) /*! \overload @@ -1991,7 +1991,7 @@ void QTest::ignoreMessage(QtMsgType type, const QRegularExpression &messagePatte { QTestLog::ignoreMessage(type, messagePattern); } -#endif // QT_NO_REGULAREXPRESSION +#endif // QT_CONFIG(regularexpression) /*! \internal */ diff --git a/src/testlib/qtestcase.h b/src/testlib/qtestcase.h index f38f7ed4df..cc666c365a 100644 --- a/src/testlib/qtestcase.h +++ b/src/testlib/qtestcase.h @@ -290,7 +290,7 @@ namespace QTest const char *file, int line); Q_TESTLIB_EXPORT void qWarn(const char *message, const char *file = nullptr, int line = 0); Q_TESTLIB_EXPORT void ignoreMessage(QtMsgType type, const char *message); -#ifndef QT_NO_REGULAREXPRESSION +#if QT_CONFIG(regularexpression) Q_TESTLIB_EXPORT void ignoreMessage(QtMsgType type, const QRegularExpression &messagePattern); #endif diff --git a/src/testlib/qtestlog.cpp b/src/testlib/qtestlog.cpp index 4964c6538e..6260b9e3fd 100644 --- a/src/testlib/qtestlog.cpp +++ b/src/testlib/qtestlog.cpp @@ -55,7 +55,9 @@ #include #include #include +#if QT_CONFIG(regularexpression) #include +#endif #include #include @@ -139,7 +141,7 @@ namespace QTest { return tp == type && (pattern.type() == QVariant::String ? stringsMatch(pattern.toString(), message) : -#ifndef QT_NO_REGULAREXPRESSION +#if QT_CONFIG(regularexpression) pattern.toRegularExpression().match(message).hasMatch()); #else false); @@ -364,7 +366,7 @@ void QTestLog::printUnhandledIgnoreMessages() if (list->pattern.type() == QVariant::String) { message = QStringLiteral("Did not receive message: \"") + list->pattern.toString() + QLatin1Char('"'); } else { -#ifndef QT_NO_REGULAREXPRESSION +#if QT_CONFIG(regularexpression) message = QStringLiteral("Did not receive any message matching: \"") + list->pattern.toRegularExpression().pattern() + QLatin1Char('"'); #endif } @@ -548,14 +550,14 @@ void QTestLog::ignoreMessage(QtMsgType type, const char *msg) QTest::IgnoreResultList::append(QTest::ignoreResultList, type, QString::fromLocal8Bit(msg)); } -#ifndef QT_NO_REGULAREXPRESSION +#if QT_CONFIG(regularexpression) void QTestLog::ignoreMessage(QtMsgType type, const QRegularExpression &expression) { QTEST_ASSERT(expression.isValid()); QTest::IgnoreResultList::append(QTest::ignoreResultList, type, QVariant(expression)); } -#endif // QT_NO_REGULAREXPRESSION +#endif // QT_CONFIG(regularexpression) void QTestLog::setMaxWarnings(int m) { diff --git a/src/widgets/dialogs/qcolordialog.cpp b/src/widgets/dialogs/qcolordialog.cpp index 896baed6c5..cf1119254b 100644 --- a/src/widgets/dialogs/qcolordialog.cpp +++ b/src/widgets/dialogs/qcolordialog.cpp @@ -1299,7 +1299,7 @@ QColorShower::QColorShower(QColorDialog *parent) lblHtml->setBuddy(htEd); #endif -#if !defined(QT_NO_REGULAREXPRESSION) +#if QT_CONFIG(regularexpression) QRegularExpression regExp(QStringLiteral("#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})")); QRegularExpressionValidator *validator = new QRegularExpressionValidator(regExp, this); htEd->setValidator(validator); diff --git a/tests/shared/emulationdetector.h b/tests/shared/emulationdetector.h index bf1192a0b2..cca11be695 100644 --- a/tests/shared/emulationdetector.h +++ b/tests/shared/emulationdetector.h @@ -32,7 +32,7 @@ #if defined(Q_OS_LINUX) && defined(Q_PROCESSOR_ARM) #define SHOULD_CHECK_ARM_ON_X86 -#if QT_CONFIG(process) && !defined(QT_NO_REGULAREXPRESSION) +#if QT_CONFIG(process) && QT_CONFIG(regularexpression) #include #include #endif @@ -88,7 +88,7 @@ static bool isX86SpecificFileAvailable() */ static bool isReportedArchitectureX86(void) { -#if QT_CONFIG(process) && !defined(QT_NO_REGULAREXPRESSION) +#if QT_CONFIG(process) && QT_CONFIG(regularexpression) QProcess unamer; QString machineString; From a65e383cac24b043b1dbe7172e0b142454e93e52 Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Thu, 1 Feb 2018 16:51:30 +0100 Subject: [PATCH 21/23] Switch lancelot from QRegExp to QRegularExpressions They are faster, and using them makes it paint commands be the most CPU intensive part of lancelot instead of regular-expression matching. Change-Id: Ifabf1081c48a83ce089660049051428fd3a43042 Reviewed-by: Eirik Aavitsland --- tests/auto/other/lancelot/paintcommands.cpp | 373 ++++++++++---------- tests/auto/other/lancelot/paintcommands.h | 194 +++++----- 2 files changed, 286 insertions(+), 281 deletions(-) diff --git a/tests/auto/other/lancelot/paintcommands.cpp b/tests/auto/other/lancelot/paintcommands.cpp index 8419f93e3b..4e0cb3b835 100644 --- a/tests/auto/other/lancelot/paintcommands.cpp +++ b/tests/auto/other/lancelot/paintcommands.cpp @@ -192,7 +192,7 @@ QList > PaintCommands::s_enumsTable = QList PaintCommands::s_commandHash; #define DECL_PAINTCOMMAND(identifier, method, regexp, syntax, sample) \ - s_commandInfoTable << PaintCommandInfos(QLatin1String(identifier), &PaintCommands::method, QRegExp(regexp), \ + s_commandInfoTable << PaintCommandInfos(QLatin1String(identifier), &PaintCommands::method, QRegularExpression(regexp, QRegularExpression::OptimizeOnFirstUsageOption), \ QLatin1String(syntax), QLatin1String(sample) ); #define DECL_PAINTCOMMANDSECTION(title) \ @@ -418,7 +418,7 @@ void PaintCommands::staticInit() "\n- a width or height of -1 means maximum space", "drawImage :/images/face.png 0 0 -1 -1 0 0 -1 -1"); DECL_PAINTCOMMAND("drawPolygon", command_drawPolygon, - "^drawPolygon\\s+\\[([\\w\\s-.]*)\\]\\s*(\\w*)$", + "^drawPolygon\\s+\\[([\\w\\s\\-.]*)\\]\\s*(\\w*)$", "drawPolygon <[ ... ]> ", "drawPolygon [ 1 4 6 8 5 3 ] Winding"); DECL_PAINTCOMMAND("drawConvexPolygon", command_drawConvexPolygon, @@ -683,19 +683,21 @@ void PaintCommands::insertAt(int commandIndex, const QStringList &newCommands) void PaintCommands::runCommand(const QString &scriptLine) { if (scriptLine.isEmpty()) { - command_noop(QRegExp()); + command_noop(QRegularExpressionMatch()); return; } if (scriptLine.startsWith('#')) { - command_comment(QRegExp()); + command_comment(QRegularExpressionMatch()); return; } - QString firstWord = scriptLine.section(QRegExp("\\s"), 0, 0); + QString firstWord = scriptLine.section(QRegularExpression("\\s"), 0, 0); QList indices = s_commandHash.values(firstWord); foreach(int idx, indices) { PaintCommandInfos command = s_commandInfoTable.at(idx); - if (command.regExp.indexIn(scriptLine) >= 0) { - (this->*(command.paintMethod))(command.regExp); + Q_ASSERT(command.regExp.isValid()); + QRegularExpressionMatch match = command.regExp.match(scriptLine); + if (match.hasMatch()) { + (this->*(command.paintMethod))(match); return; } } @@ -751,7 +753,7 @@ float PaintCommands::convertToFloat(const QString &str) double PaintCommands::convertToDouble(const QString &str) { - static QRegExp re("cp([0-9])([xy])"); + static QRegularExpression re("cp([0-9])([xy])"); if (str.toLower() == "width") { if (m_painter->device()->devType() == Qt::Widget) return m_painter->window().width(); @@ -764,9 +766,10 @@ double PaintCommands::convertToDouble(const QString &str) else return 800; } - if (re.indexIn(str) >= 0) { - int index = re.cap(1).toInt(); - bool is_it_x = re.cap(2) == "x"; + QRegularExpressionMatch match = re.match(str); + if (match.hasMatch()) { + int index = match.captured(1).toInt(); + bool is_it_x = match.captured(2) == "x"; if (index < 0 || index >= m_controlPoints.size()) { qWarning("ERROR: control point index=%d is out of bounds", index); return 0; @@ -778,21 +781,23 @@ double PaintCommands::convertToDouble(const QString &str) QColor PaintCommands::convertToColor(const QString &str) { - static QRegExp alphaColor("#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})"); - static QRegExp opaqueColor("#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})"); + static QRegularExpression alphaColorRe("#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})"); + static QRegularExpression opaqueColorRe("#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})"); - Q_ASSERT(alphaColor.isValid()); - Q_ASSERT(opaqueColor.isValid()); + Q_ASSERT(alphaColorRe.isValid()); + Q_ASSERT(opaqueColorRe.isValid()); - if (alphaColor.indexIn(str) >= 0) { - return QColor(alphaColor.cap(2).toInt(0, 16), - alphaColor.cap(3).toInt(0, 16), - alphaColor.cap(4).toInt(0, 16), - alphaColor.cap(1).toInt(0, 16)); - } else if (opaqueColor.indexIn(str) >= 0) { - return QColor(opaqueColor.cap(1).toInt(0, 16), - opaqueColor.cap(2).toInt(0, 16), - opaqueColor.cap(3).toInt(0, 16)); + QRegularExpressionMatch alphaColor = alphaColorRe.match(str); + QRegularExpressionMatch opaqueColor = opaqueColorRe.match(str); + if (alphaColor.hasMatch()) { + return QColor(alphaColor.captured(2).toInt(0, 16), + alphaColor.captured(3).toInt(0, 16), + alphaColor.captured(4).toInt(0, 16), + alphaColor.captured(1).toInt(0, 16)); + } else if (opaqueColor.hasMatch()) { + return QColor(opaqueColor.captured(1).toInt(0, 16), + opaqueColor.captured(2).toInt(0, 16), + opaqueColor.captured(3).toInt(0, 16)); } return QColor(str); } @@ -800,16 +805,16 @@ QColor PaintCommands::convertToColor(const QString &str) /********************************************************************************* ** command implementations **********************************************************************************/ -void PaintCommands::command_comment(QRegExp) +void PaintCommands::command_comment(QRegularExpressionMatch) { if (m_verboseMode) printf(" -(lance) comment: %s\n", qPrintable(m_currentCommand)); } /***************************************************************************************************/ -void PaintCommands::command_import(QRegExp re) +void PaintCommands::command_import(QRegularExpressionMatch re) { - QString importFile(re.cap(1)); + QString importFile(re.captured(1)); QFileInfo fi(m_filepath); QDir dir = fi.absoluteDir(); QFile *file = new QFile(dir.absolutePath() + QDir::separator() + importFile); @@ -862,9 +867,9 @@ void PaintCommands::command_import(QRegExp re) } /***************************************************************************************************/ -void PaintCommands::command_begin_block(QRegExp re) +void PaintCommands::command_begin_block(QRegularExpressionMatch re) { - const QString &blockName = re.cap(1); + const QString &blockName = re.captured(1); if (m_verboseMode) printf(" -(lance) begin_block (%s)\n", qPrintable(blockName)); @@ -891,7 +896,7 @@ void PaintCommands::command_begin_block(QRegExp re) } /***************************************************************************************************/ -void PaintCommands::command_end_block(QRegExp) +void PaintCommands::command_end_block(QRegularExpressionMatch) { printf(" - end_block should be consumed by begin_block command.\n"); printf(" You will never see this if your block markers are in sync\n"); @@ -899,9 +904,9 @@ void PaintCommands::command_end_block(QRegExp) } /***************************************************************************************************/ -void PaintCommands::command_repeat_block(QRegExp re) +void PaintCommands::command_repeat_block(QRegularExpressionMatch re) { - QString blockName = re.cap(1); + QString blockName = re.captured(1); if (m_verboseMode) printf(" -(lance) repeating block (%s)\n", qPrintable(blockName)); @@ -916,7 +921,7 @@ void PaintCommands::command_repeat_block(QRegExp re) } /***************************************************************************************************/ -void PaintCommands::command_drawLine(QRegExp re) +void PaintCommands::command_drawLine(QRegularExpressionMatch re) { QStringList caps = re.capturedTexts(); double x1 = convertToDouble(caps.at(1)); @@ -931,28 +936,28 @@ void PaintCommands::command_drawLine(QRegExp re) } /***************************************************************************************************/ -void PaintCommands::command_drawPath(QRegExp re) +void PaintCommands::command_drawPath(QRegularExpressionMatch re) { if (m_verboseMode) - printf(" -(lance) drawPath(name=%s)\n", qPrintable(re.cap(1))); + printf(" -(lance) drawPath(name=%s)\n", qPrintable(re.captured(1))); - QPainterPath &path = m_pathMap[re.cap(1)]; + QPainterPath &path = m_pathMap[re.captured(1)]; m_painter->drawPath(path); } /***************************************************************************************************/ -void PaintCommands::command_drawPixmap(QRegExp re) +void PaintCommands::command_drawPixmap(QRegularExpressionMatch re) { QPixmap pm; - pm = m_pixmapMap[re.cap(1)]; // try cache first + pm = m_pixmapMap[re.captured(1)]; // try cache first if (pm.isNull()) - pm = image_load(re.cap(1)); + pm = image_load(re.captured(1)); if (pm.isNull()) { QFileInfo fi(m_filepath); QDir dir = fi.absoluteDir(); dir.cdUp(); dir.cd("images"); - QString fileName = dir.absolutePath() + QLatin1Char('/') + re.cap(1); + QString fileName = dir.absolutePath() + QLatin1Char('/') + re.captured(1); pm = QPixmap(fileName); if (pm.isNull() && !fileName.endsWith(".png")) { fileName.append(".png"); @@ -961,19 +966,19 @@ void PaintCommands::command_drawPixmap(QRegExp re) } if (pm.isNull()) { fprintf(stderr, "ERROR(drawPixmap): failed to load pixmap: '%s'\n", - qPrintable(re.cap(1))); + qPrintable(re.captured(1))); return; } - qreal tx = convertToFloat(re.cap(2)); - qreal ty = convertToFloat(re.cap(3)); - qreal tw = convertToFloat(re.cap(4)); - qreal th = convertToFloat(re.cap(5)); + qreal tx = convertToFloat(re.captured(2)); + qreal ty = convertToFloat(re.captured(3)); + qreal tw = convertToFloat(re.captured(4)); + qreal th = convertToFloat(re.captured(5)); - qreal sx = convertToFloat(re.cap(6)); - qreal sy = convertToFloat(re.cap(7)); - qreal sw = convertToFloat(re.cap(8)); - qreal sh = convertToFloat(re.cap(9)); + qreal sx = convertToFloat(re.captured(6)); + qreal sy = convertToFloat(re.captured(7)); + qreal sw = convertToFloat(re.captured(8)); + qreal sh = convertToFloat(re.captured(9)); if (tw == 0) tw = -1; if (th == 0) th = -1; @@ -982,26 +987,26 @@ void PaintCommands::command_drawPixmap(QRegExp re) if (m_verboseMode) printf(" -(lance) drawPixmap('%s' dim=(%d, %d), depth=%d, (%f, %f, %f, %f), (%f, %f, %f, %f)\n", - qPrintable(re.cap(1)), pm.width(), pm.height(), pm.depth(), + qPrintable(re.captured(1)), pm.width(), pm.height(), pm.depth(), tx, ty, tw, th, sx, sy, sw, sh); m_painter->drawPixmap(QRectF(tx, ty, tw, th), pm, QRectF(sx, sy, sw, sh)); } /***************************************************************************************************/ -void PaintCommands::command_drawImage(QRegExp re) +void PaintCommands::command_drawImage(QRegularExpressionMatch re) { QImage im; - im = m_imageMap[re.cap(1)]; // try cache first + im = m_imageMap[re.captured(1)]; // try cache first if (im.isNull()) - im = image_load(re.cap(1)); + im = image_load(re.captured(1)); if (im.isNull()) { QFileInfo fi(m_filepath); QDir dir = fi.absoluteDir(); dir.cdUp(); dir.cd("images"); - QString fileName = dir.absolutePath() + QLatin1Char('/') + re.cap(1); + QString fileName = dir.absolutePath() + QLatin1Char('/') + re.captured(1); im = QImage(fileName); if (im.isNull() && !fileName.endsWith(".png")) { fileName.append(".png"); @@ -1009,19 +1014,19 @@ void PaintCommands::command_drawImage(QRegExp re) } } if (im.isNull()) { - fprintf(stderr, "ERROR(drawImage): failed to load image: '%s'\n", qPrintable(re.cap(1))); + fprintf(stderr, "ERROR(drawImage): failed to load image: '%s'\n", qPrintable(re.captured(1))); return; } - qreal tx = convertToFloat(re.cap(2)); - qreal ty = convertToFloat(re.cap(3)); - qreal tw = convertToFloat(re.cap(4)); - qreal th = convertToFloat(re.cap(5)); + qreal tx = convertToFloat(re.captured(2)); + qreal ty = convertToFloat(re.captured(3)); + qreal tw = convertToFloat(re.captured(4)); + qreal th = convertToFloat(re.captured(5)); - qreal sx = convertToFloat(re.cap(6)); - qreal sy = convertToFloat(re.cap(7)); - qreal sw = convertToFloat(re.cap(8)); - qreal sh = convertToFloat(re.cap(9)); + qreal sx = convertToFloat(re.captured(6)); + qreal sy = convertToFloat(re.captured(7)); + qreal sw = convertToFloat(re.captured(8)); + qreal sh = convertToFloat(re.captured(9)); if (tw == 0) tw = -1; if (th == 0) th = -1; @@ -1030,24 +1035,24 @@ void PaintCommands::command_drawImage(QRegExp re) if (m_verboseMode) printf(" -(lance) drawImage('%s' dim=(%d, %d), (%f, %f, %f, %f), (%f, %f, %f, %f)\n", - qPrintable(re.cap(1)), im.width(), im.height(), tx, ty, tw, th, sx, sy, sw, sh); + qPrintable(re.captured(1)), im.width(), im.height(), tx, ty, tw, th, sx, sy, sw, sh); m_painter->drawImage(QRectF(tx, ty, tw, th), im, QRectF(sx, sy, sw, sh), Qt::OrderedDither | Qt::OrderedAlphaDither); } /***************************************************************************************************/ -void PaintCommands::command_drawTiledPixmap(QRegExp re) +void PaintCommands::command_drawTiledPixmap(QRegularExpressionMatch re) { QPixmap pm; - pm = m_pixmapMap[re.cap(1)]; // try cache first + pm = m_pixmapMap[re.captured(1)]; // try cache first if (pm.isNull()) - pm = image_load(re.cap(1)); + pm = image_load(re.captured(1)); if (pm.isNull()) { QFileInfo fi(m_filepath); QDir dir = fi.absoluteDir(); dir.cdUp(); dir.cd("images"); - QString fileName = dir.absolutePath() + QLatin1Char('/') + re.cap(1); + QString fileName = dir.absolutePath() + QLatin1Char('/') + re.captured(1); pm = QPixmap(fileName); if (pm.isNull() && !fileName.endsWith(".png")) { fileName.append(".png"); @@ -1056,30 +1061,30 @@ void PaintCommands::command_drawTiledPixmap(QRegExp re) } if (pm.isNull()) { fprintf(stderr, "ERROR(drawTiledPixmap): failed to load pixmap: '%s'\n", - qPrintable(re.cap(1))); + qPrintable(re.captured(1))); return; } - int tx = convertToInt(re.cap(2)); - int ty = convertToInt(re.cap(3)); - int tw = convertToInt(re.cap(4)); - int th = convertToInt(re.cap(5)); + int tx = convertToInt(re.captured(2)); + int ty = convertToInt(re.captured(3)); + int tw = convertToInt(re.captured(4)); + int th = convertToInt(re.captured(5)); - int sx = convertToInt(re.cap(6)); - int sy = convertToInt(re.cap(7)); + int sx = convertToInt(re.captured(6)); + int sy = convertToInt(re.captured(7)); if (tw == 0) tw = -1; if (th == 0) th = -1; if (m_verboseMode) printf(" -(lance) drawTiledPixmap('%s' dim=(%d, %d), (%d, %d, %d, %d), (%d, %d)\n", - qPrintable(re.cap(1)), pm.width(), pm.height(), tx, ty, tw, th, sx, sy); + qPrintable(re.captured(1)), pm.width(), pm.height(), tx, ty, tw, th, sx, sy); m_painter->drawTiledPixmap(tx, ty, tw, th, pm, sx, sy); } /***************************************************************************************************/ -void PaintCommands::command_drawPoint(QRegExp re) +void PaintCommands::command_drawPoint(QRegularExpressionMatch re) { QStringList caps = re.capturedTexts(); float x = convertToFloat(caps.at(1)); @@ -1092,9 +1097,9 @@ void PaintCommands::command_drawPoint(QRegExp re) } /***************************************************************************************************/ -void PaintCommands::command_drawPolygon(QRegExp re) +void PaintCommands::command_drawPolygon(QRegularExpressionMatch re) { - static QRegExp separators("\\s"); + static QRegularExpression separators("\\s"); QStringList caps = re.capturedTexts(); QString cap = caps.at(1); QStringList numbers = cap.split(separators, QString::SkipEmptyParts); @@ -1110,10 +1115,10 @@ void PaintCommands::command_drawPolygon(QRegExp re) } /***************************************************************************************************/ -void PaintCommands::command_drawPolyline(QRegExp re) +void PaintCommands::command_drawPolyline(QRegularExpressionMatch re) { - static QRegExp separators("\\s"); - QStringList numbers = re.cap(1).split(separators, QString::SkipEmptyParts); + static QRegularExpression separators("\\s"); + QStringList numbers = re.captured(1).split(separators, QString::SkipEmptyParts); QPolygonF array; for (int i=0; i + 1drawText(x, y, txt); } -void PaintCommands::command_drawStaticText(QRegExp re) +void PaintCommands::command_drawStaticText(QRegularExpressionMatch re) { if (!m_shouldDrawText) return; @@ -1276,7 +1281,7 @@ void PaintCommands::command_drawStaticText(QRegExp re) } /***************************************************************************************************/ -void PaintCommands::command_noop(QRegExp) +void PaintCommands::command_noop(QRegularExpressionMatch) { if (m_verboseMode) printf(" -(lance) noop: %s\n", qPrintable(m_currentCommand)); @@ -1287,7 +1292,7 @@ void PaintCommands::command_noop(QRegExp) } /***************************************************************************************************/ -void PaintCommands::command_path_addText(QRegExp re) +void PaintCommands::command_path_addText(QRegularExpressionMatch re) { QStringList caps = re.capturedTexts(); QString name = caps.at(1); @@ -1302,7 +1307,7 @@ void PaintCommands::command_path_addText(QRegExp re) } /***************************************************************************************************/ -void PaintCommands::command_path_addEllipse(QRegExp re) +void PaintCommands::command_path_addEllipse(QRegularExpressionMatch re) { QStringList caps = re.capturedTexts(); QString name = caps.at(1); @@ -1318,7 +1323,7 @@ void PaintCommands::command_path_addEllipse(QRegExp re) } /***************************************************************************************************/ -void PaintCommands::command_path_addRect(QRegExp re) +void PaintCommands::command_path_addRect(QRegularExpressionMatch re) { QStringList caps = re.capturedTexts(); QString name = caps.at(1); @@ -1334,9 +1339,9 @@ void PaintCommands::command_path_addRect(QRegExp re) } /***************************************************************************************************/ -void PaintCommands::command_path_addPolygon(QRegExp re) +void PaintCommands::command_path_addPolygon(QRegularExpressionMatch re) { - static QRegExp separators("\\s"); + static QRegularExpression separators("\\s"); QStringList caps = re.capturedTexts(); QString name = caps.at(1); QString cap = caps.at(2); @@ -1353,7 +1358,7 @@ void PaintCommands::command_path_addPolygon(QRegExp re) } /***************************************************************************************************/ -void PaintCommands::command_path_arcTo(QRegExp re) +void PaintCommands::command_path_arcTo(QRegularExpressionMatch re) { QStringList caps = re.capturedTexts(); QString name = caps.at(1); @@ -1371,7 +1376,7 @@ void PaintCommands::command_path_arcTo(QRegExp re) } /***************************************************************************************************/ -void PaintCommands::command_path_createOutline(QRegExp re) +void PaintCommands::command_path_createOutline(QRegularExpressionMatch re) { QStringList caps = re.capturedTexts(); QString name = caps.at(1); @@ -1395,7 +1400,7 @@ void PaintCommands::command_path_createOutline(QRegExp re) } /***************************************************************************************************/ -void PaintCommands::command_path_cubicTo(QRegExp re) +void PaintCommands::command_path_cubicTo(QRegularExpressionMatch re) { QStringList caps = re.capturedTexts(); QString name = caps.at(1); @@ -1413,7 +1418,7 @@ void PaintCommands::command_path_cubicTo(QRegExp re) } /***************************************************************************************************/ -void PaintCommands::command_path_moveTo(QRegExp re) +void PaintCommands::command_path_moveTo(QRegularExpressionMatch re) { QStringList caps = re.capturedTexts(); QString name = caps.at(1); @@ -1427,7 +1432,7 @@ void PaintCommands::command_path_moveTo(QRegExp re) } /***************************************************************************************************/ -void PaintCommands::command_path_lineTo(QRegExp re) +void PaintCommands::command_path_lineTo(QRegularExpressionMatch re) { QStringList caps = re.capturedTexts(); QString name = caps.at(1); @@ -1441,7 +1446,7 @@ void PaintCommands::command_path_lineTo(QRegExp re) } /***************************************************************************************************/ -void PaintCommands::command_path_setFillRule(QRegExp re) +void PaintCommands::command_path_setFillRule(QRegularExpressionMatch re) { QStringList caps = re.capturedTexts(); QString name = caps.at(1); @@ -1454,7 +1459,7 @@ void PaintCommands::command_path_setFillRule(QRegExp re) } /***************************************************************************************************/ -void PaintCommands::command_path_closeSubpath(QRegExp re) +void PaintCommands::command_path_closeSubpath(QRegularExpressionMatch re) { QStringList caps = re.capturedTexts(); QString name = caps.at(1); @@ -1466,7 +1471,7 @@ void PaintCommands::command_path_closeSubpath(QRegExp re) } /***************************************************************************************************/ -void PaintCommands::command_path_getClipPath(QRegExp re) +void PaintCommands::command_path_getClipPath(QRegularExpressionMatch re) { QStringList caps = re.capturedTexts(); QString name = caps.at(1); @@ -1496,7 +1501,7 @@ static void qt_debug_path(const QPainterPath &path, const QString &name) } /***************************************************************************************************/ -void PaintCommands::command_path_debugPrint(QRegExp re) +void PaintCommands::command_path_debugPrint(QRegularExpressionMatch re) { QStringList caps = re.capturedTexts(); QString name = caps.at(1); @@ -1504,7 +1509,7 @@ void PaintCommands::command_path_debugPrint(QRegExp re) } /***************************************************************************************************/ -void PaintCommands::command_region_addRect(QRegExp re) +void PaintCommands::command_region_addRect(QRegularExpressionMatch re) { QStringList caps = re.capturedTexts(); QString name = caps.at(1); @@ -1520,7 +1525,7 @@ void PaintCommands::command_region_addRect(QRegExp re) } /***************************************************************************************************/ -void PaintCommands::command_region_addEllipse(QRegExp re) +void PaintCommands::command_region_addEllipse(QRegularExpressionMatch re) { QStringList caps = re.capturedTexts(); QString name = caps.at(1); @@ -1536,7 +1541,7 @@ void PaintCommands::command_region_addEllipse(QRegExp re) } /***************************************************************************************************/ -void PaintCommands::command_region_getClipRegion(QRegExp re) +void PaintCommands::command_region_getClipRegion(QRegularExpressionMatch re) { QStringList caps = re.capturedTexts(); QString name = caps.at(1); @@ -1553,7 +1558,7 @@ void PaintCommands::command_region_getClipRegion(QRegExp re) } /***************************************************************************************************/ -void PaintCommands::command_resetMatrix(QRegExp) +void PaintCommands::command_resetMatrix(QRegularExpressionMatch) { if (m_verboseMode) printf(" -(lance) resetMatrix()\n"); @@ -1562,7 +1567,7 @@ void PaintCommands::command_resetMatrix(QRegExp) } /***************************************************************************************************/ -void PaintCommands::command_restore(QRegExp) +void PaintCommands::command_restore(QRegularExpressionMatch) { if (m_verboseMode) printf(" -(lance) restore()\n"); @@ -1571,7 +1576,7 @@ void PaintCommands::command_restore(QRegExp) } /***************************************************************************************************/ -void PaintCommands::command_rotate(QRegExp re) +void PaintCommands::command_rotate(QRegularExpressionMatch re) { QStringList caps = re.capturedTexts(); double angle = convertToDouble(caps.at(1)); @@ -1583,7 +1588,7 @@ void PaintCommands::command_rotate(QRegExp re) } /***************************************************************************************************/ -void PaintCommands::command_rotate_x(QRegExp re) +void PaintCommands::command_rotate_x(QRegularExpressionMatch re) { QStringList caps = re.capturedTexts(); double angle = convertToDouble(caps.at(1)); @@ -1597,7 +1602,7 @@ void PaintCommands::command_rotate_x(QRegExp re) } /***************************************************************************************************/ -void PaintCommands::command_rotate_y(QRegExp re) +void PaintCommands::command_rotate_y(QRegularExpressionMatch re) { QStringList caps = re.capturedTexts(); double angle = convertToDouble(caps.at(1)); @@ -1611,7 +1616,7 @@ void PaintCommands::command_rotate_y(QRegExp re) } /***************************************************************************************************/ -void PaintCommands::command_save(QRegExp) +void PaintCommands::command_save(QRegularExpressionMatch) { if (m_verboseMode) printf(" -(lance) save()\n"); @@ -1620,7 +1625,7 @@ void PaintCommands::command_save(QRegExp) } /***************************************************************************************************/ -void PaintCommands::command_mapQuadToQuad(QRegExp re) +void PaintCommands::command_mapQuadToQuad(QRegularExpressionMatch re) { QStringList caps = re.capturedTexts(); double x1 = convertToDouble(caps.at(1)); @@ -1666,7 +1671,7 @@ void PaintCommands::command_mapQuadToQuad(QRegExp re) } /***************************************************************************************************/ -void PaintCommands::command_setMatrix(QRegExp re) +void PaintCommands::command_setMatrix(QRegularExpressionMatch re) { QStringList caps = re.capturedTexts(); double m11 = convertToDouble(caps.at(1)); @@ -1692,7 +1697,7 @@ void PaintCommands::command_setMatrix(QRegExp re) } /***************************************************************************************************/ -void PaintCommands::command_scale(QRegExp re) +void PaintCommands::command_scale(QRegularExpressionMatch re) { QStringList caps = re.capturedTexts(); double sx = convertToDouble(caps.at(1)); @@ -1706,7 +1711,7 @@ void PaintCommands::command_scale(QRegExp re) } /***************************************************************************************************/ -void PaintCommands::command_setBackground(QRegExp re) +void PaintCommands::command_setBackground(QRegularExpressionMatch re) { QStringList caps = re.capturedTexts(); QColor color = convertToColor(caps.at(1)); @@ -1723,7 +1728,7 @@ void PaintCommands::command_setBackground(QRegExp re) } /***************************************************************************************************/ -void PaintCommands::command_setOpacity(QRegExp re) +void PaintCommands::command_setOpacity(QRegularExpressionMatch re) { QStringList caps = re.capturedTexts(); double opacity = convertToDouble(caps.at(1)); @@ -1735,9 +1740,9 @@ void PaintCommands::command_setOpacity(QRegExp re) } /***************************************************************************************************/ -void PaintCommands::command_setBgMode(QRegExp re) +void PaintCommands::command_setBgMode(QRegularExpressionMatch re) { - QString cap = re.cap(2); + QString cap = re.captured(2); Qt::BGMode mode = Qt::TransparentMode; if (cap.toLower() == QLatin1String("opaquemode") || cap.toLower() == QLatin1String("opaque")) mode = Qt::OpaqueMode; @@ -1749,7 +1754,7 @@ void PaintCommands::command_setBgMode(QRegExp re) } /***************************************************************************************************/ -void PaintCommands::command_setBrush(QRegExp re) +void PaintCommands::command_setBrush(QRegularExpressionMatch re) { QStringList caps = re.capturedTexts(); @@ -1780,10 +1785,10 @@ void PaintCommands::command_setBrush(QRegExp re) } /***************************************************************************************************/ -void PaintCommands::command_setBrushOrigin(QRegExp re) +void PaintCommands::command_setBrushOrigin(QRegularExpressionMatch re) { - int x = convertToInt(re.cap(1)); - int y = convertToInt(re.cap(2)); + int x = convertToInt(re.captured(1)); + int y = convertToInt(re.captured(2)); if (m_verboseMode) printf(" -(lance) setBrushOrigin(%d, %d)\n", x, y); @@ -1792,7 +1797,7 @@ void PaintCommands::command_setBrushOrigin(QRegExp re) } /***************************************************************************************************/ -void PaintCommands::command_brushTranslate(QRegExp re) +void PaintCommands::command_brushTranslate(QRegularExpressionMatch re) { QStringList caps = re.capturedTexts(); double dx = convertToDouble(caps.at(1)); @@ -1809,7 +1814,7 @@ void PaintCommands::command_brushTranslate(QRegExp re) } /***************************************************************************************************/ -void PaintCommands::command_brushScale(QRegExp re) +void PaintCommands::command_brushScale(QRegularExpressionMatch re) { QStringList caps = re.capturedTexts(); double sx = convertToDouble(caps.at(1)); @@ -1826,7 +1831,7 @@ void PaintCommands::command_brushScale(QRegExp re) } /***************************************************************************************************/ -void PaintCommands::command_brushRotate(QRegExp re) +void PaintCommands::command_brushRotate(QRegularExpressionMatch re) { QStringList caps = re.capturedTexts(); double rot = convertToDouble(caps.at(1)); @@ -1842,7 +1847,7 @@ void PaintCommands::command_brushRotate(QRegExp re) } /***************************************************************************************************/ -void PaintCommands::command_brushShear(QRegExp re) +void PaintCommands::command_brushShear(QRegularExpressionMatch re) { QStringList caps = re.capturedTexts(); double sx = convertToDouble(caps.at(1)); @@ -1859,9 +1864,9 @@ void PaintCommands::command_brushShear(QRegExp re) } /***************************************************************************************************/ -void PaintCommands::command_setClipping(QRegExp re) +void PaintCommands::command_setClipping(QRegularExpressionMatch re) { - bool clipping = re.cap(1).toLower() == "true"; + bool clipping = re.captured(1).toLower() == "true"; if (m_verboseMode) printf(" -(lance) setClipping(%d)\n", clipping); @@ -1870,7 +1875,7 @@ void PaintCommands::command_setClipping(QRegExp re) } /***************************************************************************************************/ -void PaintCommands::command_setClipRect(QRegExp re) +void PaintCommands::command_setClipRect(QRegularExpressionMatch re) { QStringList caps = re.capturedTexts(); int x = convertToInt(caps.at(1)); @@ -1889,48 +1894,48 @@ void PaintCommands::command_setClipRect(QRegExp re) } /***************************************************************************************************/ -void PaintCommands::command_setClipPath(QRegExp re) +void PaintCommands::command_setClipPath(QRegularExpressionMatch re) { - int combine = translateEnum(clipOperationTable, re.cap(2), Qt::IntersectClip + 1); + int combine = translateEnum(clipOperationTable, re.captured(2), Qt::IntersectClip + 1); if (combine == -1) combine = Qt::ReplaceClip; if (m_verboseMode) - printf(" -(lance) setClipPath(name=%s), %s\n", qPrintable(re.cap(1)), clipOperationTable[combine]); + printf(" -(lance) setClipPath(name=%s), %s\n", qPrintable(re.captured(1)), clipOperationTable[combine]); - if (!m_pathMap.contains(re.cap(1))) + if (!m_pathMap.contains(re.captured(1))) fprintf(stderr, " - setClipPath, no such path"); - m_painter->setClipPath(m_pathMap[re.cap(1)], Qt::ClipOperation(combine)); + m_painter->setClipPath(m_pathMap[re.captured(1)], Qt::ClipOperation(combine)); } /***************************************************************************************************/ -void PaintCommands::command_setClipRegion(QRegExp re) +void PaintCommands::command_setClipRegion(QRegularExpressionMatch re) { - int combine = translateEnum(clipOperationTable, re.cap(2), Qt::IntersectClip + 1); + int combine = translateEnum(clipOperationTable, re.captured(2), Qt::IntersectClip + 1); if (combine == -1) combine = Qt::ReplaceClip; - QRegion r = m_regionMap[re.cap(1)]; + QRegion r = m_regionMap[re.captured(1)]; if (m_verboseMode) printf(" -(lance) setClipRegion(name=%s), bounds=[%d, %d, %d, %d], %s\n", - qPrintable(re.cap(1)), + qPrintable(re.captured(1)), r.boundingRect().x(), r.boundingRect().y(), r.boundingRect().width(), r.boundingRect().height(), clipOperationTable[combine]); - m_painter->setClipRegion(m_regionMap[re.cap(1)], Qt::ClipOperation(combine)); + m_painter->setClipRegion(m_regionMap[re.captured(1)], Qt::ClipOperation(combine)); } /***************************************************************************************************/ -void PaintCommands::command_setFont(QRegExp re) +void PaintCommands::command_setFont(QRegularExpressionMatch re) { QStringList caps = re.capturedTexts(); QString family = caps.at(1); int size = convertToInt(caps.at(2)); - int weight = translateEnum(fontWeightTable, re.cap(3).toLower(), 5); + int weight = translateEnum(fontWeightTable, re.captured(3).toLower(), 5); if (weight != -1) { switch (weight) { case 0: weight = QFont::Light; break; @@ -1940,7 +1945,7 @@ void PaintCommands::command_setFont(QRegExp re) case 4: weight = QFont::Black; break; } } else { - weight = convertToInt(re.cap(3)); + weight = convertToInt(re.captured(3)); } bool italic = caps.at(4).toLower() == "true" || caps.at(4).toLower() == "italic"; @@ -1960,9 +1965,9 @@ void PaintCommands::command_setFont(QRegExp re) } /***************************************************************************************************/ -void PaintCommands::command_setPen(QRegExp re) +void PaintCommands::command_setPen(QRegularExpressionMatch re) { - QString cap = re.cap(1); + QString cap = re.captured(1); int style = translateEnum(penStyleTable, cap, Qt::DashDotDotLine + 1); if (style >= 0) { if (m_verboseMode) @@ -1986,7 +1991,7 @@ void PaintCommands::command_setPen(QRegExp re) } /***************************************************************************************************/ -void PaintCommands::command_setPen2(QRegExp re) +void PaintCommands::command_setPen2(QRegularExpressionMatch re) { QStringList caps = re.capturedTexts(); @@ -2024,10 +2029,10 @@ void PaintCommands::command_setPen2(QRegExp re) } /***************************************************************************************************/ -void PaintCommands::command_setRenderHint(QRegExp re) +void PaintCommands::command_setRenderHint(QRegularExpressionMatch re) { - QString hintString = re.cap(1).toLower(); - bool on = re.cap(2).isEmpty() || re.cap(2).toLower() == "true"; + QString hintString = re.captured(1).toLower(); + bool on = re.captured(2).isEmpty() || re.captured(2).toLower() == "true"; if (hintString.contains("antialiasing")) { if (m_verboseMode) printf(" -(lance) setRenderHint Antialiasing\n"); @@ -2043,7 +2048,7 @@ void PaintCommands::command_setRenderHint(QRegExp re) } /***************************************************************************************************/ -void PaintCommands::command_clearRenderHint(QRegExp /*re*/) +void PaintCommands::command_clearRenderHint(QRegularExpressionMatch /*re*/) { m_painter->setRenderHint(QPainter::Antialiasing, false); m_painter->setRenderHint(QPainter::SmoothPixmapTransform, false); @@ -2052,9 +2057,9 @@ void PaintCommands::command_clearRenderHint(QRegExp /*re*/) } /***************************************************************************************************/ -void PaintCommands::command_setCompositionMode(QRegExp re) +void PaintCommands::command_setCompositionMode(QRegularExpressionMatch re) { - QString modeString = re.cap(1).toLower(); + QString modeString = re.captured(1).toLower(); int mode = translateEnum(compositionModeTable, modeString, 33); if (mode < 0 || mode > QPainter::RasterOp_SourceAndNotDestination) { @@ -2069,7 +2074,7 @@ void PaintCommands::command_setCompositionMode(QRegExp re) } /***************************************************************************************************/ -void PaintCommands::command_translate(QRegExp re) +void PaintCommands::command_translate(QRegularExpressionMatch re) { QStringList caps = re.capturedTexts(); double dx = convertToDouble(caps.at(1)); @@ -2082,7 +2087,7 @@ void PaintCommands::command_translate(QRegExp re) } /***************************************************************************************************/ -void PaintCommands::command_pixmap_load(QRegExp re) +void PaintCommands::command_pixmap_load(QRegularExpressionMatch re) { QStringList caps = re.capturedTexts(); @@ -2104,7 +2109,7 @@ void PaintCommands::command_pixmap_load(QRegExp re) } /***************************************************************************************************/ -void PaintCommands::command_bitmap_load(QRegExp re) +void PaintCommands::command_bitmap_load(QRegularExpressionMatch re) { QStringList caps = re.capturedTexts(); @@ -2125,7 +2130,7 @@ void PaintCommands::command_bitmap_load(QRegExp re) } /***************************************************************************************************/ -void PaintCommands::command_pixmap_setMask(QRegExp re) +void PaintCommands::command_pixmap_setMask(QRegularExpressionMatch re) { QStringList caps = re.capturedTexts(); QBitmap mask = image_load(caps.at(2)); @@ -2138,7 +2143,7 @@ void PaintCommands::command_pixmap_setMask(QRegExp re) } /***************************************************************************************************/ -void PaintCommands::command_image_load(QRegExp re) +void PaintCommands::command_image_load(QRegularExpressionMatch re) { QStringList caps = re.capturedTexts(); @@ -2159,7 +2164,7 @@ void PaintCommands::command_image_load(QRegExp re) } /***************************************************************************************************/ -void PaintCommands::command_image_setColorCount(QRegExp re) +void PaintCommands::command_image_setColorCount(QRegularExpressionMatch re) { QStringList caps = re.capturedTexts(); @@ -2174,7 +2179,7 @@ void PaintCommands::command_image_setColorCount(QRegExp re) } /***************************************************************************************************/ -void PaintCommands::command_image_setColor(QRegExp re) +void PaintCommands::command_image_setColor(QRegularExpressionMatch re) { QStringList caps = re.capturedTexts(); @@ -2189,13 +2194,13 @@ void PaintCommands::command_image_setColor(QRegExp re) } /***************************************************************************************************/ -void PaintCommands::command_abort(QRegExp) +void PaintCommands::command_abort(QRegularExpressionMatch) { m_abort = true; } /***************************************************************************************************/ -void PaintCommands::command_gradient_clearStops(QRegExp) +void PaintCommands::command_gradient_clearStops(QRegularExpressionMatch) { if (m_verboseMode) printf(" -(lance) gradient_clearStops\n"); @@ -2203,7 +2208,7 @@ void PaintCommands::command_gradient_clearStops(QRegExp) } /***************************************************************************************************/ -void PaintCommands::command_gradient_appendStop(QRegExp re) +void PaintCommands::command_gradient_appendStop(QRegularExpressionMatch re) { QStringList caps = re.capturedTexts(); double pos = convertToDouble(caps.at(1)); @@ -2216,7 +2221,7 @@ void PaintCommands::command_gradient_appendStop(QRegExp re) } /***************************************************************************************************/ -void PaintCommands::command_gradient_setLinear(QRegExp re) +void PaintCommands::command_gradient_setLinear(QRegularExpressionMatch re) { QStringList caps = re.capturedTexts(); double x1 = convertToDouble(caps.at(1)); @@ -2239,7 +2244,7 @@ void PaintCommands::command_gradient_setLinear(QRegExp re) } /***************************************************************************************************/ -void PaintCommands::command_gradient_setLinearPen(QRegExp re) +void PaintCommands::command_gradient_setLinearPen(QRegularExpressionMatch re) { QStringList caps = re.capturedTexts(); double x1 = convertToDouble(caps.at(1)); @@ -2261,7 +2266,7 @@ void PaintCommands::command_gradient_setLinearPen(QRegExp re) } /***************************************************************************************************/ -void PaintCommands::command_gradient_setRadial(QRegExp re) +void PaintCommands::command_gradient_setRadial(QRegularExpressionMatch re) { QStringList caps = re.capturedTexts(); double cx = convertToDouble(caps.at(1)); @@ -2286,7 +2291,7 @@ void PaintCommands::command_gradient_setRadial(QRegExp re) } /***************************************************************************************************/ -void PaintCommands::command_gradient_setRadialExtended(QRegExp re) +void PaintCommands::command_gradient_setRadialExtended(QRegularExpressionMatch re) { QStringList caps = re.capturedTexts(); double cx = convertToDouble(caps.at(1)); @@ -2312,7 +2317,7 @@ void PaintCommands::command_gradient_setRadialExtended(QRegExp re) } /***************************************************************************************************/ -void PaintCommands::command_gradient_setConical(QRegExp re) +void PaintCommands::command_gradient_setConical(QRegularExpressionMatch re) { QStringList caps = re.capturedTexts(); double cx = convertToDouble(caps.at(1)); @@ -2335,9 +2340,9 @@ void PaintCommands::command_gradient_setConical(QRegExp re) } /***************************************************************************************************/ -void PaintCommands::command_gradient_setSpread(QRegExp re) +void PaintCommands::command_gradient_setSpread(QRegularExpressionMatch re) { - int spreadMethod = translateEnum(spreadMethodTable, re.cap(1), 3); + int spreadMethod = translateEnum(spreadMethodTable, re.captured(1), 3); if (m_verboseMode) printf(" -(lance) gradient_setSpread %d=[%s]\n", spreadMethod, spreadMethodTable[spreadMethod]); @@ -2345,9 +2350,9 @@ void PaintCommands::command_gradient_setSpread(QRegExp re) m_gradientSpread = QGradient::Spread(spreadMethod); } -void PaintCommands::command_gradient_setCoordinateMode(QRegExp re) +void PaintCommands::command_gradient_setCoordinateMode(QRegularExpressionMatch re) { - int coord = translateEnum(coordinateMethodTable, re.cap(1), 3); + int coord = translateEnum(coordinateMethodTable, re.captured(1), 3); if (m_verboseMode) printf(" -(lance) gradient_setCoordinateMode %d=[%s]\n", coord, @@ -2357,7 +2362,7 @@ void PaintCommands::command_gradient_setCoordinateMode(QRegExp re) } /***************************************************************************************************/ -void PaintCommands::command_surface_begin(QRegExp re) +void PaintCommands::command_surface_begin(QRegularExpressionMatch re) { QStringList caps = re.capturedTexts(); double x = convertToDouble(caps.at(1)); @@ -2417,7 +2422,7 @@ void PaintCommands::command_surface_begin(QRegExp re) } /***************************************************************************************************/ -void PaintCommands::command_surface_end(QRegExp) +void PaintCommands::command_surface_end(QRegularExpressionMatch) { if (!m_surface_painter) { fprintf(stderr, "ERROR: surface not active"); @@ -2466,7 +2471,7 @@ void PaintCommands::command_surface_end(QRegExp) } /***************************************************************************************************/ -void PaintCommands::command_image_convertToFormat(QRegExp re) +void PaintCommands::command_image_convertToFormat(QRegularExpressionMatch re) { QStringList caps = re.capturedTexts(); @@ -2499,7 +2504,7 @@ void PaintCommands::command_image_convertToFormat(QRegExp re) } /***************************************************************************************************/ -void PaintCommands::command_textlayout_draw(QRegExp re) +void PaintCommands::command_textlayout_draw(QRegularExpressionMatch re) { QStringList caps = re.capturedTexts(); @@ -2532,7 +2537,7 @@ void PaintCommands::command_textlayout_draw(QRegExp re) } /***************************************************************************************************/ -void PaintCommands::command_pen_setDashOffset(QRegExp re) +void PaintCommands::command_pen_setDashOffset(QRegularExpressionMatch re) { QStringList caps = re.capturedTexts(); double offset = convertToDouble(caps.at(1)); @@ -2546,9 +2551,9 @@ void PaintCommands::command_pen_setDashOffset(QRegExp re) } /***************************************************************************************************/ -void PaintCommands::command_pen_setDashPattern(QRegExp re) +void PaintCommands::command_pen_setDashPattern(QRegularExpressionMatch re) { - static QRegExp separators("\\s"); + static QRegularExpression separators("\\s"); QStringList caps = re.capturedTexts(); QString cap = caps.at(1); QStringList numbers = cap.split(separators, QString::SkipEmptyParts); @@ -2566,7 +2571,7 @@ void PaintCommands::command_pen_setDashPattern(QRegExp re) } /***************************************************************************************************/ -void PaintCommands::command_pen_setCosmetic(QRegExp re) +void PaintCommands::command_pen_setCosmetic(QRegularExpressionMatch re) { QString hm = re.capturedTexts().at(1); bool on = hm == "true" || hm == "yes" || hm == "on"; @@ -2582,9 +2587,9 @@ void PaintCommands::command_pen_setCosmetic(QRegExp re) } /***************************************************************************************************/ -void PaintCommands::command_drawConvexPolygon(QRegExp re) +void PaintCommands::command_drawConvexPolygon(QRegularExpressionMatch re) { - static QRegExp separators("\\s"); + static QRegularExpression separators("\\s"); QStringList caps = re.capturedTexts(); QString cap = caps.at(1); QStringList numbers = cap.split(separators, QString::SkipEmptyParts); diff --git a/tests/auto/other/lancelot/paintcommands.h b/tests/auto/other/lancelot/paintcommands.h index fc7496ce11..e3fb96744c 100644 --- a/tests/auto/other/lancelot/paintcommands.h +++ b/tests/auto/other/lancelot/paintcommands.h @@ -32,13 +32,13 @@ #include #include #include +#include #include #include #include #include QT_FORWARD_DECLARE_CLASS(QPainter) -QT_FORWARD_DECLARE_CLASS(QRegExp) #ifndef QT_NO_OPENGL QT_FORWARD_DECLARE_CLASS(QOpenGLFramebufferObject) QT_FORWARD_DECLARE_CLASS(QOpenGLPaintDevice) @@ -128,121 +128,121 @@ private: QColor convertToColor(const QString &str); // commands: comments - void command_comment(QRegExp re); + void command_comment(QRegularExpressionMatch re); // commands: importer - void command_import(QRegExp re); + void command_import(QRegularExpressionMatch re); // commands: blocks - void command_begin_block(QRegExp re); - void command_end_block(QRegExp re); - void command_repeat_block(QRegExp re); + void command_begin_block(QRegularExpressionMatch re); + void command_end_block(QRegularExpressionMatch re); + void command_repeat_block(QRegularExpressionMatch re); // commands: misc - void command_textlayout_draw(QRegExp re); - void command_abort(QRegExp re); + void command_textlayout_draw(QRegularExpressionMatch re); + void command_abort(QRegularExpressionMatch re); // commands: noops - void command_noop(QRegExp re); + void command_noop(QRegularExpressionMatch re); // commands: setters - void command_setBgMode(QRegExp re); - void command_setBackground(QRegExp re); - void command_setOpacity(QRegExp re); - void command_path_setFillRule(QRegExp re); - void command_setBrush(QRegExp re); - void command_setBrushOrigin(QRegExp re); - void command_brushTranslate(QRegExp re); - void command_brushRotate(QRegExp re); - void command_brushScale(QRegExp re); - void command_brushShear(QRegExp re); - void command_setClipPath(QRegExp re); - void command_setClipRect(QRegExp re); - void command_setClipRectangle(QRegExp re); - void command_setClipRegion(QRegExp re); - void command_setClipping(QRegExp re); - void command_setCompositionMode(QRegExp re); - void command_setFont(QRegExp re); - void command_setPen(QRegExp re); - void command_setPen2(QRegExp re); - void command_pen_setDashOffset(QRegExp re); - void command_pen_setDashPattern(QRegExp re); - void command_pen_setCosmetic(QRegExp re); - void command_setRenderHint(QRegExp re); - void command_clearRenderHint(QRegExp re); - void command_gradient_appendStop(QRegExp re); - void command_gradient_clearStops(QRegExp re); - void command_gradient_setConical(QRegExp re); - void command_gradient_setLinear(QRegExp re); - void command_gradient_setRadial(QRegExp re); - void command_gradient_setRadialExtended(QRegExp re); - void command_gradient_setLinearPen(QRegExp re); - void command_gradient_setSpread(QRegExp re); - void command_gradient_setCoordinateMode(QRegExp re); + void command_setBgMode(QRegularExpressionMatch re); + void command_setBackground(QRegularExpressionMatch re); + void command_setOpacity(QRegularExpressionMatch re); + void command_path_setFillRule(QRegularExpressionMatch re); + void command_setBrush(QRegularExpressionMatch re); + void command_setBrushOrigin(QRegularExpressionMatch re); + void command_brushTranslate(QRegularExpressionMatch re); + void command_brushRotate(QRegularExpressionMatch re); + void command_brushScale(QRegularExpressionMatch re); + void command_brushShear(QRegularExpressionMatch re); + void command_setClipPath(QRegularExpressionMatch re); + void command_setClipRect(QRegularExpressionMatch re); + void command_setClipRectangle(QRegularExpressionMatch re); + void command_setClipRegion(QRegularExpressionMatch re); + void command_setClipping(QRegularExpressionMatch re); + void command_setCompositionMode(QRegularExpressionMatch re); + void command_setFont(QRegularExpressionMatch re); + void command_setPen(QRegularExpressionMatch re); + void command_setPen2(QRegularExpressionMatch re); + void command_pen_setDashOffset(QRegularExpressionMatch re); + void command_pen_setDashPattern(QRegularExpressionMatch re); + void command_pen_setCosmetic(QRegularExpressionMatch re); + void command_setRenderHint(QRegularExpressionMatch re); + void command_clearRenderHint(QRegularExpressionMatch re); + void command_gradient_appendStop(QRegularExpressionMatch re); + void command_gradient_clearStops(QRegularExpressionMatch re); + void command_gradient_setConical(QRegularExpressionMatch re); + void command_gradient_setLinear(QRegularExpressionMatch re); + void command_gradient_setRadial(QRegularExpressionMatch re); + void command_gradient_setRadialExtended(QRegularExpressionMatch re); + void command_gradient_setLinearPen(QRegularExpressionMatch re); + void command_gradient_setSpread(QRegularExpressionMatch re); + void command_gradient_setCoordinateMode(QRegularExpressionMatch re); // commands: drawing ops - void command_drawArc(QRegExp re); - void command_drawChord(QRegExp re); - void command_drawConvexPolygon(QRegExp re); - void command_drawEllipse(QRegExp re); - void command_drawImage(QRegExp re); - void command_drawLine(QRegExp re); - void command_drawPath(QRegExp re); - void command_drawPie(QRegExp re); - void command_drawPixmap(QRegExp re); - void command_drawPoint(QRegExp re); - void command_drawPolygon(QRegExp re); - void command_drawPolyline(QRegExp re); - void command_drawRect(QRegExp re); - void command_drawRoundedRect(QRegExp re); - void command_drawRoundRect(QRegExp re); - void command_drawText(QRegExp re); - void command_drawStaticText(QRegExp re); - void command_drawTiledPixmap(QRegExp re); - void command_path_addEllipse(QRegExp re); - void command_path_addPolygon(QRegExp re); - void command_path_addRect(QRegExp re); - void command_path_addText(QRegExp re); - void command_path_arcTo(QRegExp re); - void command_path_closeSubpath(QRegExp re); - void command_path_createOutline(QRegExp re); - void command_path_cubicTo(QRegExp re); - void command_path_debugPrint(QRegExp re); - void command_path_lineTo(QRegExp re); - void command_path_moveTo(QRegExp re); - void command_region_addEllipse(QRegExp re); - void command_region_addRect(QRegExp re); + void command_drawArc(QRegularExpressionMatch re); + void command_drawChord(QRegularExpressionMatch re); + void command_drawConvexPolygon(QRegularExpressionMatch re); + void command_drawEllipse(QRegularExpressionMatch re); + void command_drawImage(QRegularExpressionMatch re); + void command_drawLine(QRegularExpressionMatch re); + void command_drawPath(QRegularExpressionMatch re); + void command_drawPie(QRegularExpressionMatch re); + void command_drawPixmap(QRegularExpressionMatch re); + void command_drawPoint(QRegularExpressionMatch re); + void command_drawPolygon(QRegularExpressionMatch re); + void command_drawPolyline(QRegularExpressionMatch re); + void command_drawRect(QRegularExpressionMatch re); + void command_drawRoundedRect(QRegularExpressionMatch re); + void command_drawRoundRect(QRegularExpressionMatch re); + void command_drawText(QRegularExpressionMatch re); + void command_drawStaticText(QRegularExpressionMatch re); + void command_drawTiledPixmap(QRegularExpressionMatch re); + void command_path_addEllipse(QRegularExpressionMatch re); + void command_path_addPolygon(QRegularExpressionMatch re); + void command_path_addRect(QRegularExpressionMatch re); + void command_path_addText(QRegularExpressionMatch re); + void command_path_arcTo(QRegularExpressionMatch re); + void command_path_closeSubpath(QRegularExpressionMatch re); + void command_path_createOutline(QRegularExpressionMatch re); + void command_path_cubicTo(QRegularExpressionMatch re); + void command_path_debugPrint(QRegularExpressionMatch re); + void command_path_lineTo(QRegularExpressionMatch re); + void command_path_moveTo(QRegularExpressionMatch re); + void command_region_addEllipse(QRegularExpressionMatch re); + void command_region_addRect(QRegularExpressionMatch re); // getters - void command_region_getClipRegion(QRegExp re); - void command_path_getClipPath(QRegExp re); + void command_region_getClipRegion(QRegularExpressionMatch re); + void command_path_getClipPath(QRegularExpressionMatch re); // commands: surface begin/end - void command_surface_begin(QRegExp re); - void command_surface_end(QRegExp re); + void command_surface_begin(QRegularExpressionMatch re); + void command_surface_end(QRegularExpressionMatch re); // commands: save/restore painter state - void command_restore(QRegExp re); - void command_save(QRegExp re); + void command_restore(QRegularExpressionMatch re); + void command_save(QRegularExpressionMatch re); // commands: pixmap/image - void command_pixmap_load(QRegExp re); - void command_pixmap_setMask(QRegExp re); - void command_bitmap_load(QRegExp re); - void command_image_convertToFormat(QRegExp re); - void command_image_load(QRegExp re); - void command_image_setColor(QRegExp re); - void command_image_setColorCount(QRegExp re); + void command_pixmap_load(QRegularExpressionMatch re); + void command_pixmap_setMask(QRegularExpressionMatch re); + void command_bitmap_load(QRegularExpressionMatch re); + void command_image_convertToFormat(QRegularExpressionMatch re); + void command_image_load(QRegularExpressionMatch re); + void command_image_setColor(QRegularExpressionMatch re); + void command_image_setColorCount(QRegularExpressionMatch re); // commands: transformation - void command_resetMatrix(QRegExp re); - void command_translate(QRegExp re); - void command_rotate(QRegExp re); - void command_rotate_x(QRegExp re); - void command_rotate_y(QRegExp re); - void command_scale(QRegExp re); - void command_mapQuadToQuad(QRegExp re); - void command_setMatrix(QRegExp re); + void command_resetMatrix(QRegularExpressionMatch re); + void command_translate(QRegularExpressionMatch re); + void command_rotate(QRegularExpressionMatch re); + void command_rotate_x(QRegularExpressionMatch re); + void command_rotate_y(QRegularExpressionMatch re); + void command_scale(QRegularExpressionMatch re); + void command_mapQuadToQuad(QRegularExpressionMatch re); + void command_setMatrix(QRegularExpressionMatch re); // attributes QPainter *m_painter; @@ -302,7 +302,7 @@ private: public: struct PaintCommandInfos { - PaintCommandInfos(QString id, void (PaintCommands::*p)(QRegExp), QRegExp r, QString sy, QString sa) + PaintCommandInfos(QString id, void (PaintCommands::*p)(QRegularExpressionMatch), QRegularExpression r, QString sy, QString sa) : identifier(id) , regExp(r) , syntax(sy) @@ -313,10 +313,10 @@ public: : identifier(title), paintMethod(0) {} bool isSectionHeader() const { return paintMethod == 0; } QString identifier; - QRegExp regExp; + QRegularExpression regExp; QString syntax; QString sample; - void (PaintCommands::*paintMethod)(QRegExp); + void (PaintCommands::*paintMethod)(QRegularExpressionMatch); }; static PaintCommandInfos *findCommandById(const QString &identifier) { From 7ebe69d23c33971b96790510df94d4d3bd438c58 Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Wed, 14 Mar 2018 16:01:59 +0100 Subject: [PATCH 22/23] Expose gdb-index as configure argument We report it in the overview, but left no way of controlling it Change-Id: I1d31f2e31bb32566f47069c3776e41033ffb1891 Reviewed-by: hjk Reviewed-by: Oswald Buddenhagen --- config_help.txt | 2 ++ configure.json | 1 + 2 files changed, 3 insertions(+) diff --git a/config_help.txt b/config_help.txt index 3e2c0c61b0..d15e113b9a 100644 --- a/config_help.txt +++ b/config_help.txt @@ -95,6 +95,8 @@ Build options: -optimized-tools ..... Build optimized host tools even in debug build [no] -force-debug-info .... Create symbol files for release builds [no] -separate-debug-info . Split off debug information to separate files [no] + -gdb-index ........... Index the debug info to speed up GDB + [no; auto if -developer-build with debug info] -strip ............... Strip release binaries of unneeded symbols [yes] -force-asserts ....... Enable Q_ASSERT even in release builds [no] -developer-build ..... Compile and link Qt for developing Qt itself diff --git a/configure.json b/configure.json index 3f751203b8..003c6c5b90 100644 --- a/configure.json +++ b/configure.json @@ -78,6 +78,7 @@ "force-debug-info": { "type": "boolean", "name": "force_debug_info" }, "force-pkg-config": { "type": "void", "name": "pkg-config" }, "framework": "boolean", + "gdb-index": { "type": "boolean", "name": "gdb_index" }, "gcc-sysroot": "boolean", "gcov": "boolean", "gnumake": { "type": "boolean", "name": "GNUmake" }, From fc8fd508165c8e4dcfe0da397b63cf99f15178e3 Mon Sep 17 00:00:00 2001 From: Sergio Martins Date: Tue, 20 Mar 2018 15:55:02 +0000 Subject: [PATCH 23/23] Fix subpixel rendering on Windows/FreeType FT_LCD_FILTER_H wasn't defined because we weren't including the header. To fix it just remove the checks, as was done for Linux and assume sub-pixel is there. If it's not then no harm done, it won't use any. Change-Id: I76f50cb17e41621c45c03cb7d5c75c110557ea68 Reviewed-by: Allan Sandfeld Jensen Reviewed-by: Friedemann Kleint --- src/plugins/platforms/windows/qwindowsscreen.cpp | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/plugins/platforms/windows/qwindowsscreen.cpp b/src/plugins/platforms/windows/qwindowsscreen.cpp index 66d3b140e2..d56dc870ea 100644 --- a/src/plugins/platforms/windows/qwindowsscreen.cpp +++ b/src/plugins/platforms/windows/qwindowsscreen.cpp @@ -396,9 +396,6 @@ Qt::ScreenOrientation QWindowsScreen::orientationPreference() */ QPlatformScreen::SubpixelAntialiasingType QWindowsScreen::subpixelAntialiasingTypeHint() const { -#if !defined(FT_LCD_FILTER_H) || !defined(FT_CONFIG_OPTION_SUBPIXEL_RENDERING) - return QPlatformScreen::Subpixel_None; -#else QPlatformScreen::SubpixelAntialiasingType type = QPlatformScreen::subpixelAntialiasingTypeHint(); if (type == QPlatformScreen::Subpixel_None) { QSettings settings(QLatin1String("HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Avalon.Graphics\\DISPLAY1"), QSettings::NativeFormat); @@ -419,7 +416,6 @@ QPlatformScreen::SubpixelAntialiasingType QWindowsScreen::subpixelAntialiasingTy } } return type; -#endif } /*!