From b8802071ed00689373da5817fc4824a30b5fcf86 Mon Sep 17 00:00:00 2001 From: ChunLin Wang Date: Wed, 31 Mar 2021 17:54:49 +0800 Subject: Fix get out of bounds index in QSortFilterProxyModel::filterAcceptsRow Before calling the index function, we need to check the validity of the parameters. Fixes: QTBUG-91878 Pick-to: 5.15 6.0 6.1 Change-Id: I9ec7265fff3f81b8a288c4ba8fae606a2ec808a6 Reviewed-by: David Faure --- src/corelib/itemmodels/qsortfilterproxymodel.cpp | 8 +++++--- .../tst_qconcatenatetablesproxymodel.cpp | 17 +++++++++++++++++ 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/src/corelib/itemmodels/qsortfilterproxymodel.cpp b/src/corelib/itemmodels/qsortfilterproxymodel.cpp index 9fb66b023a..a5bb56245a 100644 --- a/src/corelib/itemmodels/qsortfilterproxymodel.cpp +++ b/src/corelib/itemmodels/qsortfilterproxymodel.cpp @@ -3001,8 +3001,9 @@ bool QSortFilterProxyModel::filterAcceptsRow(int source_row, const QModelIndex & if (d->filter_data.pattern().isEmpty()) return true; + + int column_count = d->model->columnCount(source_parent); if (d->filter_column == -1) { - int column_count = d->model->columnCount(source_parent); for (int column = 0; column < column_count; ++column) { QModelIndex source_index = d->model->index(source_row, column, source_parent); QString key = d->model->data(source_index, d->filter_role).toString(); @@ -3011,9 +3012,10 @@ bool QSortFilterProxyModel::filterAcceptsRow(int source_row, const QModelIndex & } return false; } - QModelIndex source_index = d->model->index(source_row, d->filter_column, source_parent); - if (!source_index.isValid()) // the column may not exist + + if (d->filter_column >= column_count) // the column may not exist return true; + QModelIndex source_index = d->model->index(source_row, d->filter_column, source_parent); QString key = d->model->data(source_index, d->filter_role).toString(); return d->filter_data.match(key).hasMatch(); } diff --git a/tests/auto/corelib/itemmodels/qconcatenatetablesproxymodel/tst_qconcatenatetablesproxymodel.cpp b/tests/auto/corelib/itemmodels/qconcatenatetablesproxymodel/tst_qconcatenatetablesproxymodel.cpp index e1ea7a4552..90972caa57 100644 --- a/tests/auto/corelib/itemmodels/qconcatenatetablesproxymodel/tst_qconcatenatetablesproxymodel.cpp +++ b/tests/auto/corelib/itemmodels/qconcatenatetablesproxymodel/tst_qconcatenatetablesproxymodel.cpp @@ -117,6 +117,7 @@ private Q_SLOTS: void shouldPropagateDropAfterLastRow_data(); void shouldPropagateDropAfterLastRow(); void qtbug91788(); + void qtbug91878(); private: QStandardItemModel mod; @@ -843,6 +844,22 @@ void tst_QConcatenateTablesProxyModel::qtbug91788() QCOMPARE(proxyConcat.columnCount(), 0); } +void tst_QConcatenateTablesProxyModel::qtbug91878() +{ + QStandardItemModel m; + m.setRowCount(4); + m.setColumnCount(4); + + QConcatenateTablesProxyModel pm; + QSortFilterProxyModel proxyFilter; + proxyFilter.setSourceModel(&pm); + proxyFilter.setFilterFixedString("something"); + pm.addSourceModel(&m); // This should not assert + + QCOMPARE(pm.columnCount(), 4); + QCOMPARE(pm.rowCount(), 4); +} + QTEST_GUILESS_MAIN(tst_QConcatenateTablesProxyModel) #include "tst_qconcatenatetablesproxymodel.moc" -- cgit v1.2.3 From 587e3bb0ba6def90906f1f6b8c60c8f33ec88571 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A5rten=20Nordheim?= Date: Thu, 25 Mar 2021 17:26:37 +0100 Subject: QSemaphore: fix missed wakes with futex on Windows We do this by making the 'futexNeedsWakeAllBit' to be part of both the expectedValue and the pointer we're waiting on. This makes sense since having the 'futexNeedsWakeAllBit' set is a requirement for starting a sleep. Thus we should condition sleeping on whether or not another thread unset it. Since the futexNeedsWakeAllBit is in the "topmost" bit of the pointer we wait on we'll need to use the full 64-bits on 64-bit platforms. This isn't enabled (nor was it an issue) for configurations with 'futexHasWaiterCount' since that works differently, and waits for the high 32 bits. Fixes: QTBUG-92148 Change-Id: I424c605f0120ea5e647c5bb19b00ff35eaf1608a Reviewed-by: Thiago Macieira --- src/corelib/thread/qsemaphore.cpp | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/src/corelib/thread/qsemaphore.cpp b/src/corelib/thread/qsemaphore.cpp index 5111d80ac6..45983d47ab 100644 --- a/src/corelib/thread/qsemaphore.cpp +++ b/src/corelib/thread/qsemaphore.cpp @@ -200,14 +200,21 @@ futexSemaphoreTryAcquire_loop(QBasicAtomicInteger &u, quintptr curValu // indicate we're waiting start_wait: - auto ptr = futexLow32(&u); + auto ptr = [&u]() { + if constexpr (futexHasWaiterCount) + return futexLow32(&u); + else + return &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; + if constexpr (futexHasWaiterCount) { + if (n > 1) { + ptr = futexHigh32(&u); + // curValue >>= 32; // but this is UB in 32-bit, so roundabout: + curValue = quint64(curValue) >> 32; + } } } @@ -397,7 +404,7 @@ void QSemaphore::release(int n) futexWakeOp(*futexLow32(&u), n, INT_MAX, *futexHigh32(&u), FUTEX_OP(op, oparg, cmp, cmparg)); } #else - // Unset the bit and wake everyone. There are two possibibilies + // Unset the bit and wake everyone. There are two possibilities // under which a thread can set the bit between the AND and the // futexWake: // 1) it did see the new counter value, but it wasn't enough for -- cgit v1.2.3 From 0baa26638d7d14b6609dab191c4ea0cc1d3ff50a Mon Sep 17 00:00:00 2001 From: Ilya Fedin Date: Sun, 14 Feb 2021 23:06:23 +0400 Subject: indicator-application hack: fallback to dbus service check There is a hack to work with Canonical's indicator-application tray applet. Since it implements the SNI spec partially and doesn't work with IconPixmap, the icon is broken without the hack. Unfortunately, this tray implementation is still in active use by Ubuntu; it's shipped and enabled by default on at least: * Xubuntu * Ubuntu MATE * Ubuntu Budgie (and maybe even others) Unfortunately, the check doesn't work in confined environments providing broken tray icons for snapped & flatpak'ed apps. Fortunately, snap allows checking all registered services on the host. It also fixes the check on flatpak if permissions to talk with these names are given. Pick-to: 6.1 6.0 Change-Id: Iee5d0bb610c3ff397babee89ef1ee788ac19f477 Reviewed-by: Shawn Rutledge --- src/gui/platform/unix/dbustray/qdbustrayicon.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/gui/platform/unix/dbustray/qdbustrayicon.cpp b/src/gui/platform/unix/dbustray/qdbustrayicon.cpp index 1194e4ac66..892a99d726 100644 --- a/src/gui/platform/unix/dbustray/qdbustrayicon.cpp +++ b/src/gui/platform/unix/dbustray/qdbustrayicon.cpp @@ -208,6 +208,14 @@ QTemporaryFile *QDBusTrayIcon::tempIcon(const QIcon &icon) uint pid = session.interface()->servicePid(KDEWatcherService).value(); QString processName = QLockFilePrivate::processNameByPid(pid); necessary = processName.endsWith(QLatin1String("indicator-application-service")); + if (!necessary) { + necessary = session.interface()->isServiceRegistered( + QStringLiteral("com.canonical.indicator.application")); + } + if (!necessary) { + necessary = session.interface()->isServiceRegistered( + QStringLiteral("org.ayatana.indicator.application")); + } if (!necessary && QGuiApplication::desktopSettingsAware()) { // Accessing to process name might be not allowed if the application // is confined, thus we can just rely on the current desktop in use -- cgit v1.2.3 From df54a5d087d7e3a5cf20bb34fefd8d643a7b2f58 Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Sun, 4 Apr 2021 15:59:54 +0200 Subject: Add QRhiTexture::RG16 format Those are needed to handle 16bit YUV formats in Qt Multimedia. Change-Id: I39c67bf4fcf558487b7819ea38e578f99c12a3ed Reviewed-by: Laszlo Agocs --- src/gui/rhi/qrhi.cpp | 5 +++++ src/gui/rhi/qrhi_p.h | 1 + src/gui/rhi/qrhid3d11.cpp | 4 ++++ src/gui/rhi/qrhigles2.cpp | 13 +++++++++++++ src/gui/rhi/qrhimetal.mm | 2 ++ src/gui/rhi/qrhivulkan.cpp | 4 ++++ 6 files changed, 29 insertions(+) diff --git a/src/gui/rhi/qrhi.cpp b/src/gui/rhi/qrhi.cpp index fea688e9cd..8c24f11079 100644 --- a/src/gui/rhi/qrhi.cpp +++ b/src/gui/rhi/qrhi.cpp @@ -2378,6 +2378,8 @@ QRhiResource::Type QRhiRenderBuffer::resourceType() const \value R16 One component, unsigned normalized 16 bit. + \value RG16 Two component, unsigned normalized 16 bit. + \value RED_OR_ALPHA8 Either same as R8, or is a similar format with the component swizzled to alpha, depending on \l{QRhi::RedOrAlpha8IsRed}{RedOrAlpha8IsRed}. @@ -4533,6 +4535,9 @@ void QRhiImplementation::textureFormatInfo(QRhiTexture::Format format, const QSi case QRhiTexture::R16: bpc = 2; break; + case QRhiTexture::RG16: + bpc = 4; + break; case QRhiTexture::RED_OR_ALPHA8: bpc = 1; break; diff --git a/src/gui/rhi/qrhi_p.h b/src/gui/rhi/qrhi_p.h index a4d65a661a..b43d490ea9 100644 --- a/src/gui/rhi/qrhi_p.h +++ b/src/gui/rhi/qrhi_p.h @@ -765,6 +765,7 @@ public: R8, RG8, R16, + RG16, RED_OR_ALPHA8, RGBA16F, diff --git a/src/gui/rhi/qrhid3d11.cpp b/src/gui/rhi/qrhid3d11.cpp index addb058d4d..46851ad612 100644 --- a/src/gui/rhi/qrhid3d11.cpp +++ b/src/gui/rhi/qrhid3d11.cpp @@ -1214,6 +1214,8 @@ static inline DXGI_FORMAT toD3DTextureFormat(QRhiTexture::Format format, QRhiTex return DXGI_FORMAT_R8G8_UNORM; case QRhiTexture::R16: return DXGI_FORMAT_R16_UNORM; + case QRhiTexture::RG16: + return DXGI_FORMAT_R16G16_UNORM; case QRhiTexture::RED_OR_ALPHA8: return DXGI_FORMAT_R8_UNORM; @@ -1300,6 +1302,8 @@ static inline QRhiTexture::Format colorTextureFormatFromDxgiFormat(DXGI_FORMAT f return QRhiTexture::RG8; case DXGI_FORMAT_R16_UNORM: return QRhiTexture::R16; + case DXGI_FORMAT_R16G16_UNORM: + return QRhiTexture::RG16; default: // this cannot assert, must warn and return unknown qWarning("DXGI_FORMAT %d is not a recognized uncompressed color format", format); break; diff --git a/src/gui/rhi/qrhigles2.cpp b/src/gui/rhi/qrhigles2.cpp index c2035869c3..8eaf02f817 100644 --- a/src/gui/rhi/qrhigles2.cpp +++ b/src/gui/rhi/qrhigles2.cpp @@ -160,6 +160,10 @@ QT_BEGIN_NAMESPACE #define GL_R16 0x822A #endif +#ifndef GL_RG16 +#define GL_RG16 0x822C +#endif + #ifndef GL_RED #define GL_RED 0x1903 #endif @@ -822,6 +826,12 @@ static inline void toGlTextureFormat(QRhiTexture::Format format, const QRhiGles2 *glformat = GL_RED; *gltype = GL_UNSIGNED_SHORT; break; + case QRhiTexture::RG16: + *glintformat = GL_RG16; + *glsizedintformat = *glintformat; + *glformat = GL_RG; + *gltype = GL_UNSIGNED_SHORT; + break; case QRhiTexture::R8: *glintformat = GL_R8; *glsizedintformat = *glintformat; @@ -926,6 +936,9 @@ bool QRhiGles2::isTextureFormatSupported(QRhiTexture::Format format, QRhiTexture case QRhiTexture::R16: return caps.r16Format; + case QRhiTexture::RG16: + return caps.r16Format; + case QRhiTexture::RGBA16F: case QRhiTexture::RGBA32F: return caps.floatFormats; diff --git a/src/gui/rhi/qrhimetal.mm b/src/gui/rhi/qrhimetal.mm index ab255f74df..850b3a91aa 100644 --- a/src/gui/rhi/qrhimetal.mm +++ b/src/gui/rhi/qrhimetal.mm @@ -2348,6 +2348,8 @@ static inline MTLPixelFormat toMetalTextureFormat(QRhiTexture::Format format, QR #endif case QRhiTexture::R16: return MTLPixelFormatR16Unorm; + case QRhiTexture::RG16: + return MTLPixelFormatRG16Unorm; case QRhiTexture::RED_OR_ALPHA8: return MTLPixelFormatR8Unorm; diff --git a/src/gui/rhi/qrhivulkan.cpp b/src/gui/rhi/qrhivulkan.cpp index 26d6de498b..e7e31b1b2d 100644 --- a/src/gui/rhi/qrhivulkan.cpp +++ b/src/gui/rhi/qrhivulkan.cpp @@ -886,6 +886,8 @@ static inline VkFormat toVkTextureFormat(QRhiTexture::Format format, QRhiTexture return srgb ? VK_FORMAT_R8G8_SRGB : VK_FORMAT_R8G8_UNORM; case QRhiTexture::R16: return VK_FORMAT_R16_UNORM; + case QRhiTexture::RG16: + return VK_FORMAT_R16G16_UNORM; case QRhiTexture::RED_OR_ALPHA8: return VK_FORMAT_R8_UNORM; @@ -993,6 +995,8 @@ static inline QRhiTexture::Format colorTextureFormatFromVkFormat(VkFormat format return QRhiTexture::RG8; case VK_FORMAT_R16_UNORM: return QRhiTexture::R16; + case VK_FORMAT_R16G16_UNORM: + return QRhiTexture::RG16; default: // this cannot assert, must warn and return unknown qWarning("VkFormat %d is not a recognized uncompressed color format", format); break; -- cgit v1.2.3