From 14b61d48e8bad6223a08843cf363ef48f09c479b Mon Sep 17 00:00:00 2001 From: Christian Ehrlicher Date: Fri, 11 Oct 2019 20:53:49 +0200 Subject: QPSQL: Add support for PostgreSQL 12 Add proper version check and replace long deprecated and now removed access to pg_attrdef.adsrc. [ChangeLog][QtSql][QPSQL] added support for PostgreSQL 12 Fixes: QTBUG-79033 Fixes: QTBUG-79064 Change-Id: Iec1b13945c34ea017139ad1c5539ab5b7f1e03aa Reviewed-by: Edward Welbourne --- src/plugins/sqldrivers/psql/qsql_psql.cpp | 43 +++++++++++++++++-------------- src/plugins/sqldrivers/psql/qsql_psql_p.h | 1 + 2 files changed, 25 insertions(+), 19 deletions(-) diff --git a/src/plugins/sqldrivers/psql/qsql_psql.cpp b/src/plugins/sqldrivers/psql/qsql_psql.cpp index 3803f05b9f..760685f64b 100644 --- a/src/plugins/sqldrivers/psql/qsql_psql.cpp +++ b/src/plugins/sqldrivers/psql/qsql_psql.cpp @@ -1078,8 +1078,10 @@ static QPSQLDriver::Protocol qMakePSQLVersion(int vMaj, int vMin) return QPSQLDriver::Version10; case 11: return QPSQLDriver::Version11; + case 12: + return QPSQLDriver::Version12; default: - if (vMaj > 11) + if (vMaj > 12) return QPSQLDriver::UnknownLaterVersion; break; } @@ -1439,26 +1441,29 @@ QSqlRecord QPSQLDriver::record(const QString &tablename) const schema = stripDelimiters(schema, QSqlDriver::TableName); tbl = stripDelimiters(tbl, QSqlDriver::TableName); - QString stmt = QStringLiteral("SELECT pg_attribute.attname, pg_attribute.atttypid::int, " - "pg_attribute.attnotnull, pg_attribute.attlen, pg_attribute.atttypmod, " - "pg_attrdef.adsrc " - "FROM pg_class, pg_attribute " - "LEFT JOIN pg_attrdef ON (pg_attrdef.adrelid = " - "pg_attribute.attrelid AND pg_attrdef.adnum = pg_attribute.attnum) " - "WHERE %1 " - "AND pg_class.relname = '%2' " - "AND pg_attribute.attnum > 0 " - "AND pg_attribute.attrelid = pg_class.oid " - "AND pg_attribute.attisdropped = false " - "ORDER BY pg_attribute.attnum"); - if (schema.isEmpty()) - stmt = stmt.arg(QStringLiteral("pg_table_is_visible(pg_class.oid)")); - else - stmt = stmt.arg(QStringLiteral("pg_class.relnamespace = (SELECT oid FROM " - "pg_namespace WHERE pg_namespace.nspname = '%1')").arg(schema)); + const QString adsrc = protocol() < Version8 + ? QStringLiteral("pg_attrdef.adsrc") + : QStringLiteral("pg_get_expr(pg_attrdef.adbin, pg_attrdef.adrelid)"); + const QString nspname = schema.isEmpty() + ? QStringLiteral("pg_table_is_visible(pg_class.oid)") + : QStringLiteral("pg_class.relnamespace = (SELECT oid FROM " + "pg_namespace WHERE pg_namespace.nspname = '%1')").arg(schema); + const QString stmt = + QStringLiteral("SELECT pg_attribute.attname, pg_attribute.atttypid::int, " + "pg_attribute.attnotnull, pg_attribute.attlen, pg_attribute.atttypmod, " + "%1 " + "FROM pg_class, pg_attribute " + "LEFT JOIN pg_attrdef ON (pg_attrdef.adrelid = " + "pg_attribute.attrelid AND pg_attrdef.adnum = pg_attribute.attnum) " + "WHERE %2 " + "AND pg_class.relname = '%3' " + "AND pg_attribute.attnum > 0 " + "AND pg_attribute.attrelid = pg_class.oid " + "AND pg_attribute.attisdropped = false " + "ORDER BY pg_attribute.attnum").arg(adsrc, nspname, tbl); QSqlQuery query(createResult()); - query.exec(stmt.arg(tbl)); + query.exec(stmt); while (query.next()) { int len = query.value(3).toInt(); int precision = query.value(4).toInt(); diff --git a/src/plugins/sqldrivers/psql/qsql_psql_p.h b/src/plugins/sqldrivers/psql/qsql_psql_p.h index 99e0b5f60f..9ac1fb50d7 100644 --- a/src/plugins/sqldrivers/psql/qsql_psql_p.h +++ b/src/plugins/sqldrivers/psql/qsql_psql_p.h @@ -93,6 +93,7 @@ public: Version9_6 = 22, Version10 = 23, Version11 = 24, + Version12 = 25, UnknownLaterVersion = 100000 }; -- cgit v1.2.3 From 19f29802bf7daafacd0fd824c2a1349e80eac536 Mon Sep 17 00:00:00 2001 From: Eirik Aavitsland Date: Thu, 17 Oct 2019 13:25:06 +0200 Subject: Fix: QPainter off-by-one clipping for some non-integer scalings For some scalings, setClipRect(QRect) would produce a clip one pixel different from setClipRect(QRectF) because of different rounding. Ditto for setClipRegion. Fix by making sure to transform QRectFs instead of QRects. Fixes: QTBUG-78962 Fixes: QTBUG-78963 Change-Id: I0be721133858c30769ec6d81e978962a3d6b70cf Reviewed-by: Christoph Cullmann Reviewed-by: Allan Sandfeld Jensen --- src/gui/painting/qpaintengine_raster.cpp | 2 +- src/gui/painting/qtransform.cpp | 4 +- tests/auto/gui/painting/qpainter/tst_qpainter.cpp | 49 ++++++++++++++++++++++- 3 files changed, 51 insertions(+), 4 deletions(-) diff --git a/src/gui/painting/qpaintengine_raster.cpp b/src/gui/painting/qpaintengine_raster.cpp index 8c51981120..40c822076b 100644 --- a/src/gui/painting/qpaintengine_raster.cpp +++ b/src/gui/painting/qpaintengine_raster.cpp @@ -1319,7 +1319,7 @@ void QRasterPaintEngine::clip(const QRect &rect, Qt::ClipOperation op) QPaintEngineEx::clip(rect, op); return; - } else if (!setClipRectInDeviceCoords(s->matrix.mapRect(rect), op)) { + } else if (!setClipRectInDeviceCoords(s->matrix.mapRect(QRectF(rect)).toRect(), op)) { QPaintEngineEx::clip(rect, op); return; } diff --git a/src/gui/painting/qtransform.cpp b/src/gui/painting/qtransform.cpp index 7696da7d45..d75b66c50b 100644 --- a/src/gui/painting/qtransform.cpp +++ b/src/gui/painting/qtransform.cpp @@ -1529,12 +1529,12 @@ QRegion QTransform::map(const QRegion &r) const QRegion res; if (m11() < 0 || m22() < 0) { for (const QRect &rect : r) - res += mapRect(rect); + res += mapRect(QRectF(rect)).toRect(); } else { QVarLengthArray rects; rects.reserve(r.rectCount()); for (const QRect &rect : r) { - QRect nr = mapRect(rect); + QRect nr = mapRect(QRectF(rect)).toRect(); if (!nr.isEmpty()) rects.append(nr); } diff --git a/tests/auto/gui/painting/qpainter/tst_qpainter.cpp b/tests/auto/gui/painting/qpainter/tst_qpainter.cpp index d2a4dfc3e9..6e48439944 100644 --- a/tests/auto/gui/painting/qpainter/tst_qpainter.cpp +++ b/tests/auto/gui/painting/qpainter/tst_qpainter.cpp @@ -157,10 +157,10 @@ private slots: void clippedLines(); void clippedPolygon_data(); void clippedPolygon(); - void clippedText(); void clipBoundingRect(); + void transformedClip(); void setOpacity_data(); void setOpacity(); @@ -4589,6 +4589,53 @@ void tst_QPainter::clipBoundingRect() } +void tst_QPainter::transformedClip() +{ + QImage img(8, 4, QImage::Format_ARGB32_Premultiplied); + QImage img2(img.size(), img.format()); + QRect clip(0, 0, 2, 1); + QTransform xf; + xf.translate(0.2, 0); + xf.scale(2.2, 1); + // setClipRect(QRectF) + { + img.fill(Qt::green); + QPainter p(&img); + p.setTransform(xf); + p.setClipRect(QRectF(clip)); + p.fillRect(img.rect(), Qt::white); + } + // setClipRect(QRect) + { + img2.fill(Qt::green); + QPainter p(&img2); + p.setTransform(xf); + p.setClipRect(clip); + p.fillRect(img2.rect(), Qt::white); + QCOMPARE(img, img2); + } + // setClipRegion + { + img2.fill(Qt::green); + QPainter p(&img2); + p.setTransform(xf); + p.setClipRegion(QRegion(clip) + QRect(0, 3, 1, 1)); // dummy extra rect to avoid single-rect codepath + p.fillRect(img2.rect(), Qt::white); + QCOMPARE(img.copy(0, 0, 8, 2), img2.copy(0, 0, 8, 2)); + } + // setClipPath + { + img2.fill(Qt::green); + QPainter p(&img2); + p.setTransform(xf); + QPainterPath path; + path.addRect(clip); + p.setClipPath(path); + p.fillRect(img2.rect(), Qt::white); + QCOMPARE(img, img2); + } +} + #if defined(Q_OS_MAC) // Only Mac supports sub pixel positions in raster engine currently void tst_QPainter::drawText_subPixelPositionsInRaster_qtbug5053() -- cgit v1.2.3 From a7df98a9a72ee460c6bd23388d52b1200e7ed3ba Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Fri, 11 Oct 2019 13:39:46 +0200 Subject: QSortFilterProxyModel: Add a cheaper way to find source_sort_column There are two places where we are only interested in the mapping of proxy to source sort column, rather than the full mapping. Creating the full mapping is rather expensive as it iterates all rows and columns and allocates a large number of objects. Just figuring out the n-th accepted column can be much cheaper. Fixes: QTBUG-41659 Change-Id: I7ea914cb695518b4d47cdc3ad67c7786380d8709 Reviewed-by: David Faure Reviewed-by: Christian Ehrlicher --- src/corelib/itemmodels/qsortfilterproxymodel.cpp | 40 ++++++++++++++++++------ 1 file changed, 30 insertions(+), 10 deletions(-) diff --git a/src/corelib/itemmodels/qsortfilterproxymodel.cpp b/src/corelib/itemmodels/qsortfilterproxymodel.cpp index 675bf4b8c3..978102035e 100644 --- a/src/corelib/itemmodels/qsortfilterproxymodel.cpp +++ b/src/corelib/itemmodels/qsortfilterproxymodel.cpp @@ -377,6 +377,7 @@ public: void sort(); bool update_source_sort_column(); + int find_source_sort_column() const; void sort_source_rows(QVector &source_rows, const QModelIndex &source_parent) const; QVector > > proxy_intervals_for_source_items_to_add( @@ -479,11 +480,8 @@ void QSortFilterProxyModelPrivate::_q_clearMapping() qDeleteAll(source_index_mapping); source_index_mapping.clear(); - if (dynamic_sortfilter && update_source_sort_column()) { - //update_source_sort_column might have created wrong mapping so we have to clear it again - qDeleteAll(source_index_mapping); - source_index_mapping.clear(); - } + if (dynamic_sortfilter) + source_sort_column = find_source_sort_column(); // update the persistent indexes update_persistent_indexes(source_indexes); @@ -640,6 +638,31 @@ bool QSortFilterProxyModelPrivate::update_source_sort_column() return old_source_sort_column != source_sort_column; } +/*! + \internal + + Find the source_sort_column without creating a full mapping and + without updating anything. +*/ +int QSortFilterProxyModelPrivate::find_source_sort_column() const +{ + if (proxy_sort_column == -1) + return -1; + + const QModelIndex rootIndex; + const int source_cols = model->columnCount(); + int accepted_columns = -1; + + Q_Q(const QSortFilterProxyModel); + for (int i = 0; i < source_cols; ++i) { + if (q->filterAcceptsColumn(i, rootIndex)) { + if (++accepted_columns == proxy_sort_column) + return i; + } + } + + return -1; +} /*! \internal @@ -1591,11 +1614,8 @@ void QSortFilterProxyModelPrivate::_q_sourceLayoutChanged(const QListlayoutChanged(saved_layoutChange_parents); saved_layoutChange_parents.clear(); -- cgit v1.2.3 From 2c9bd677abde65e8a31ef6d9772497203525f29a Mon Sep 17 00:00:00 2001 From: Volker Krause Date: Tue, 15 Oct 2019 18:56:36 +0200 Subject: Make QSslError::SslError a Q_ENUM This avoids error prone manual mappings when having to persist such values, as eg. done in https://cgit.kde.org/kio.git/tree/src/kssld/kssld.cpp#n49. Change-Id: Ib279c116a10ce8edc0b686b8b80cbd848b4b410e Reviewed-by: David Faure --- src/network/ssl/qsslerror.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/network/ssl/qsslerror.h b/src/network/ssl/qsslerror.h index c4a0d52193..28eb1a9ea8 100644 --- a/src/network/ssl/qsslerror.h +++ b/src/network/ssl/qsslerror.h @@ -53,6 +53,7 @@ QT_BEGIN_NAMESPACE class QSslErrorPrivate; class Q_NETWORK_EXPORT QSslError { + Q_GADGET public: enum SslError { NoError, @@ -94,6 +95,7 @@ public: OcspStatusUnknown, UnspecifiedError = -1 }; + Q_ENUM(SslError) // RVCT compiler in debug build does not like about default values in const- // So as an workaround we define all constructor overloads here explicitly -- cgit v1.2.3 From ff2ba8b9d2798c4b7a77734df723d6312b983f1d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Mon, 14 Oct 2019 14:07:20 +0200 Subject: macOS: Let system decide whether modal window should prevent app termination The logic for preventing application termination when there are modal windows active was a leftover from the Carbon to Cocoa port, and is no longer needed. AppKit will deal with this on its own, by checking the preventsApplicationTerminationWhenModal property of each NSWindow. In some cases AppKit will also ignore this property, such as when quitting the application from the menu entry, which means we now get the default system behavior for this use-case. Change-Id: Iac5d8d8e17eb0974448f7ee6f39c9b7761bf4d90 Reviewed-by: Shawn Rutledge Reviewed-by: Volker Hilsheimer --- .../platforms/cocoa/qcocoaapplicationdelegate.mm | 25 +++------------------- 1 file changed, 3 insertions(+), 22 deletions(-) diff --git a/src/plugins/platforms/cocoa/qcocoaapplicationdelegate.mm b/src/plugins/platforms/cocoa/qcocoaapplicationdelegate.mm index 9daf65abcf..33a45985a8 100644 --- a/src/plugins/platforms/cocoa/qcocoaapplicationdelegate.mm +++ b/src/plugins/platforms/cocoa/qcocoaapplicationdelegate.mm @@ -142,28 +142,9 @@ QT_USE_NAMESPACE - (BOOL)canQuit { - bool handle_quit = true; - NSMenuItem *quitMenuItem = [[QCocoaMenuLoader sharedMenuLoader] quitMenuItem]; - if (!QGuiApplicationPrivate::instance()->modalWindowList.isEmpty() - && [quitMenuItem isEnabled]) { - int visible = 0; - const QWindowList tlws = QGuiApplication::topLevelWindows(); - for (int i = 0; i < tlws.size(); ++i) { - if (tlws.at(i)->isVisible()) - ++visible; - } - handle_quit = (visible <= 1); - } - - if (handle_quit) { - QCloseEvent ev; - QGuiApplication::sendEvent(qGuiApp, &ev); - if (ev.isAccepted()) { - return YES; - } - } - - return NO; + QCloseEvent ev; + QGuiApplication::sendEvent(qGuiApp, &ev); + return ev.isAccepted(); } // This function will only be called when NSApp is actually running. -- cgit v1.2.3